9#include "testing/testing.h"
13using namespace blender::bke::path_templates;
20 type =
"UNESCAPED_CURLY_BRACE";
23 type =
"VARIABLE_SYNTAX";
26 type =
"FORMAT_SPECIFIER";
29 type =
"UNKNOWN_VARIABLE";
34 fmt::format_to(std::back_inserter(s),
47 fmt::format_to(std::back_inserter(s),
"[");
49 for (
const Error &error : errors) {
54 fmt::format_to(std::back_inserter(s),
", ");
58 fmt::format_to(std::back_inserter(s),
"]");
69 EXPECT_FALSE(map.
remove(
"hello"));
75 EXPECT_TRUE(map.
add_string(
"hello",
"What a wonderful world."));
77 EXPECT_TRUE(map.
add_float(
"what", 3.14159));
87 EXPECT_FALSE(map.
add_float(
"hello", 2.71828));
88 EXPECT_FALSE(map.
add_float(
"bye", 2.71828));
89 EXPECT_FALSE(map.
add_float(
"what", 2.71828));
95 EXPECT_FALSE(map.
contains(
"not here"));
112 EXPECT_TRUE(map.
remove(
"hello"));
113 EXPECT_TRUE(map.
remove(
"bye"));
114 EXPECT_TRUE(map.
remove(
"what"));
117 EXPECT_FALSE(map.
contains(
"hello"));
123 EXPECT_FALSE(map.
remove(
"hello"));
124 EXPECT_FALSE(map.
remove(
"bye"));
125 EXPECT_FALSE(map.
remove(
"what"));
140 variables.
add_string(
"long",
"This string is exactly 32 bytes.");
144 variables.
add_float(
"pi", 3.14159265358979323846);
145 variables.
add_float(
"e", 2.71828182845904523536);
146 variables.
add_float(
"ntsc", 30.0 / 1.001);
148 variables.
add_float(
"f_negative", -3.14159265358979323846);
149 variables.
add_float(
"huge", 200000000000000000000000000000000.0);
150 variables.
add_float(
"tiny", 0.000000000000000000000000000000002);
156 "{hi}_{bye}_{the_answer}_{prime}_{i_negative}_{pi}_{e}_{ntsc}_{two}_{f_negative}_{huge}_"
158 "hello_goodbye_42_7_-7_3.141592653589793_2.718281828459045_29.970029970029973_2.0_-3."
159 "141592653589793_2e+32_2e-33",
165 "{the_answer:#}_{the_answer:##}_{the_answer:####}_{i_negative:####}",
172 "{the_answer:.###}_{the_answer:#.##}_{the_answer:###.##}_{i_negative:###.####}",
173 "42.000_42.00_042.00_-07.0000",
179 "{pi:.####}_{e:.###}_{ntsc:.########}_{two:.##}_{f_negative:.##}_{huge:.##}_{tiny:.##}",
180 "3.1416_2.718_29.97002997_2.00_-3.14_200000000000000010732324408786944.00_0.00",
186 "{pi:##.####}_{e:####.###}_{ntsc:#.########}_{two:###.##}_{f_negative:###.##}_{huge:###."
188 "03.1416_0002.718_29.97002997_002.00_-03.14_200000000000000010732324408786944.00_000.00",
194 "{pi:##}_{e:####}_{ntsc:#}_{two:###}",
201 "{hi}_{{hi}}_{{{bye}}}_{bye}",
202 "hello_{hi}_{goodbye}_goodbye",
219 "{pi:##.}_{e:####.}_{ntsc:#.}_{two:###.}_{f_negative:###.}_{huge:###.}_{tiny:###.}",
220 "{pi:##.}_{e:####.}_{ntsc:#.}_{two:###.}_{f_negative:###.}_{huge:###.}_{tiny:###.}",
234 "{hi}_{missing}_{bye}",
235 "{hi}_{missing}_{bye}",
261 "{prime:}_{prime:.}_{prime:#.#.#}_{prime:sup}_{prime::sup}_{prime}",
262 "{prime:}_{prime:.}_{prime:#.#.#}_{prime:sup}_{prime::sup}_{prime}",
299 "___{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}"
300 "{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
301 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
302 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
303 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
304 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
305 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
306 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
307 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
308 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
309 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
310 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
313 "___This string is exactly 32 bytes.This string is exactly 32 bytes.This string is "
314 "exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This "
315 "string is exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 "
316 "bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This string is "
317 "exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This "
318 "string is exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 "
319 "bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This string is "
320 "exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This "
321 "string is exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 "
322 "bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This string is "
323 "exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 bytes.This "
324 "string is exactly 32 bytes.This string is exactly 32 bytes.This string is exactly 32 "
337 EXPECT_EQ(validation_errors, test_case.expected_errors)
339 <<
" Expected errors: " <<
errors_to_string(test_case.expected_errors) << std::endl
340 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
342 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
346 EXPECT_EQ(application_errors, test_case.expected_errors)
347 <<
" Template errors: " <<
errors_to_string(application_errors) << std::endl
348 <<
" Expected errors: " <<
errors_to_string(test_case.expected_errors) << std::endl
349 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
351 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
Functions and classes for applying templates with variable expressions to filepaths.
blender::Vector< blender::bke::path_templates::Error > BKE_path_validate_template(blender::StringRef path, const blender::bke::path_templates::VariableMap &template_variables)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr int64_t start() const
std::optional< blender::StringRefNull > get_string(blender::StringRef name) const
std::optional< int64_t > get_integer(blender::StringRef name) const
bool add_string(blender::StringRef name, blender::StringRef value)
bool contains(blender::StringRef name) const
bool add_float(blender::StringRef name, double value)
bool remove(blender::StringRef name)
bool add_integer(blender::StringRef name, int64_t value)
std::optional< double > get_float(blender::StringRef name) const
static std::string error_to_string(const Error &error)
TEST(action_groups, ReconstructGroupsWithReordering)
static std::string errors_to_string(Span< Error > errors)
blender::Vector< Error > BKE_path_apply_template(char *path, int path_max_length, const VariableMap &template_variables)
blender::IndexRange byte_range
char path_result[FILE_MAX]
Vector< Error > expected_errors