13#include "testing/testing.h"
17TEST(AssetCatalogPathTest, construction)
31 const std::string str_const =
"the/path";
34 std::string str_variable =
"the/path";
37 std::string long_string =
"this is a long/string/with/a/path in the middle";
41 EXPECT_EQ(from_string_ref,
"long/string/with/a/path");
56TEST(AssetCatalogPathTest, name)
65TEST(AssetCatalogPathTest, comparison_operators)
73 EXPECT_LT(empty, the_path);
74 EXPECT_LT(the_path, the_path_child);
75 EXPECT_LT(the_path, unrelated_path);
77 EXPECT_EQ(empty, empty) <<
"Identical empty instances should compare equal.";
78 EXPECT_EQ(empty,
"") <<
"Comparison to empty string should be possible.";
79 EXPECT_EQ(the_path, the_path) <<
"Identical non-empty instances should compare equal.";
80 EXPECT_EQ(the_path,
"the/path") <<
"Comparison to string should be possible.";
81 EXPECT_EQ(the_path, other_instance_same_path)
82 <<
"Different instances with equal path should compare equal.";
84 EXPECT_NE(the_path, the_path_child);
85 EXPECT_NE(the_path, unrelated_path);
86 EXPECT_NE(the_path, empty);
89 EXPECT_TRUE(the_path);
92TEST(AssetCatalogPathTest, move_semantics)
95 EXPECT_TRUE(source_path);
98 EXPECT_FALSE(source_path);
99 EXPECT_TRUE(dest_path);
102TEST(AssetCatalogPathTest, concatenation)
108 <<
"Appending a child path should not modify the parent.";
109 EXPECT_EQ(child,
"some/родитель/ребенок");
112 EXPECT_EQ(appended_compound_path,
"some/родитель/ребенок/внук");
117 <<
"Appending to an empty path should not create an initial slash.";
120 EXPECT_EQ(parent_of_the_void,
"some/родитель")
121 <<
"Prepending to an empty path should not create a trailing slash.";
123 std::string subpath =
"child";
125 EXPECT_EQ(concatenated_with_string,
"some/родитель/child");
128TEST(AssetCatalogPathTest, hashable)
132 std::set<AssetCatalogPath> path_std_set;
133 path_std_set.insert(path);
136 path_blender_set.
add(path);
139TEST(AssetCatalogPathTest, stream_operator)
142 std::stringstream sstream;
144 EXPECT_EQ(
"путь/в/Пермь", sstream.str());
147TEST(AssetCatalogPathTest, is_contained_in)
156 <<
"Non-normalized paths are not expected to work.";
174 AssetCatalogPath child_with_dotdot = some_parent /
"../../other/hierarchy/part";
176 <<
"dotdot path components should have no meaning";
179TEST(AssetCatalogPathTest, cleanup)
185 <<
"cleanup should not modify the path instance itself";
210TEST(AssetCatalogPathTest, iterate_components)
216 std::pair<std::string, bool> parameter_pair = std::make_pair<std::string, bool>(
217 component_name,
bool(is_last_component));
218 seen_components.
append(parameter_pair);
221 ASSERT_EQ(3, seen_components.
size());
223 EXPECT_EQ(
"путь", seen_components[0].first);
224 EXPECT_EQ(
"в", seen_components[1].first);
225 EXPECT_EQ(
"Пермь", seen_components[2].first);
227 EXPECT_FALSE(seen_components[0].second);
228 EXPECT_FALSE(seen_components[1].second);
229 EXPECT_TRUE(seen_components[2].second);
232TEST(AssetCatalogPathTest, rebase)
235 EXPECT_EQ(path.
rebase(
"some/path",
"new/base"),
"new/base/to/some/catalog");
236 EXPECT_EQ(path.
rebase(
"",
"new/base"),
"new/base/some/path/to/some/catalog");
238 EXPECT_EQ(path.
rebase(
"some/path/to/some/catalog",
"some/path/to/some/catalog"),
239 "some/path/to/some/catalog")
240 <<
"Rebasing to itself should not change the path.";
243 <<
"Non-matching base path should return empty string to indicate 'NO'.";
252TEST(AssetCatalogPathTest, parent)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr StringRefNull()
void append(const T &value)
AssetCatalogPath parent() const
const std::string & str() const
AssetCatalogPath cleanup() const
AssetCatalogPath rebase(const AssetCatalogPath &from_path, const AssetCatalogPath &to_path) const
AssetCatalogPath()=default
bool is_contained_in(const AssetCatalogPath &other_path) const
void iterate_components(ComponentIteratorFn callback) const
float length(VecOp< float, D >) RET
TEST(AssetCatalogPathTest, construction)