// File: /workspace/github_cpp_makefile_star2_O3/lemire[P]validateutf8-experiments/tests/unit.cpp
// Function: test()
void test() {

  // additional tests are from autobahn websocket testsuite https://github.com/crossbario/autobahn-testsuite/tree/master/autobahntestsuite/autobahntestsuite/case
  const char *goodsequences[] = {"a", "\xc3\xb1", "\xe2\x82\xa1", "\xf0\x90\x8c\xbc", "안녕하세요, 세상",
                            "\xc2\x80", // 6.7.2
                            "\xf0\x90\x80\x80", // 6.7.4
                            "\xee\x80\x80", // 6.11.2
                            "\xef\xbb\xbf"
                            };
  const char *badsequences[] = {"\xc3\x28",         // 0
                          "\xa0\xa1",         // 1
                          "\xe2\x28\xa1",     // 2
                          "\xe2\x82\x28",     // 3
                          "\xf0\x28\x8c\xbc", // 4
                          "\xf0\x90\x28\xbc", // 5
                          "\xf0\x28\x8c\x28", // 6
                          "\xc0\x9f",         // 7
                          "\xf5\xff\xff\xff", // 8
                          "\xed\xa0\x81", // 9
                          "\xf8\x90\x80\x80\x80", //10
                          "123456789012345\xed", //11
                          "123456789012345\xf1", //12
                          "123456789012345\xc2", //13
                          "\xC2\x7F", // 14
                          "\xce", // 6.6.1
                          "\xce\xba\xe1", // 6.6.3
                          "\xce\xba\xe1\xbd", // 6.6.4
                          "\xce\xba\xe1\xbd\xb9\xcf", // 6.6.6
                          "\xce\xba\xe1\xbd\xb9\xcf\x83\xce", // 6.6.8
                          "\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce", // 6.6.10
                          "\xdf", // 6.14.6
                          "\xef\xbf", // 6.14.7
                          "\x80", 
                          "\x91\x85\x95\x9e",
                          "\x6c\x02\x8e\x18"
                        };
  for (size_t i = 0; i < 9; i++) {
    size_t len = strlen(goodsequences[i]);
    if(active_fastvalidate::lookup2::validate(goodsequences[i], len) != fastvalidate::error_code::SUCCESS) {
        printf("bug goodsequences[%zu]\n", i);
        abort();
    }
    if(active_fastvalidate::lookup3::validate(goodsequences[i], len) != fastvalidate::error_code::SUCCESS) {
        printf("bug goodsequences[%zu]\n", i);
        abort();
    }
    if(active_fastvalidate::lookup4::validate(goodsequences[i], len) != fastvalidate::error_code::SUCCESS) {
        printf("bug goodsequences[%zu]\n", i);
        abort();
    }
  }
  for (size_t i = 0; i < 26; i++) {
    size_t len = strlen(badsequences[i]);
    if(active_fastvalidate::lookup2::validate(badsequences[i], len) != fastvalidate::error_code::UTF8_ERROR) {
        printf("bug lookup2 badsequences[%zu]\n", i);
        abort();
    }
    if(active_fastvalidate::lookup3::validate(badsequences[i], len) != fastvalidate::error_code::UTF8_ERROR) {
        printf("bug lookup3 badsequences[%zu]\n", i);
        abort();
    }
    if(active_fastvalidate::lookup4::validate(badsequences[i], len) != fastvalidate::error_code::UTF8_ERROR) {
        printf("bug lookup4 badsequences[%zu]\n", i);
        abort();
    }
  }
  printf("tests ok.\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x44a8(%rip), %r12      # 0xaca0
xorl %ebx, %ebx
movq (%r12), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x550c
testl %eax, %eax
jne 0x68b7
movq %r14, %rdi
movq %r15, %rsi
callq 0x5511
testl %eax, %eax
jne 0x68b7
movq %r14, %rdi
movq %r15, %rsi
callq 0x5516
testl %eax, %eax
jne 0x68b7
incq %rbx
addq $0x8, %r12
cmpq $0x9, %rbx
jne 0x67fa
leaq 0x449e(%rip), %r12      # 0xacf0
xorl %ebx, %ebx
movq (%r12), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x550c
cmpl $0x1, %eax
jne 0x68d2
movq %r14, %rdi
movq %r15, %rsi
callq 0x5511
cmpl $0x1, %eax
jne 0x68c9
movq %r14, %rdi
movq %r15, %rsi
callq 0x5516
cmpl $0x1, %eax
jne 0x68c0
incq %rbx
addq $0x8, %r12
cmpq $0x1a, %rbx
jne 0x6854
leaq 0x2291(%rip), %rdi      # 0x8b38
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2180
leaq 0x209e(%rip), %rdi      # 0x895c
jmp 0x68d9
leaq 0x20eb(%rip), %rdi      # 0x89b2
jmp 0x68d9
leaq 0x20c3(%rip), %rdi      # 0x8993
jmp 0x68d9
leaq 0x209b(%rip), %rdi      # 0x8974
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
callq 0x20b0