// File: ridiculousfish[P]docopt_fish/docopt_fish_test.cpp
// Function: test_command_names()
static void test_command_names()
{
    const struct cmd_testcase_t {
        const char *usage;
        const char *expected_names;
    } testcases[] =
    {   /* Case 0 */
        {   "Usage: prog -foo",
            "prog"
        },
        /* Case 1 */
        {   "Usage: prog (foo|bar) --baz\n"
            "       prog --baz\n"
            "       prog2",
            "prog,prog2"
        },
        /* Case 2 */
        {   "Usage: prog (foo|bar) --baz\n"
            "       prog2"
            "       prog --baz\n",
            "prog,prog2"
        },
        {nullptr, nullptr}
    };
    for (size_t testcase_idx=0; testcases[testcase_idx].usage != nullptr; testcase_idx++) {
        const cmd_testcase_t *testcase = &testcases[testcase_idx];
        string_t doc(to_string(testcase->usage));
        string_t actual_cmds = join(argument_parser_t(doc, nullptr).get_command_names(), ",");
        string_t expected_cmds = to_string(testcase->expected_names);
        if (actual_cmds != expected_cmds) {
            err("Command test %lu.%lu expected '%ls', but instead got '%ls'", testcase_idx, 0LU, wide(expected_cmds), wide(actual_cmds));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
leaq -0x40(%rbp), %rdi
leaq 0x3864a(%rip), %rsi     # 0x77d60
movl $0x40, %edx
callq 0x8270
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rcx
leaq -0x40(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x3f923
movq -0x48(%rbp), %rax
shlq $0x4, %rax
leaq -0x40(%rbp,%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x3af90
movq -0xe8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rdi
callq 0xab40
jmp 0x3f782
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xa820
jmp 0x3f797
leaq 0xd374(%rip), %rdx      # 0x4cb12
leaq -0x90(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3b130
jmp 0x3f7b3
leaq -0xa8(%rbp), %rdi
callq 0x12f80
leaq -0xb0(%rbp), %rdi
callq 0xac20
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3af90
jmp 0x3f7e1
leaq -0x90(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x470e0
testb $0x1, %al
jne 0x3f7fd
jmp 0x3f8da
movq -0x48(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3b6c0
movq %rax, -0xf0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3b6c0
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rcx
movq %rax, %r8
leaq 0x103a9(%rip), %rdi     # 0x4fbe8
xorl %eax, %eax
movl %eax, %edx
callq 0x3b570
jmp 0x3f84a
jmp 0x3f8da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x3f918
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x3f898
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x12f80
leaq -0xb0(%rbp), %rdi
callq 0xac20
jmp 0x3f918
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x3f90c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x8590
jmp 0x3f90c
leaq -0xe0(%rbp), %rdi
callq 0x8590
leaq -0x90(%rbp), %rdi
callq 0x8590
leaq -0x70(%rbp), %rdi
callq 0x8590
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3f728
leaq -0x90(%rbp), %rdi
callq 0x8590
leaq -0x70(%rbp), %rdi
callq 0x8590
jmp 0x3f92c
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xb8(%rbp), %rdi
callq 0x85d0
nopl (%rax,%rax)