aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_fileutils01.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-07 03:11:30 +0200
committerSven Gothel <[email protected]>2022-07-07 03:11:30 +0200
commite2ad720568f730fe5ca2f1d0c9c911b339fb58b8 (patch)
treee2e8baf85c006d0b494b42554dc9b3d87a794816 /test/test_fileutils01.cpp
parentb9d1c558884dd5f5ce23ee7d35e2f14201a2c4c2 (diff)
Fix dir_item::reduce()
- use while-loop to remove initial './' - always use spos and reset to pre-len when re-assembling pre+post - break resolve loop once on found idx == npos - limit loop to spos <= haystack.size()-pattern_size - resolve '/./': - remove dead-case '_dot == pre' as resolved upfront - resolve '/../': - test non-starting '/..' at end of pre -> no change. E.g. '../../../bbb' - case 'pre_str = direname(pre)': test '.' (first dir removed)
Diffstat (limited to 'test/test_fileutils01.cpp')
-rw-r--r--test/test_fileutils01.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/test/test_fileutils01.cpp b/test/test_fileutils01.cpp
index d10be65..54a59e8 100644
--- a/test/test_fileutils01.cpp
+++ b/test/test_fileutils01.cpp
@@ -396,7 +396,42 @@ class TestFileUtil01 : TestFileUtilBase {
INFO_STR("\n\ntest04_dir_item: 60 '"+path1_+" -> "+di.to_string()+" -> '"+di.path()+"'\n");
REQUIRE( "../../test_data" == di.dirname() );
REQUIRE( "file_01_slink09R1.txt" == di.basename() );
- REQUIRE( "../../test_data/file_01_slink09R1.txt" == di.path() );
+ REQUIRE( path1_ == di.path() );
+ }
+
+ {
+ const std::string path1_ = "../../../jaulib/test_data";
+ const jau::fs::dir_item di(path1_);
+ INFO_STR("\n\ntest04_dir_item: 61 '"+path1_+" -> "+di.to_string()+" -> '"+di.path()+"'\n");
+ REQUIRE( "../../../jaulib" == di.dirname() );
+ REQUIRE( "test_data" == di.basename() );
+ REQUIRE( path1_ == di.path() );
+ }
+
+ {
+ const std::string path1_ = "../../../../jaulib/test_data";
+ const jau::fs::dir_item di(path1_);
+ INFO_STR("\n\ntest04_dir_item: 62 '"+path1_+" -> "+di.to_string()+" -> '"+di.path()+"'\n");
+ REQUIRE( "../../../../jaulib" == di.dirname() );
+ REQUIRE( "test_data" == di.basename() );
+ REQUIRE( path1_ == di.path() );
+ }
+
+ {
+ const std::string path1_ = "././././jaulib/test_data";
+ const jau::fs::dir_item di(path1_);
+ INFO_STR("\n\ntest04_dir_item: 63 '"+path1_+" -> "+di.to_string()+" -> '"+di.path()+"'\n");
+ REQUIRE( "jaulib" == di.dirname() );
+ REQUIRE( "test_data" == di.basename() );
+ REQUIRE( "jaulib/test_data" == di.path() );
+ }
+ {
+ const std::string path1_ = "a/././././jaulib/test_data";
+ const jau::fs::dir_item di(path1_);
+ INFO_STR("\n\ntest04_dir_item: 64 '"+path1_+" -> "+di.to_string()+" -> '"+di.path()+"'\n");
+ REQUIRE( "a/jaulib" == di.dirname() );
+ REQUIRE( "test_data" == di.basename() );
+ REQUIRE( "a/jaulib/test_data" == di.path() );
}
{