// File: /workspace/github_c_makefile_star2_O2/theck01[P]offbrand_lib/src/tests/obstring_test.c
// Function: main
int main (){

  obstring *str1, *str2, *str3, *null_str;
  obvector *tokens;
  const char *contents;

  str1 = obstring_new("Hello, World!");

  /* Test obstring_new and obstring_cstring */
  contents = obstring_cstring(str1);
  assert(strcmp(contents, "Hello, World!") == 0);


  /* Test obstring_copy_substring and obstring_length */
  str2 = obstring_copy_substring(str1, 0, 5);
  contents = obstring_cstring(str2);
  assert(strcmp(contents, "Hello") == 0);

  ob_release((obj *)str2);

  str2 = obstring_copy_substring(str1, -15, 7);
  contents = obstring_cstring(str2);
  assert(strcmp(contents, "Hello") == 0);

  ob_release((obj *)str2);

  str2 = obstring_copy_substring(str1, 0, obstring_length(str1));
  contents = obstring_cstring(str2);
  assert(strcmp(contents, "Hello, World!") == 0);

  ob_release((obj *)str2);

  null_str = obstring_copy_substring(str1, 20, 2);
  assert(obstring_length(null_str) == 0);

  /* Test obstring_char_at_index */
  assert(obstring_char_at_index(str1, 0) == 'H');
  assert(obstring_char_at_index(str1, -5) == 'o');
  assert(obstring_char_at_index(str1, -20) == '\0');
  assert(obstring_char_at_index(str1, 20) == '\0');
  assert(obstring_char_at_index(null_str, 0) == '\0');

  /* Test String Concatenation */
  str2 = obstring_new(" And hello again!");
  str3 = obstring_concat(str1, str2);
  contents = obstring_cstring(str3);
  assert(strcmp(contents, "Hello, World! And hello again!") == 0);

  ob_release((obj *)str2);

  str2 = obstring_concat(null_str, str1);
  contents = obstring_cstring(str2);
  assert(strcmp(contents, "Hello, World!") == 0);

  /* Test String Comparision */
  assert(ob_compare((obj *)str1, (obj *)str2) == OB_EQUAL_TO);
  assert(ob_compare((obj *)str1, (obj *)str3) == OB_LESS_THAN);
  assert(ob_compare((obj *)str1, (obj *)null_str) == OB_GREATER_THAN);

  ob_release((obj *)str2);
  ob_release((obj *)str3);

  /* Test String Splits */
  str2 = obstring_new("Testing string split   into#!many");
  tokens = obstring_split(str2, " ");
  assert(strcmp(obstring_cstring((obstring *)obvector_obj_at_index(tokens, 0)), "Testing")
         == 0);
  assert(strcmp(obstring_cstring((obstring *)obvector_obj_at_index(tokens, 3)),
                           "into#!many") == 0);

  ob_release((obj *)tokens);

  tokens = obstring_split(str2, "#!");
  assert(strcmp(obstring_cstring((obstring *)obvector_obj_at_index(tokens, 0)),
                           "Testing string split   into") == 0);
  assert(strcmp(obstring_cstring((obstring *)obvector_obj_at_index(tokens, 1)), "many")
         == 0);

  ob_release((obj *)tokens);

  /* Test String Search */

  assert(obstring_find_substring(str2, "Testing") != 0);
  assert(obstring_find_substring(str2, "#!many") != 0);
  assert(obstring_find_substring(str2, "Hello World") == 0);

  /* Test Regex Match */
  str3 = obstring_match_regex(str1, "[Hh]el{1,2}.");
  assert(strcmp(obstring_cstring(str3), "Hello") == 0);
  ob_release((obj *)str3);

  str3 = obstring_match_regex(str2, " *into[#!]{2,2}.*$");
  assert(strcmp(obstring_cstring(str3), "   into#!many") == 0);

  ob_release((obj *)str3);
  ob_release((obj *)str2);
  ob_release((obj *)str1);
  ob_release((obj *)null_str);

  /* TESTS COMPLETE */
  printf("obstring: TESTS PASSED\n");

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x1d89(%rip), %r14      # 0x3004
movq %r14, %rdi
callq 0x18ec
movq %rax, %rbx
movq %rax, %rdi
callq 0x1c1d
movq %rax, %rdi
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
jne 0x1658
pushq $0x5
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1a04
movq %rax, %r14
movq %rax, %rdi
callq 0x1c1d
leaq 0x1d9e(%rip), %rsi      # 0x305e
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1674
movq %r14, %rdi
callq 0x2e82
pushq $-0xf
popq %rsi
pushq $0x7
popq %rdx
movq %rbx, %rdi
callq 0x1a04
movq %rax, %r14
movq %rax, %rdi
callq 0x1c1d
leaq 0x1d66(%rip), %rsi      # 0x305e
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1690
movq %r14, %rdi
callq 0x2e82
movq %rbx, %rdi
callq 0x1aea
movq %rbx, %rdi
xorl %esi, %esi
movl %eax, %edx
callq 0x1a04
movq %rax, %r14
movq %rax, %rdi
callq 0x1c1d
leaq 0x1cce(%rip), %rsi      # 0x3004
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x16ac
movq %r14, %rdi
callq 0x2e82
pushq $0x14
popq %rsi
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x1a04
movq %rax, %r14
movq %rax, %rdi
callq 0x1aea
testl %eax, %eax
jne 0x16c8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1b11
cmpb $0x48, %al
jne 0x16e4
pushq $-0x5
popq %rsi
movq %rbx, %rdi
callq 0x1b11
cmpb $0x6f, %al
jne 0x1700
pushq $-0x14
popq %rsi
movq %rbx, %rdi
callq 0x1b11
testb %al, %al
jne 0x171c
pushq $0x14
popq %rsi
movq %rbx, %rdi
callq 0x1b11
testb %al, %al
jne 0x1738
movq %r14, %rdi
xorl %esi, %esi
callq 0x1b11
testb %al, %al
jne 0x1754
leaq 0x1daa(%rip), %rdi      # 0x317d
callq 0x18ec
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1b53
movq %rax, %r15
movq %rax, %rdi
callq 0x1c1d
leaq 0x1d78(%rip), %rsi      # 0x3170
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1770
movq %r12, %rdi
callq 0x2e82
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1b53
movq %rax, %r12
movq %rax, %rdi
callq 0x1c1d
leaq 0x1bd7(%rip), %rsi      # 0x3004
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x178c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2dcb
testb %al, %al
jne 0x17a8
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2dcb
cmpb $-0x1, %al
jne 0x17c4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dcb
cmpb $0x1, %al
jne 0x17e0
movq %r12, %rdi
callq 0x2e82
movq %r15, %rdi
callq 0x2e82
leaq 0x1ddf(%rip), %rdi      # 0x326c
callq 0x18ec
movq %rax, %r15
leaq 0x1df2(%rip), %rsi      # 0x328e
movq %rax, %rdi
callq 0x1c45
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
callq 0x2522
movq %rax, %rdi
callq 0x1c1d
leaq 0x1dd0(%rip), %rsi      # 0x3290
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x17fc
pushq $0x3
popq %rsi
movq %r12, %rdi
callq 0x2522
movq %rax, %rdi
callq 0x1c1d
leaq 0x1d99(%rip), %rsi      # 0x3283
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1818
movq %r12, %rdi
callq 0x2e82
leaq 0x1e40(%rip), %rsi      # 0x3349
movq %r15, %rdi
callq 0x1c45
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
callq 0x2522
movq %rax, %rdi
callq 0x1c1d
leaq 0x1e1f(%rip), %rsi      # 0x334c
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1834
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x2522
movq %rax, %rdi
callq 0x1c1d
leaq 0x1d32(%rip), %rsi      # 0x3289
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x1850
movq %r12, %rdi
callq 0x2e82
leaq 0x1d1a(%rip), %rsi      # 0x3290
movq %r15, %rdi
callq 0x1d9c
testb %al, %al
je 0x1869
leaq 0x1cfa(%rip), %rsi      # 0x3287
movq %r15, %rdi
callq 0x1d9c
testb %al, %al
je 0x1882
leaq 0x1ede(%rip), %rsi      # 0x3482
movq %r15, %rdi
callq 0x1d9c
testb %al, %al
jne 0x189b
leaq 0x1f05(%rip), %rsi      # 0x34c0
movq %rbx, %rdi
callq 0x1e39
movq %rax, %r12
movq %rax, %rdi
callq 0x1c1d
leaq 0x1a89(%rip), %rsi      # 0x305e
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x18b4
movq %r12, %rdi
callq 0x2e82
leaq 0x1f06(%rip), %rsi      # 0x34fa
movq %r15, %rdi
callq 0x1e39
movq %rax, %r12
movq %rax, %rdi
callq 0x1c1d
leaq 0x1c72(%rip), %rsi      # 0x3280
movq %rax, %rdi
callq 0x10e0
testl %eax, %eax
jne 0x18cd
movq %r12, %rdi
callq 0x2e82
movq %r15, %rdi
callq 0x2e82
movq %rbx, %rdi
callq 0x2e82
movq %r14, %rdi
callq 0x2e82
leaq 0x1efd(%rip), %rdi      # 0x3542
callq 0x1070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x19b3(%rip), %rdi      # 0x3012
leaq 0x19d3(%rip), %rsi      # 0x3039
leaq 0x19e6(%rip), %rcx      # 0x3053
pushq $0x17
jmp 0x18e4
leaq 0x19e9(%rip), %rdi      # 0x3064
leaq 0x19b7(%rip), %rsi      # 0x3039
leaq 0x19ca(%rip), %rcx      # 0x3053
pushq $0x1d
jmp 0x18e4
leaq 0x19cd(%rip), %rdi      # 0x3064
leaq 0x199b(%rip), %rsi      # 0x3039
leaq 0x19ae(%rip), %rcx      # 0x3053
pushq $0x23
jmp 0x18e4
leaq 0x195f(%rip), %rdi      # 0x3012
leaq 0x197f(%rip), %rsi      # 0x3039
leaq 0x1992(%rip), %rcx      # 0x3053
pushq $0x29
jmp 0x18e4
leaq 0x19b4(%rip), %rdi      # 0x3083
leaq 0x1963(%rip), %rsi      # 0x3039
leaq 0x1976(%rip), %rcx      # 0x3053
pushq $0x2e
jmp 0x18e4
leaq 0x19b7(%rip), %rdi      # 0x30a2
leaq 0x1947(%rip), %rsi      # 0x3039
leaq 0x195a(%rip), %rcx      # 0x3053
pushq $0x31
jmp 0x18e4
leaq 0x19c2(%rip), %rdi      # 0x30c9
leaq 0x192b(%rip), %rsi      # 0x3039
leaq 0x193e(%rip), %rcx      # 0x3053
pushq $0x32
jmp 0x18e4
leaq 0x19ce(%rip), %rdi      # 0x30f1
leaq 0x190f(%rip), %rsi      # 0x3039
leaq 0x1922(%rip), %rcx      # 0x3053
pushq $0x33
jmp 0x18e4
leaq 0x19dc(%rip), %rdi      # 0x311b
leaq 0x18f3(%rip), %rsi      # 0x3039
leaq 0x1906(%rip), %rcx      # 0x3053
pushq $0x34
jmp 0x18e4
leaq 0x19e9(%rip), %rdi      # 0x3144
leaq 0x18d7(%rip), %rsi      # 0x3039
leaq 0x18ea(%rip), %rcx      # 0x3053
pushq $0x35
jmp 0x18e4
leaq 0x1a18(%rip), %rdi      # 0x318f
leaq 0x18bb(%rip), %rsi      # 0x3039
leaq 0x18ce(%rip), %rcx      # 0x3053
pushq $0x3b
jmp 0x18e4
leaq 0x187f(%rip), %rdi      # 0x3012
leaq 0x189f(%rip), %rsi      # 0x3039
leaq 0x18b2(%rip), %rcx      # 0x3053
pushq $0x41
jmp 0x18e4
leaq 0x1a18(%rip), %rdi      # 0x31c7
leaq 0x1883(%rip), %rsi      # 0x3039
leaq 0x1896(%rip), %rcx      # 0x3053
pushq $0x44
jmp 0x18e4
leaq 0x1a30(%rip), %rdi      # 0x31fb
leaq 0x1867(%rip), %rsi      # 0x3039
leaq 0x187a(%rip), %rcx      # 0x3053
pushq $0x45
jmp 0x18e4
leaq 0x1a49(%rip), %rdi      # 0x3230
leaq 0x184b(%rip), %rsi      # 0x3039
leaq 0x185e(%rip), %rcx      # 0x3053
pushq $0x46
jmp 0x18e4
leaq 0x1a95(%rip), %rdi      # 0x3298
leaq 0x182f(%rip), %rsi      # 0x3039
leaq 0x1842(%rip), %rcx      # 0x3053
pushq $0x4f
jmp 0x18e4
leaq 0x1ad0(%rip), %rdi      # 0x32ef
leaq 0x1813(%rip), %rsi      # 0x3039
leaq 0x1826(%rip), %rcx      # 0x3053
pushq $0x51
jmp 0x18e4
leaq 0x1b2d(%rip), %rdi      # 0x3368
leaq 0x17f7(%rip), %rsi      # 0x3039
leaq 0x180a(%rip), %rcx      # 0x3053
pushq $0x57
jmp 0x18e4
leaq 0x1b7c(%rip), %rdi      # 0x33d3
leaq 0x17db(%rip), %rsi      # 0x3039
leaq 0x17ee(%rip), %rcx      # 0x3053
pushq $0x59
jmp 0x18e4
leaq 0x1bb7(%rip), %rdi      # 0x3427
leaq 0x17c2(%rip), %rsi      # 0x3039
leaq 0x17d5(%rip), %rcx      # 0x3053
pushq $0x5f
jmp 0x18e4
leaq 0x1bcc(%rip), %rdi      # 0x3455
leaq 0x17a9(%rip), %rsi      # 0x3039
leaq 0x17bc(%rip), %rcx      # 0x3053
pushq $0x60
jmp 0x18e4
leaq 0x1bec(%rip), %rdi      # 0x348e
leaq 0x1790(%rip), %rsi      # 0x3039
leaq 0x17a3(%rip), %rcx      # 0x3053
pushq $0x61
jmp 0x18e4
leaq 0x1c12(%rip), %rdi      # 0x34cd
leaq 0x1777(%rip), %rsi      # 0x3039
leaq 0x178a(%rip), %rcx      # 0x3053
pushq $0x65
jmp 0x18e4
leaq 0x1c39(%rip), %rdi      # 0x350d
leaq 0x175e(%rip), %rsi      # 0x3039
leaq 0x1771(%rip), %rcx      # 0x3053
pushq $0x69
popq %rdx
callq 0x10a0
nop