// File: /workspace/github_c_makefile_star2_O2/yangtau[P]hedgehog/src/test/string_test.c
// Function: test_strbuf
void test_strbuf() {
    hg_strtable_init();

    struct hg_strbuf buf;

    {
        //  empty string
        hg_strbuf_init(&buf);

        test_assert(buf.len == 0);
        test_assert(!buf._moved);

        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp("", t) == 0);
        test_assert(buf._moved);

        hg_strbuf_free(&buf);
    }

    {
        hg_strbuf_init(&buf);
#define spaces "        "
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);
        hg_strbuf_append(&buf, spaces);

        test_assert(buf.len == 4 * strlen(spaces));
        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp(spaces spaces spaces spaces, t) == 0);

#undef spaces
        hg_strbuf_free(&buf);
    }

    {
        hg_strbuf_init(&buf);
        test_assert(buf.len == 0);

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, world"));

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, worldhello, world"));

        test_assert(hg_strbuf_append(&buf, "hello, %s", "world"));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world"));

        test_assert(hg_strbuf_append(&buf, " a=%d+%d,b=%c", 10, 20, 'c'));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c"));

        test_assert(hg_strbuf_append(&buf, ""));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c"));

        test_assert(hg_strbuf_append(&buf, "  "));
        test_assert(buf.len == strlen("hello, worldhello, worldhello, world a=10+20,b=c  "));

        const char* t = hg_strbuf_to_str(&buf);
        test_assert(strcmp("hello, worldhello, worldhello, world a=10+20,b=c  ", t) == 0);
        test_assert(buf._moved);

        hg_strbuf_free(&buf);
    }

    hg_strtable_free();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
