// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x5e0, %rsp            # imm = 0x5E0
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
cmpq $0x22, -0x10(%rbp)
jae 0x66f6a
movq -0x10(%rbp), %rax
shlq $0x6, %rax
leaq 0x593ef(%rip), %rcx     # 0xbfcc0
movq %rcx, -0x578(%rbp)
movq 0x8(%rax,%rcx), %rsi
movl (%rax,%rcx), %edx
leaq -0x29c(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x6e7a0
movq -0x578(%rbp), %rcx
movq -0x570(%rbp), %rdi
movq -0x10(%rbp), %rax
shlq $0x6, %rax
leaq 0x18(%rax,%rcx), %rax
movq %rax, -0x568(%rbp)
callq 0x67200
movq -0x568(%rbp), %rcx
movb %al, -0x2b1(%rbp)
leaq 0x27e0d(%rip), %rsi     # 0x8e73b
leaq 0x27e23(%rip), %rdx     # 0x8e758
leaq -0x2b0(%rbp), %rdi
movq %rdi, -0x560(%rbp)
leaq -0x2b1(%rbp), %r8
callq 0x566e0
movq -0x560(%rbp), %rdi
callq 0x31090
movb %al, -0x551(%rbp)
jmp 0x66963
movb -0x551(%rbp), %al
testb $0x1, %al
jne 0x6696f
jmp 0x6698b
jmp 0x66a50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66ad8
leaq -0x2d0(%rbp), %rdi
callq 0x16d70
jmp 0x66999
leaq -0x2b0(%rbp), %rdi
callq 0x310b0
movq %rax, -0x580(%rbp)
jmp 0x669ae
movq -0x580(%rbp), %r8
leaq 0x27cbc(%rip), %rdx     # 0x8e678
leaq -0x2d8(%rbp), %rdi
movl $0x2, %esi
movl $0x3c, %ecx
callq 0x13fa0
jmp 0x669d4
leaq -0x2d8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x14060
jmp 0x669e9
leaq -0x2d8(%rbp), %rdi
callq 0x14020
leaq -0x2d0(%rbp), %rdi
callq 0x31070
movl $0x1, -0x2dc(%rbp)
jmp 0x66a5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66a3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x14020
leaq -0x2d0(%rbp), %rdi
callq 0x31070
jmp 0x66ad8
movl $0x0, -0x2dc(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x30d20
movl -0x2dc(%rbp), %eax
testl %eax, %eax
je 0x66a77
jmp 0x66a72
jmp 0x66f6a
movq -0x10(%rbp), %rax
shlq $0x6, %rax
leaq 0x5923a(%rip), %rcx     # 0xbfcc0
leaq 0x1c(%rax,%rcx), %rcx
leaq -0x296(%rbp), %r8
leaq 0x27cd5(%rip), %rsi     # 0x8e76e
leaq 0x27ce7(%rip), %rdx     # 0x8e787
leaq -0x2f0(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0x67220
movq -0x590(%rbp), %rdi
callq 0x31090
movb %al, -0x581(%rbp)
jmp 0x66ac7
movb -0x581(%rbp), %al
testb $0x1, %al
jne 0x66ad3
jmp 0x66b00
jmp 0x66bc5
leaq -0x2b0(%rbp), %rdi
callq 0x30d20
jmp 0x66f73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66c99
leaq -0x2f8(%rbp), %rdi
callq 0x16d70
jmp 0x66b0e
leaq -0x2f0(%rbp), %rdi
callq 0x310b0
movq %rax, -0x598(%rbp)
jmp 0x66b23
movq -0x598(%rbp), %r8
leaq 0x27b47(%rip), %rdx     # 0x8e678
leaq -0x300(%rbp), %rdi
movl $0x2, %esi
movl $0x3d, %ecx
callq 0x13fa0
jmp 0x66b49
leaq -0x300(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x14060
jmp 0x66b5e
leaq -0x300(%rbp), %rdi
callq 0x14020
leaq -0x2f8(%rbp), %rdi
callq 0x31070
movl $0x1, -0x2dc(%rbp)
jmp 0x66bcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66bb4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x14020
leaq -0x2f8(%rbp), %rdi
callq 0x31070
jmp 0x66c99
movl $0x0, -0x2dc(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x30d20
movl -0x2dc(%rbp), %eax
testl %eax, %eax
je 0x66bec
jmp 0x66be7
jmp 0x66f6a
movl $0x0, -0x304(%rbp)
movl -0x304(%rbp), %eax
movzwl -0x296(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66dd1
movq -0x10(%rbp), %rcx
shlq $0x6, %rcx
leaq 0x590a6(%rip), %rax     # 0xbfcc0
addq %rcx, %rax
movslq -0x304(%rbp), %rcx
movl %ecx, %esi
leaq 0x20(%rax,%rcx,4), %rax
movq %rax, -0x5b0(%rbp)
leaq -0x29c(%rbp), %rdi
callq 0x67270
movq -0x5b0(%rbp), %rcx
movw %ax, -0x31a(%rbp)
leaq 0x27b44(%rip), %rsi     # 0x8e797
leaq 0x27b5d(%rip), %rdx     # 0x8e7b7
leaq -0x318(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
leaq -0x31a(%rbp), %r8
callq 0x67220
movq -0x5a8(%rbp), %rdi
callq 0x31090
movb %al, -0x599(%rbp)
jmp 0x66c88
movb -0x599(%rbp), %al
testb $0x1, %al
jne 0x66c94
jmp 0x66cc1
jmp 0x66d83
leaq -0x2f0(%rbp), %rdi
callq 0x30d20
jmp 0x66f73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66dc0
leaq -0x328(%rbp), %rdi
callq 0x16d70
jmp 0x66ccf
leaq -0x318(%rbp), %rdi
callq 0x310b0
movq %rax, -0x5b8(%rbp)
jmp 0x66ce4
movq -0x5b8(%rbp), %r8
leaq 0x27986(%rip), %rdx     # 0x8e678
leaq -0x330(%rbp), %rdi
movl $0x2, %esi
movl $0x41, %ecx
callq 0x13fa0
jmp 0x66d0a
leaq -0x330(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x14060
jmp 0x66d1f
leaq -0x330(%rbp), %rdi
callq 0x14020
leaq -0x328(%rbp), %rdi
callq 0x31070
movl $0x1, -0x2dc(%rbp)
jmp 0x66d8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66d75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
leaq -0x330(%rbp), %rdi
callq 0x14020
leaq -0x328(%rbp), %rdi
callq 0x31070
jmp 0x66dc0
movl $0x0, -0x2dc(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x30d20
movl -0x2dc(%rbp), %eax
testl %eax, %eax
je 0x66daa
jmp 0x66da5
jmp 0x66f6a
jmp 0x66dac
movl -0x304(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x304(%rbp)
jmp 0x66bf6
leaq -0x318(%rbp), %rdi
callq 0x30d20
jmp 0x66f73
leaq -0x530(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
leaq -0x29c(%rbp), %rsi
callq 0x6eef0
movq -0x5d0(%rbp), %r8
movq -0x10(%rbp), %rax
shlq $0x6, %rax
leaq 0x58ebf(%rip), %rcx     # 0xbfcc0
movq 0x10(%rax,%rcx), %rcx
leaq 0x279bc(%rip), %rsi     # 0x8e7c9
leaq 0x2958b(%rip), %rdx     # 0x9039f
leaq -0x540(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x19e10
movq -0x5c8(%rbp), %rdi
callq 0x31090
movb %al, -0x5b9(%rbp)
jmp 0x66e3b
movb -0x5b9(%rbp), %al
testb $0x1, %al
jne 0x66e47
jmp 0x66e63
jmp 0x66f25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66f5c
leaq -0x548(%rbp), %rdi
callq 0x16d70
jmp 0x66e71
leaq -0x540(%rbp), %rdi
callq 0x310b0
movq %rax, -0x5d8(%rbp)
jmp 0x66e86
movq -0x5d8(%rbp), %r8
leaq 0x277e4(%rip), %rdx     # 0x8e678
leaq -0x550(%rbp), %rdi
movl $0x2, %esi
movl $0x46, %ecx
callq 0x13fa0
jmp 0x66eac
leaq -0x550(%rbp), %rdi
leaq -0x548(%rbp), %rsi
callq 0x14060
jmp 0x66ec1
leaq -0x550(%rbp), %rdi
callq 0x14020
leaq -0x548(%rbp), %rdi
callq 0x31070
movl $0x1, -0x2dc(%rbp)
jmp 0x66f2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
jmp 0x66f17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c0(%rbp)
movl %eax, -0x2c4(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x14020
leaq -0x548(%rbp), %rdi
callq 0x31070
jmp 0x66f5c
movl $0x0, -0x2dc(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x30d20
movl -0x2dc(%rbp), %eax
testl %eax, %eax
je 0x66f49
jmp 0x66f47
jmp 0x66f6a
jmp 0x66f4b
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x668b7
leaq -0x540(%rbp), %rdi
callq 0x30d20
jmp 0x66f73
addq $0x5e0, %rsp            # imm = 0x5E0
popq %rbp
retq
movq -0x2c0(%rbp), %rdi
callq 0xee80
nop