// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]tundra/unittest/test_PathUtil.cpp
// Function: PathUtil_Init_Test::TestBody()
TEST(PathUtil, Init)
{
  static const struct
  {
    PathType::Enum  type;
    const char     *input;
    const char     *expected_output;
    bool            expect_absolute;
    int             expect_segs;
    int             expect_seg_lens[8];
  }
  test_data[] =
  {
    { PathType::kUnix, "",                "",                     false,  0, {} },
    { PathType::kUnix, "/",               "/",                    true,   0, {} },
    { PathType::kUnix, "////",            "/",                    true,   0, {} },
    { PathType::kUnix, "foo.c",           "foo.c",                false,  1, { 5 } },
    { PathType::kUnix, "/foo.c",          "/foo.c",               true,   1, { 5 } },
    { PathType::kUnix, "foo/bar.c",       "foo/bar.c",            false,  2, { 3, 5 } },
    { PathType::kUnix, "/foo/bar.c",      "/foo/bar.c",           true,   2, { 3, 5 } },
    { PathType::kUnix, "/foo///bar.c",    "/foo/bar.c",           true,   2, { 3, 5 } },
    { PathType::kUnix, "/foo///bar.c/",   "/foo/bar.c",           true,   2, { 3, 5 } },
    { PathType::kUnix, "/foo/./bar.c/",   "/foo/bar.c",           true,   2, { 3, 5 } },
    { PathType::kUnix, "/foo/../bar.c/",  "/bar.c",               true,   1, { 5 } },
    { PathType::kUnix, "foo/../../bar.c", "../bar.c",             false,  1, { 5 } },
    { PathType::kUnix, "../../../bar.c",  "../../../bar.c",       false,  1, { 5 } },
    { PathType::kUnix, "./././bar.c",     "bar.c",                false,  1, { 5 } },
    { PathType::kUnix, ".",               "",                     false,  0, {}},
    { PathType::kUnix, "././.",           "",                     false,  0, {}},

    { PathType::kWindows, "",                "",                     false,  0, {} },
    { PathType::kWindows, "\\",              "\\",                   true,   0, {} },
    { PathType::kWindows, "////",            "\\",                   true,   0, {} },
    { PathType::kWindows, "foo.c",           "foo.c",                false,  1, { 5 } },
    { PathType::kWindows, "/foo.c",          "\\foo.c",              true,   1, { 5 } },
    { PathType::kWindows, "foo/bar.c",       "foo\\bar.c",           false,  2, { 3, 5 } },
    { PathType::kWindows, "/foo/bar.c",      "\\foo\\bar.c",         true,   2, { 3, 5 } },
    { PathType::kWindows, "/foo///bar.c",    "\\foo\\bar.c",         true,   2, { 3, 5 } },
    { PathType::kWindows, "/foo///bar.c/",   "\\foo\\bar.c",         true,   2, { 3, 5 } },
    { PathType::kWindows, "/foo/./bar.c/",   "\\foo\\bar.c",         true,   2, { 3, 5 } },
    { PathType::kWindows, "/foo/../bar.c/",  "\\bar.c",              true,   1, { 5 } },
    { PathType::kWindows, "foo/../../bar.c", "..\\bar.c",            false,  1, { 5 } },
    { PathType::kWindows, "../../../bar.c",  "..\\..\\..\\bar.c",    false,  1, { 5 } },
    { PathType::kWindows, "./././bar.c",     "bar.c",                false,  1, { 5 } },
    { PathType::kWindows, ".",               "",                     false,  0, { } },
    { PathType::kWindows, "././.",           "",                     false,  0, { } },
    { PathType::kWindows, "x:\\foo",         "x:\\foo",              true,   2, { 2, 3 } },
    { PathType::kWindows, "x:/foo",          "x:\\foo",              true,   2, { 2, 3 } },
  };

  for (size_t i = 0; i < ARRAY_SIZE(test_data); ++i)
  {
    PathBuffer path;
    PathInit(&path, test_data[i].input, test_data[i].type);
    ASSERT_EQ(test_data[i].expect_absolute, PathIsAbsolute(&path));
    ASSERT_EQ(test_data[i].expect_segs, path.m_SegCount);

    for (int s = 0; s < path.m_SegCount; ++s)
    {
      ASSERT_EQ(test_data[i].expect_seg_lens[s], path.SegLength(s));
    }

    char buffer[kMaxPathLength];
    PathFormat(buffer, &path);
    ASSERT_STREQ(test_data[i].expected_output, buffer);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
leaq 0x33470(%rip), %rax     # 0x71d60
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0x33441(%rip), %rax     # 0x71d40
leaq 0x23c(%rsp), %rdi
leaq 0x1886d(%rip), %r13     # 0x5717b
leaq 0x30(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, 0x28(%rsp)
shlq $0x6, %r12
leaq (%r12,%rax), %rbp
addq $0x18, %rbp
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0x42eb0
movb 0x240(%rsp), %al
andb $0x1, %al
movb %al, 0x8(%rsp)
movq %r14, %rbx
movq %r14, %rdi
movq %r13, %rsi
leaq 0x18846(%rip), %rdx     # 0x57198
movq %rbp, %rcx
movq %r15, %r8
callq 0x3670e
cmpb $0x0, 0x30(%rsp)
je 0x3eb57
movq %r15, %r13
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
leaq 0x333c2(%rip), %rax     # 0x71d40
addq %rax, %r12
leaq 0x1c(%r12), %rcx
movq %rbx, %rdi
leaq 0x1881e(%rip), %rsi     # 0x571ae
leaq 0x18830(%rip), %rdx     # 0x571c7
leaq 0x242(%rsp), %r8
callq 0x3efea
cmpb $0x0, 0x30(%rsp)
je 0x3eb70
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
cmpw $0x0, 0x242(%rsp)
je 0x3ea3b
movq 0x20(%rsp), %rbp
xorl %r15d, %r15d
testq %r15, %r15
je 0x3e9e7
movzwl 0x246(%rsp,%r15,2), %eax
subw 0x244(%rsp,%r15,2), %ax
jmp 0x3e9ef
movzwl 0x246(%rsp), %eax
movw %ax, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x187d9(%rip), %rsi     # 0x571d7
leaq 0x187f2(%rip), %rdx     # 0x571f7
movq %rbp, %rcx
movq %r13, %r8
callq 0x3efea
cmpb $0x0, 0x30(%rsp)
je 0x3eabc
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
incq %r15
movzwl 0x242(%rsp), %eax
addq $0x4, %rbp
cmpq %rax, %r15
jb 0x3e9ce
movq %rbx, %rdi
leaq 0x23c(%rsp), %rsi
callq 0x4322e
movq 0x10(%r12), %rcx
movq %r13, %rdi
leaq 0x187af(%rip), %rsi     # 0x57209
leaq 0x19fe0(%rip), %rdx     # 0x58a41
movq %rbx, %r8
callq 0x150d6
cmpb $0x0, 0x8(%rsp)
je 0x3eb90
movq %r13, %rbp
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
movq 0x28(%rsp), %r12
incq %r12
addq $0x40, 0x20(%rsp)
cmpq $0x22, %r12
leaq 0x332a4(%rip), %rax     # 0x71d40
leaq 0x186d8(%rip), %r13     # 0x5717b
movq %rbp, %r15
movq %rbx, %r14
leaq 0x23c(%rsp), %rdi
jne 0x3e918
jmp 0x3eb45
leaq 0x8(%rsp), %rdi
callq 0x12eee
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3ead5
movq (%rax), %r8
jmp 0x3eadc
leaq 0x1a377(%rip), %r8      # 0x58e53
leaq 0x185d5(%rip), %rdx     # 0x570b8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x41, %ecx
callq 0x10bb8
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c56
movq %rsp, %rdi
callq 0x10c24
cmpq $0x0, 0x8(%rsp)
je 0x3eb39
movl $0x1, %edi
callq 0x10bb4
testb %al, %al
je 0x3eb30
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3eb30
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %rdi
callq 0x12eee
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3ebae
movq (%rax), %r8
jmp 0x3ebb5
leaq 0x8(%rsp), %rdi
callq 0x12eee
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3ec23
movq (%rax), %r8
jmp 0x3ec2a
movq %rsp, %rdi
callq 0x12eee
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x3ec98
movq (%rax), %r8
jmp 0x3ec9f
leaq 0x1a29e(%rip), %r8      # 0x58e53
leaq 0x184fc(%rip), %rdx     # 0x570b8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x3c, %ecx
callq 0x10bb8
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c56
movq %rsp, %rdi
callq 0x10c24
cmpq $0x0, 0x8(%rsp)
je 0x3ec12
movl $0x1, %edi
callq 0x10bb4
testb %al, %al
je 0x3ec09
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3ec09
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
jmp 0x3eb45
leaq 0x1a229(%rip), %r8      # 0x58e53
leaq 0x18487(%rip), %rdx     # 0x570b8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x3d, %ecx
callq 0x10bb8
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c56
movq %rsp, %rdi
callq 0x10c24
cmpq $0x0, 0x8(%rsp)
je 0x3ec87
movl $0x1, %edi
callq 0x10bb4
testb %al, %al
je 0x3ec7e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3ec7e
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
jmp 0x3eb45
leaq 0x1a1b4(%rip), %r8      # 0x58e53
leaq 0x18412(%rip), %rdx     # 0x570b8
leaq 0x18(%rsp), %rdi
movl $0x2, %esi
movl $0x46, %ecx
callq 0x10bb8
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x10c56
leaq 0x18(%rsp), %rdi
callq 0x10c24
cmpq $0x0, (%rsp)
je 0x3ecfd
movl $0x1, %edi
callq 0x10bb4
testb %al, %al
je 0x3ecf5
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3ecf5
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, (%rsp)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2c81c
jmp 0x3eb45
jmp 0x3ed87
jmp 0x3ed87
jmp 0x3ed87
jmp 0x3ed87
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x10c24
jmp 0x3ed28
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31faa
jmp 0x3ed35
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x3ed74
jmp 0x3ed87
jmp 0x3ed50
jmp 0x3ed5d
jmp 0x3ed6c
jmp 0x3ed87
jmp 0x3ed50
jmp 0x3ed5d
jmp 0x3ed6c
jmp 0x3ed87
jmp 0x3ed87
movq %rax, %rbx
movq %rsp, %rdi
callq 0x10c24
jmp 0x3ed60
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x31faa
jmp 0x3ed6f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x31fbc
movq %rbx, %rdi
callq 0xcbb0
jmp 0x3ed87
jmp 0x3ed87
jmp 0x3ed87
movq %rax, %rdi
callq 0x28baf
nop