Some more tests on tl::FileUtils

This commit is contained in:
Matthias Koefferlein 2018-07-03 23:51:10 +02:00
parent 17c7c8e1bb
commit d1553d7586
1 changed files with 24 additions and 0 deletions

View File

@ -245,6 +245,10 @@ TEST (10)
EXPECT_EQ (tl::extension ("\\hello\\.world.gz"), "gz");
EXPECT_EQ (tl::extension ("/hello//world/"), "");
EXPECT_EQ (tl::combine_path ("hello", "world"), "hello\\world");
EXPECT_EQ (tl::combine_path ("hello", ""), "hello");
EXPECT_EQ (tl::combine_path ("hello", "", true), "hello\\");
tl::file_utils_force_reset ();
} catch (...) {
@ -291,6 +295,10 @@ TEST (11)
EXPECT_EQ (tl::extension ("/hello/.world.gz"), "gz");
EXPECT_EQ (tl::extension ("/hello//world/"), "");
EXPECT_EQ (tl::combine_path ("hello", "world"), "hello/world");
EXPECT_EQ (tl::combine_path ("hello", ""), "hello");
EXPECT_EQ (tl::combine_path ("hello", "", true), "hello/");
tl::file_utils_force_reset ();
} catch (...) {
@ -299,4 +307,20 @@ TEST (11)
}
}
// current_dir
TEST (12)
{
std::string currdir = tl::current_dir ();
std::string currdir_abs = tl::absolute_file_path (".");
EXPECT_EQ (currdir, currdir_abs);
std::string above = tl::absolute_file_path ("..");
EXPECT_EQ (tl::is_same_file (currdir, above), false);
EXPECT_EQ (tl::is_parent_path (currdir, above), false);
EXPECT_EQ (tl::is_parent_path (currdir, currdir), true);
EXPECT_EQ (tl::is_parent_path (above, currdir), true);
EXPECT_EQ (tl::is_parent_path (above, above), true);
EXPECT_EQ (tl::is_same_file (tl::combine_path (currdir, ".."), above), true);
}
#endif