// File: /workspace/github_c_makefile_star2_O1/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 0x163c
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x175c
cmpq $0x0, (%rbx)
jne 0x1be8
cmpb $0x1, 0x20(%rsp)
je 0x1bf2
leaq 0x8(%rsp), %rdi
callq 0x1962
cmpb $0x0, (%rax)
jne 0x1bfc
cmpb $0x0, 0x20(%rsp)
je 0x1c06
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1783
movq %rbx, %rdi
callq 0x175c
leaq 0x774(%rip), %r14       # 0x218a
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b8
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b8
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b8
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17b8
cmpq $0x20, (%rbx)
jne 0x1c10
leaq 0x8(%rsp), %rdi
callq 0x1962
leaq 0x70d(%rip), %rdi       # 0x2172
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1c1a
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1783
movq %rbx, %rdi
callq 0x175c
cmpq $0x0, (%rbx)
jne 0x1c24
leaq 0x724(%rip), %rsi       # 0x21bf
leaq 0x727(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c2e
cmpq $0xc, 0x8(%rsp)
jne 0x1c38
leaq 0x6f6(%rip), %rsi       # 0x21bf
leaq 0x6f9(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c42
cmpq $0x18, 0x8(%rsp)
jne 0x1c4c
leaq 0x6c8(%rip), %rsi       # 0x21bf
leaq 0x6cb(%rip), %rdx       # 0x21c9
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c56
cmpq $0x24, 0x8(%rsp)
jne 0x1c60
leaq 0x761(%rip), %rsi       # 0x2286
leaq 0x8(%rsp), %rdi
movl $0xa, %edx
movl $0x14, %ecx
movl $0x63, %r8d
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c6a
cmpq $0x30, 0x8(%rsp)
jne 0x1c74
leaq 0x5b1(%rip), %rsi       # 0x210d
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c7e
cmpq $0x30, 0x8(%rsp)
jne 0x1c88
leaq 0x60d(%rip), %rsi       # 0x2190
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x17b8
testb %al, %al
je 0x1c92
cmpq $0x32, 0x8(%rsp)
jne 0x1c9c
leaq 0x8(%rsp), %rdi
callq 0x1962
leaq 0x7db(%rip), %rdi       # 0x238f
movq %rax, %rsi
callq 0x1090
testl %eax, %eax
jne 0x1ca6
cmpb $0x0, 0x20(%rsp)
je 0x1cb0
leaq 0x8(%rsp), %rdi
callq 0x1783
xorl %eax, %eax
callq 0x1666
addq $0x28, %rsp
popq %rbx
popq %r14
retq
callq 0x10e0
jmp 0x19d1
callq 0x1116
jmp 0x19dc
callq 0x114c
jmp 0x19ef
callq 0x1182
jmp 0x19fa
callq 0x11b8
jmp 0x1a54
callq 0x11ee
jmp 0x1a75
callq 0x1224
jmp 0x1a94
callq 0x125a
jmp 0x1ab6
callq 0x1290
jmp 0x1ac2
callq 0x12c6
jmp 0x1ae4
callq 0x12fc
jmp 0x1af0
callq 0x1332
jmp 0x1b12
callq 0x1368
jmp 0x1b1e
callq 0x139e
jmp 0x1b49
callq 0x13d4
jmp 0x1b55
callq 0x140a
jmp 0x1b70
callq 0x1440
jmp 0x1b7c
callq 0x1476
jmp 0x1b97
callq 0x14ac
jmp 0x1ba3
callq 0x14e2
jmp 0x1bc4
callq 0x1518
jmp 0x1bcf