Skip to content

Commit 189509a

Browse files
committed
add files::startsWith unit tests
1 parent 6f6dd4c commit 189509a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/lib/Support/Path.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,45 @@ struct Path_test
2929
*/
3030
}
3131

32+
void
33+
testStartsWith()
34+
{
35+
using namespace files;
36+
37+
// empty
38+
{
39+
BOOST_TEST(startsWith("", ""));
40+
}
41+
42+
// identical
43+
{
44+
BOOST_TEST(startsWith("/", "/"));
45+
BOOST_TEST(startsWith("/abc", "/abc"));
46+
BOOST_TEST(startsWith("/abc/def", "/abc/def"));
47+
}
48+
49+
// equivalent
50+
{
51+
BOOST_TEST(startsWith("/", "\\"));
52+
BOOST_TEST(startsWith("/abc", "\\abc"));
53+
BOOST_TEST(startsWith("\\abc", "/abc"));
54+
BOOST_TEST(startsWith("/abc/def", "\\abc\\def"));
55+
BOOST_TEST(startsWith("\\abc\\def", "/abc/def"));
56+
}
57+
58+
// subdirectory
59+
{
60+
BOOST_TEST(startsWith("/abc/def", "/abc"));
61+
BOOST_TEST(startsWith("\\abc\\def", "/abc"));
62+
BOOST_TEST_NOT(startsWith("/abcdef", "/abc"));
63+
BOOST_TEST_NOT(startsWith("\\abcdef", "/abc"));
64+
}
65+
}
66+
3267
void run()
3368
{
3469
testPaths();
70+
testStartsWith();
3571
}
3672
};
3773

0 commit comments

Comments
 (0)