// File: /workspace/github_cpp_makefile_star2_O2/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 0x86a8(%rip), %r12      # 0xbca0
xorl %ebx, %ebx
cmpq $0x9, %rbx
je 0x364d
movq (%r12), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x230c
testl %eax, %eax
jne 0x36bb
movq %r14, %rdi
movq %r15, %rsi
callq 0x2316
testl %eax, %eax
jne 0x36bb
movq %r14, %rdi
movq %r15, %rsi
callq 0x2320
testl %eax, %eax
jne 0x36bb
incq %rbx
addq $0x8, %r12
jmp 0x35fa
leaq 0x869c(%rip), %r12      # 0xbcf0
xorl %ebx, %ebx
cmpq $0x1a, %rbx
je 0x36a4
movq (%r12), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x230c
cmpl $0x1, %eax
jne 0x36d6
movq %r14, %rdi
movq %r15, %rsi
callq 0x2316
cmpl $0x1, %eax
jne 0x36cd
movq %r14, %rdi
movq %r15, %rsi
callq 0x2320
cmpl $0x1, %eax
jne 0x36c4
incq %rbx
addq $0x8, %r12
jmp 0x3656
leaq 0x548d(%rip), %rdi      # 0x8b38
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2190
leaq 0x529a(%rip), %rdi      # 0x895c
jmp 0x36dd
leaq 0x52e7(%rip), %rdi      # 0x89b2
jmp 0x36dd
leaq 0x52bf(%rip), %rdi      # 0x8993
jmp 0x36dd
leaq 0x5297(%rip), %rdi      # 0x8974
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
callq 0x20c0