MCPcopy Create free account
hub / github.com/boostorg/filesystem / weakly_canonical_basic_tests

Function weakly_canonical_basic_tests

test/operations_test.cpp:2868–2900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2866// weakly_canonical_basic_tests ----------------------------------------------------//
2867
2868void weakly_canonical_basic_tests()
2869{
2870 cout << "weakly_canonical_basic_tests..." << endl;
2871 cout << " dir is " << dir << endl;
2872
2873 // Note: Use cacnonical form of the root path in all paths to make path comparisons more stable
2874 const fs::path cur_path = canonicalize_root_path(fs::current_path());
2875
2876 BOOST_TEST_EQ(fs::weakly_canonical("no-such/foo/bar"), cur_path / fs::path("no-such/foo/bar"));
2877 BOOST_TEST_EQ(fs::weakly_canonical("no-such/foo/../bar"), cur_path / fs::path("no-such/bar"));
2878 BOOST_TEST_EQ(fs::weakly_canonical(dir), dir);
2879 BOOST_TEST_EQ(fs::weakly_canonical(dir / "no-such/foo/bar"), dir / "no-such/foo/bar");
2880 BOOST_TEST_EQ(fs::weakly_canonical(dir / "no-such/foo/../bar"), dir / "no-such/bar");
2881 BOOST_TEST_EQ(fs::weakly_canonical(dir / "../no-such/foo/../bar"), dir.parent_path() / "no-such/bar");
2882 BOOST_TEST_EQ(fs::weakly_canonical(dir / "no-such/../f0"), dir / "f0"); // dir / "f0" exists, dir / "no-such" does not
2883 BOOST_TEST_EQ(fs::weakly_canonical("f0", d1), d1 / "f0");
2884 BOOST_TEST_EQ(fs::weakly_canonical("./f0", d1), d1 / "f0");
2885 BOOST_TEST_EQ(fs::weakly_canonical("./foo", d1), d1 / "foo");
2886 BOOST_TEST_EQ(fs::weakly_canonical("../f0", d1), dir / "f0");
2887 BOOST_TEST_EQ(fs::weakly_canonical("../foo", d1), dir / "foo");
2888 BOOST_TEST_EQ(fs::weakly_canonical("..//foo", d1), dir / "foo");
2889
2890#ifdef BOOST_FILESYSTEM_WINDOWS_API
2891 BOOST_TEST_EQ(fs::weakly_canonical("c:/no-such/foo/bar"), fs::path("C:/no-such/foo/bar"));
2892
2893 // Test Windows long paths
2894 fs::path long_path = make_long_path(dir / L"f0");
2895 BOOST_TEST_EQ(fs::weakly_canonical(long_path), long_path);
2896
2897 long_path = make_long_path(dir / L"no-such/foo/bar");
2898 BOOST_TEST_EQ(fs::weakly_canonical(long_path), long_path);
2899#endif
2900}
2901
2902// weakly_canonical_symlink_tests --------------------------------------------------//
2903

Callers 1

cpp_mainFunction · 0.85

Calls 6

weakly_canonicalFunction · 0.85
make_long_pathFunction · 0.85
parent_pathMethod · 0.80
canonicalize_root_pathFunction · 0.70
pathFunction · 0.70
current_pathFunction · 0.50

Tested by

no test coverage detected