MCPcopy Create free account
hub / github.com/crownengine/crown / test_path

Function test_path

src/core/unit_tests.cpp:1629–1818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1627}
1628
1629static void test_path()
1630{
1631#if CROWN_PLATFORM_WINDOWS
1632 {
1633 ENSURE(path::is_absolute("C:\\Users\\foo"));
1634 ENSURE(path::is_absolute("/c/Users/foo"));
1635 ENSURE(!path::is_absolute("Users\\foo"));
1636 ENSURE(!path::is_absolute("Users/foo"));
1637 }
1638 {
1639 ENSURE(!path::is_relative("D:\\Users\\foo"));
1640 ENSURE(!path::is_relative("/d/Users/foo"));
1641 ENSURE(path::is_relative("Users\\foo"));
1642 ENSURE(path::is_relative("Users/foo"));
1643 }
1644 {
1645 ENSURE(path::is_root("E:\\"));
1646 ENSURE(path::is_root("/c"));
1647 ENSURE(!path::is_root("/home"));
1648 ENSURE(!path::is_root("E:\\Users"));
1649 ENSURE(!path::is_root("/c/Users"));
1650 }
1651 {
1652 ENSURE(path::has_trailing_separator("C:\\Users\\foo\\"));
1653 ENSURE(!path::has_trailing_separator("C:\\Users\\foo"));
1654 }
1655 {
1656 TempAllocator128 ta;
1657 DynamicString clean(ta);
1658 path::reduce(clean, "C:\\Users\\\\foo\\");
1659 ENSURE(clean == "C:\\Users\\foo");
1660 }
1661 {
1662 TempAllocator128 ta;
1663 DynamicString clean(ta);
1664 path::reduce(clean, "C:/Users//foo/");
1665 ENSURE(clean == "C:\\Users\\foo");
1666 }
1667 {
1668 StringView dir = path::parent_dir("C:\\");
1669 ENSURE(dir == "C:\\");
1670 }
1671 {
1672 StringView dir = path::parent_dir("C:\\foo");
1673 ENSURE(dir == "C:\\");
1674 }
1675 {
1676 StringView dir = path::parent_dir("C:\\foo\\bar");
1677 ENSURE(dir == "C:\\foo");
1678 }
1679#else
1680 {
1681 const bool a = path::is_absolute("/home/foo");
1682 ENSURE(a == true);
1683 const bool b = path::is_absolute("home/foo");
1684 ENSURE(b == false);
1685 }
1686 {

Callers

nothing calls this directly

Calls 13

is_absoluteFunction · 0.85
is_relativeFunction · 0.85
is_rootFunction · 0.85
has_trailing_separatorFunction · 0.85
reduceFunction · 0.85
parent_dirFunction · 0.85
basenameFunction · 0.85
strcmpFunction · 0.85
extensionFunction · 0.85
expandFunction · 0.85
is_valid_basenameFunction · 0.85
joinFunction · 0.50

Tested by

no test coverage detected