12 #include "testing/testing.h"
16 TEST(AssetCatalogPathTest, construction)
30 const std::string str_const =
"the/path";
33 std::string str_variable =
"the/path";
36 std::string long_string =
"this is a long/string/with/a/path in the middle";
40 EXPECT_EQ(from_string_ref,
"long/string/with/a/path");
55 TEST(AssetCatalogPathTest, name)
64 TEST(AssetCatalogPathTest, comparison_operators)
72 EXPECT_LT(empty, the_path);
73 EXPECT_LT(the_path, the_path_child);
74 EXPECT_LT(the_path, unrelated_path);
76 EXPECT_EQ(empty, empty) <<
"Identical empty instances should compare equal.";
77 EXPECT_EQ(empty,
"") <<
"Comparison to empty string should be possible.";
78 EXPECT_EQ(the_path, the_path) <<
"Identical non-empty instances should compare equal.";
79 EXPECT_EQ(the_path,
"the/path") <<
"Comparison to string should be possible.";
80 EXPECT_EQ(the_path, other_instance_same_path)
81 <<
"Different instances with equal path should compare equal.";
83 EXPECT_NE(the_path, the_path_child);
84 EXPECT_NE(the_path, unrelated_path);
85 EXPECT_NE(the_path, empty);
88 EXPECT_TRUE(the_path);
91 TEST(AssetCatalogPathTest, move_semantics)
94 EXPECT_TRUE(source_path);
97 EXPECT_FALSE(source_path);
98 EXPECT_TRUE(dest_path);
101 TEST(AssetCatalogPathTest, concatenation)
107 <<
"Appending a child path should not modify the parent.";
108 EXPECT_EQ(child,
"some/родитель/ребенок");
111 EXPECT_EQ(appended_compound_path,
"some/родитель/ребенок/внук");
116 <<
"Appending to an empty path should not create an initial slash.";
119 EXPECT_EQ(parent_of_the_void,
"some/родитель")
120 <<
"Prepending to an empty path should not create a trailing slash.";
122 std::string subpath =
"child";
124 EXPECT_EQ(concatenated_with_string,
"some/родитель/child");
127 TEST(AssetCatalogPathTest, hashable)
131 std::set<AssetCatalogPath> path_std_set;
132 path_std_set.insert(path);
135 path_blender_set.
add(path);
138 TEST(AssetCatalogPathTest, stream_operator)
141 std::stringstream sstream;
143 EXPECT_EQ(
"путь/в/Пермь", sstream.str());
146 TEST(AssetCatalogPathTest, is_contained_in)
155 <<
"Non-normalized paths are not expected to work.";
173 AssetCatalogPath child_with_dotdot = some_parent /
"../../other/hierarchy/part";
175 <<
"dotdot path components should have no meaning";
178 TEST(AssetCatalogPathTest, cleanup)
184 <<
"cleanup should not modify the path instance itself";
209 TEST(AssetCatalogPathTest, iterate_components)
215 std::pair<std::string, bool> parameter_pair = std::make_pair<std::string, bool>(
216 component_name,
bool(is_last_component));
217 seen_components.
append(parameter_pair);
220 ASSERT_EQ(3, seen_components.
size());
222 EXPECT_EQ(
"путь", seen_components[0].first);
223 EXPECT_EQ(
"в", seen_components[1].first);
224 EXPECT_EQ(
"Пермь", seen_components[2].first);
226 EXPECT_FALSE(seen_components[0].second);
227 EXPECT_FALSE(seen_components[1].second);
228 EXPECT_TRUE(seen_components[2].second);
231 TEST(AssetCatalogPathTest, rebase)
234 EXPECT_EQ(path.
rebase(
"some/path",
"new/base"),
"new/base/to/some/catalog");
235 EXPECT_EQ(path.
rebase(
"",
"new/base"),
"new/base/some/path/to/some/catalog");
237 EXPECT_EQ(path.
rebase(
"some/path/to/some/catalog",
"some/path/to/some/catalog"),
238 "some/path/to/some/catalog")
239 <<
"Rebasing to itself should not change the path.";
242 <<
"Non-matching base path should return empty string to indicate 'NO'.";
251 TEST(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
void append(const T &value)
const std::string & str() const
AssetCatalogPath cleanup() const
bool is_contained_in(const AssetCatalogPath &other_path) const
void iterate_components(ComponentIteratorFn callback) const
AssetCatalogPath rebase(const AssetCatalogPath &from_path, const AssetCatalogPath &to_path) const
AssetCatalogPath parent() const
TEST(action_groups, ReconstructGroupsWithReordering)
T length(const vec_base< T, Size > &a)