// File: /workspace/github_c_makefile_star2_O3/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 0x32f8c(%rip), %rax     # 0x70d60
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
leaq 0x32f5d(%rip), %rax     # 0x70d40
leaq 0x23c(%rsp), %rdi
leaq 0x183b9(%rip), %r12     # 0x561ab
leaq 0x30(%rsp), %r13
leaq 0x8(%rsp), %r14
movq %r15, 0x28(%rsp)
shlq $0x6, %r15
leaq (%r15,%rax), %rbp
addq $0x18, %rbp
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0x41ff4
movb 0x240(%rsp), %al
andb $0x1, %al
movb %al, 0x8(%rsp)
movq %r13, %rbx
movq %r13, %rdi
movq %r12, %rsi
leaq 0x18392(%rip), %rdx     # 0x561c8
movq %rbp, %rcx
movq %r14, %r8
callq 0x35f40
cmpb $0x0, 0x30(%rsp)
je 0x3e030
movq %r14, %r12
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
leaq 0x32ede(%rip), %rax     # 0x70d40
addq %rax, %r15
leaq 0x1c(%r15), %rcx
movq %rbx, %rdi
leaq 0x1836b(%rip), %rsi     # 0x561de
leaq 0x1837d(%rip), %rdx     # 0x561f7
leaq 0x242(%rsp), %r8
callq 0x3e4a0
cmpb $0x0, 0x30(%rsp)
je 0x3e049
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
cmpw $0x0, 0x242(%rsp)
je 0x3df1e
movq 0x20(%rsp), %rbp
xorl %r14d, %r14d
testq %r14, %r14
je 0x3deca
movzwl 0x246(%rsp,%r14,2), %eax
subw 0x244(%rsp,%r14,2), %ax
jmp 0x3ded2
movzwl 0x246(%rsp), %eax
movw %ax, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x18326(%rip), %rsi     # 0x56207
leaq 0x1833f(%rip), %rdx     # 0x56227
movq %rbp, %rcx
movq %r12, %r8
callq 0x3e4a0
cmpb $0x0, 0x30(%rsp)
je 0x3df9e
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
incq %r14
movzwl 0x242(%rsp), %eax
addq $0x4, %rbp
cmpq %rax, %r14
jb 0x3deb1
movq %rbx, %rdi
leaq 0x23c(%rsp), %rsi
callq 0x42376
movq 0x10(%r15), %rcx
movq %r12, %rdi
leaq 0x182fd(%rip), %rsi     # 0x56239
leaq 0x19b72(%rip), %rdx     # 0x57ab5
movq %rbx, %r8
callq 0x14ffa
cmpb $0x0, 0x8(%rsp)
je 0x3e069
movq %r12, %rbp
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
movq 0x28(%rsp), %r15
incq %r15
addq $0x40, 0x20(%rsp)
cmpq $0x22, %r15
leaq 0x32dc2(%rip), %rax     # 0x70d40
leaq 0x18226(%rip), %r12     # 0x561ab
movq %rbp, %r14
movq %rbx, %r13
leaq 0x23c(%rsp), %rdi
jne 0x3ddfc
jmp 0x3e01e
leaq 0x8(%rsp), %rdi
callq 0x12e46
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3dfb7
movq (%rax), %r8
jmp 0x3dfbe
leaq 0x19f09(%rip), %r8      # 0x57ec7
leaq 0x18123(%rip), %rdx     # 0x560e8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x41, %ecx
callq 0x10b64
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c00
movq %rsp, %rdi
callq 0x10bd0
cmpq $0x0, 0x8(%rsp)
je 0x3e012
movl $0x1, %edi
callq 0x10b61
testb %al, %al
je 0x3e012
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3e012
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %rdi
callq 0x12e46
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3e087
movq (%rax), %r8
jmp 0x3e08e
leaq 0x8(%rsp), %rdi
callq 0x12e46
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x3e0f3
movq (%rax), %r8
jmp 0x3e0fa
movq %rsp, %rdi
callq 0x12e46
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x3e15f
movq (%rax), %r8
jmp 0x3e166
leaq 0x19e39(%rip), %r8      # 0x57ec7
leaq 0x18053(%rip), %rdx     # 0x560e8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x3c, %ecx
callq 0x10b64
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c00
movq %rsp, %rdi
callq 0x10bd0
cmpq $0x0, 0x8(%rsp)
je 0x3e0e2
movl $0x1, %edi
callq 0x10b61
testb %al, %al
je 0x3e0e2
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3e0e2
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
jmp 0x3e01e
leaq 0x19dcd(%rip), %r8      # 0x57ec7
leaq 0x17fe7(%rip), %rdx     # 0x560e8
movq %rsp, %rdi
movl $0x2, %esi
movl $0x3d, %ecx
callq 0x10b64
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10c00
movq %rsp, %rdi
callq 0x10bd0
cmpq $0x0, 0x8(%rsp)
je 0x3e14e
movl $0x1, %edi
callq 0x10b61
testb %al, %al
je 0x3e14e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3e14e
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
jmp 0x3e01e
leaq 0x19d61(%rip), %r8      # 0x57ec7
leaq 0x17f7b(%rip), %rdx     # 0x560e8
leaq 0x18(%rsp), %rdi
movl $0x2, %esi
movl $0x46, %ecx
callq 0x10b64
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x10c00
leaq 0x18(%rsp), %rdi
callq 0x10bd0
cmpq $0x0, (%rsp)
je 0x3e1bc
movl $0x1, %edi
callq 0x10b61
testb %al, %al
je 0x3e1bc
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3e1bc
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2c37a
jmp 0x3e01e
jmp 0x3e246
jmp 0x3e246
jmp 0x3e246
jmp 0x3e246
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x10bd0
jmp 0x3e1e7
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31a70
jmp 0x3e1f4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x3e233
jmp 0x3e246
jmp 0x3e20f
jmp 0x3e21c
jmp 0x3e22b
jmp 0x3e246
jmp 0x3e20f
jmp 0x3e21c
jmp 0x3e22b
jmp 0x3e246
jmp 0x3e246
movq %rax, %rbx
movq %rsp, %rdi
callq 0x10bd0
jmp 0x3e21f
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x31a70
jmp 0x3e22e
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x31a82
movq %rbx, %rdi
callq 0xcbb0
jmp 0x3e246
jmp 0x3e246
jmp 0x3e246
movq %rax, %rdi
callq 0x287ef