xorl %eax, %eax
callq 0x11cc
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12dc
cmpq $0x0, (%rbx)
jne 0x171e
cmpb $0x1, 0x20(%rsp)
je 0x1753
leaq 0x8(%rsp), %rdi
callq 0x14a0
cmpb $0x0, (%rax)
jne 0x1788
cmpb $0x0, 0x20(%rsp)
je 0x17bd
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12fe
movq %rbx, %rdi
callq 0x12dc
leaq 0xc38(%rip), %r14       # 0x218a
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1331
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1331
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1331
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1331
cmpq $0x20, (%rbx)
jne 0x17f2
leaq 0x8(%rsp), %rdi
callq 0x14a0
leaq 0xbd1(%rip), %rdi       # 0x2172
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1827
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12fe
movq %rbx, %rdi
callq 0x12dc
cmpq $0x0, (%rbx)
jne 0x185c
leaq 0xbe8(%rip), %rsi       # 0x21bf
leaq 0xbeb(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x1891
cmpq $0xc, 0x8(%rsp)
jne 0x18c6
leaq 0xbba(%rip), %rsi       # 0x21bf
leaq 0xbbd(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x18fb
cmpq $0x18, 0x8(%rsp)
jne 0x1930
leaq 0xb8c(%rip), %rsi       # 0x21bf
leaq 0xb8f(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x1965
cmpq $0x24, 0x8(%rsp)
jne 0x199a
leaq 0xc25(%rip), %rsi       # 0x2286
leaq 0x8(%rsp), %rdi
pushq $0xa
popq %rdx
pushq $0x14
popq %rcx
pushq $0x63
popq %r8
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x19cf
cmpq $0x30, 0x8(%rsp)
jne 0x1a04
leaq 0xa7b(%rip), %rsi       # 0x210d
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x1a39
cmpq $0x30, 0x8(%rsp)
jne 0x1a6e
leaq 0xad7(%rip), %rsi       # 0x2190
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1331
testb %al, %al
je 0x1aa3
cmpq $0x32, 0x8(%rsp)
jne 0x1ad8
leaq 0x8(%rsp), %rdi
callq 0x14a0
leaq 0xca5(%rip), %rdi       # 0x238f
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1b0d
cmpb $0x0, 0x20(%rsp)
je 0x1b42
leaq 0x8(%rsp), %rdi
callq 0x12fe
xorl %eax, %eax
callq 0x11f3
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movq 0x28d3(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x9b3(%rip), %rsi       # 0x20e2
leaq 0x9d8(%rip), %rdx       # 0x210e
leaq 0x9df(%rip), %r8        # 0x211c
leaq 0x9e4(%rip), %r9        # 0x2128
pushq $0xf
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x150d
movq 0x289e(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x97e(%rip), %rsi       # 0x20e2
leaq 0x9a3(%rip), %rdx       # 0x210e
leaq 0x9aa(%rip), %r8        # 0x211c
leaq 0x9bc(%rip), %r9        # 0x2135
pushq $0x10
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1518
movq 0x2869(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x949(%rip), %rsi       # 0x20e2
leaq 0x96e(%rip), %rdx       # 0x210e
leaq 0x975(%rip), %r8        # 0x211c
leaq 0x993(%rip), %r9        # 0x2141
pushq $0x13
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x152b
movq 0x2834(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x914(%rip), %rsi       # 0x20e2
leaq 0x939(%rip), %rdx       # 0x210e
leaq 0x940(%rip), %r8        # 0x211c
leaq 0x953(%rip), %r9        # 0x2136
pushq $0x14
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1536
movq 0x27ff(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x8df(%rip), %rsi       # 0x20e2
leaq 0x904(%rip), %rdx       # 0x210e
leaq 0x90b(%rip), %r8        # 0x211c
leaq 0x93c(%rip), %r9        # 0x2154
pushq $0x21
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1590
movq 0x27ca(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x8aa(%rip), %rsi       # 0x20e2
leaq 0x8cf(%rip), %rdx       # 0x210e
leaq 0x8d6(%rip), %r8        # 0x211c
leaq 0x946(%rip), %r9        # 0x2193
pushq $0x23
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x15b1
movq 0x2795(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x875(%rip), %rsi       # 0x20e2
leaq 0x89a(%rip), %rdx       # 0x210e
leaq 0x8a1(%rip), %r8        # 0x211c
leaq 0x8a6(%rip), %r9        # 0x2128
pushq $0x2b
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x15d0
movq 0x2760(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x840(%rip), %rsi       # 0x20e2
leaq 0x865(%rip), %rdx       # 0x210e
leaq 0x86c(%rip), %r8        # 0x211c
leaq 0x918(%rip), %r9        # 0x21cf
pushq $0x2d
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x15f2
movq 0x272b(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x80b(%rip), %rsi       # 0x20e2
leaq 0x830(%rip), %rdx       # 0x210e
leaq 0x837(%rip), %r8        # 0x211c
leaq 0x910(%rip), %r9        # 0x21fc
pushq $0x2e
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x15fe
movq 0x26f6(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x7d6(%rip), %rsi       # 0x20e2
leaq 0x7fb(%rip), %rdx       # 0x210e
leaq 0x802(%rip), %r8        # 0x211c
leaq 0x8ae(%rip), %r9        # 0x21cf
pushq $0x30
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1620
movq 0x26c1(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x7a1(%rip), %rsi       # 0x20e2
leaq 0x7c6(%rip), %rdx       # 0x210e
leaq 0x7cd(%rip), %r8        # 0x211c
leaq 0x8c8(%rip), %r9        # 0x221e
pushq $0x31
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x162c
movq 0x268c(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x76c(%rip), %rsi       # 0x20e2
leaq 0x791(%rip), %rdx       # 0x210e
leaq 0x798(%rip), %r8        # 0x211c
leaq 0x844(%rip), %r9        # 0x21cf
pushq $0x33
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x164e
movq 0x2657(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x737(%rip), %rsi       # 0x20e2
leaq 0x75c(%rip), %rdx       # 0x210e
leaq 0x763(%rip), %r8        # 0x211c
leaq 0x88c(%rip), %r9        # 0x224c
pushq $0x34
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x165a
movq 0x2622(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x702(%rip), %rsi       # 0x20e2
leaq 0x727(%rip), %rdx       # 0x210e
leaq 0x72e(%rip), %r8        # 0x211c
leaq 0x89f(%rip), %r9        # 0x2294
pushq $0x36
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x167f
movq 0x25ed(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x6cd(%rip), %rsi       # 0x20e2
leaq 0x6f2(%rip), %rdx       # 0x210e
leaq 0x6f9(%rip), %r8        # 0x211c
leaq 0x89f(%rip), %r9        # 0x22c9
pushq $0x37
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x168b
movq 0x25b8(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x698(%rip), %rsi       # 0x20e2
leaq 0x6bd(%rip), %rdx       # 0x210e
leaq 0x6c4(%rip), %r8        # 0x211c
leaq 0x8b0(%rip), %r9        # 0x230f
pushq $0x39
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x16a6
movq 0x2583(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x663(%rip), %rsi       # 0x20e2
leaq 0x688(%rip), %rdx       # 0x210e
leaq 0x68f(%rip), %r8        # 0x211c
leaq 0x835(%rip), %r9        # 0x22c9
pushq $0x3a
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x16b2
movq 0x254e(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x62e(%rip), %rsi       # 0x20e2
leaq 0x653(%rip), %rdx       # 0x210e
leaq 0x65a(%rip), %r8        # 0x211c
leaq 0x861(%rip), %r9        # 0x232a
pushq $0x3c
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x16cd
movq 0x2519(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x5f9(%rip), %rsi       # 0x20e2
leaq 0x61e(%rip), %rdx       # 0x210e
leaq 0x625(%rip), %r8        # 0x211c
leaq 0x849(%rip), %r9        # 0x2347
pushq $0x3d
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x16d9
movq 0x24e4(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x5c4(%rip), %rsi       # 0x20e2
leaq 0x5e9(%rip), %rdx       # 0x210e
leaq 0x5f0(%rip), %r8        # 0x211c
leaq 0x88f(%rip), %r9        # 0x23c2
pushq $0x40
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x16fa
movq 0x24af(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x58f(%rip), %rsi       # 0x20e2
leaq 0x5b4(%rip), %rdx       # 0x210e
leaq 0x5bb(%rip), %r8        # 0x211c
leaq 0x5ce(%rip), %r9        # 0x2136
pushq $0x41
popq %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1705