From d1553d758662ad476caea58731402e400cf1a346 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 3 Jul 2018 23:51:10 +0200 Subject: [PATCH] Some more tests on tl::FileUtils --- src/tl/unit_tests/tlFileUtils.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tl/unit_tests/tlFileUtils.cc b/src/tl/unit_tests/tlFileUtils.cc index 1d21a2d23..ba1b60d16 100644 --- a/src/tl/unit_tests/tlFileUtils.cc +++ b/src/tl/unit_tests/tlFileUtils.cc @@ -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