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),
37 error.byte_range.start(),
38 error.byte_range.size());
47 fmt::format_to(std::back_inserter(s),
"[");
54 fmt::format_to(std::back_inserter(s),
", ");
58 fmt::format_to(std::back_inserter(s),
"]");
69 EXPECT_FALSE(map.
remove(
"hello"));
76 EXPECT_TRUE(map.
add_string(
"hello",
"What a wonderful world."));
79 EXPECT_TRUE(map.
add_float(
"what", 3.14159));
95 EXPECT_FALSE(map.
add_float(
"hello", 2.71828));
96 EXPECT_FALSE(map.
add_float(
"where", 2.71828));
97 EXPECT_FALSE(map.
add_float(
"bye", 2.71828));
98 EXPECT_FALSE(map.
add_float(
"what", 2.71828));
105 EXPECT_FALSE(map.
contains(
"not here"));
129 EXPECT_TRUE(map.
remove(
"hello"));
130 EXPECT_TRUE(map.
remove(
"where"));
131 EXPECT_TRUE(map.
remove(
"bye"));
132 EXPECT_TRUE(map.
remove(
"what"));
135 EXPECT_FALSE(map.
contains(
"hello"));
136 EXPECT_FALSE(map.
contains(
"where"));
143 EXPECT_FALSE(map.
remove(
"hello"));
144 EXPECT_FALSE(map.
remove(
"where"));
145 EXPECT_FALSE(map.
remove(
"bye"));
146 EXPECT_FALSE(map.
remove(
"what"));
153 EXPECT_TRUE(map.
add_filename_only(
"a",
"/home/bob/project_joe/scene_3.blend",
"fallback"));
156 EXPECT_TRUE(map.
add_filename_only(
"b",
"/home/bob/project_joe/scene_3",
"fallback"));
159 EXPECT_TRUE(map.
add_filename_only(
"c",
"/home/bob/project_joe/scene.03.blend",
"fallback"));
162 EXPECT_TRUE(map.
add_filename_only(
"d",
"/home/bob/project_joe/.scene_3.blend",
"fallback"));
165 EXPECT_TRUE(map.
add_filename_only(
"e",
"/home/bob/project_joe/.scene_3",
"fallback"));
190 EXPECT_TRUE(map.
add_path_up_to_file(
"a",
"/home/bob/project_joe/scene_3.blend",
"fallback"));
231 variables.
add_string(
"sanitize",
"./\\?*:|\"<>");
232 variables.
add_string(
"long",
"This string is exactly 32 bytes_");
237 variables.
add_float(
"pi", 3.14159265358979323846);
238 variables.
add_float(
"e", 2.71828182845904523536);
239 variables.
add_float(
"ntsc", 30.0 / 1.001);
241 variables.
add_float(
"f_negative", -3.14159265358979323846);
242 variables.
add_float(
"huge", 200000000000000000000000000000000.0);
243 variables.
add_float(
"tiny", 0.000000000000000000000000000000002);
249 "{hi}_{bye}_{empty}_{sanitize}_{path}"
250 "_{the_answer}_{prime}_{i_negative}_{pi}_{e}_{ntsc}_{two}"
251 "_{f_negative}_{huge}_{tiny}",
252 "hello_goodbye__.__________C:\\and/or/../nor/"
253 "_42_7_-7_3.141592653589793_2.718281828459045_29.970029970029973_2.0"
254 "_-3.141592653589793_2e+32_2e-33",
260 "{the_answer:#}_{the_answer:##}_{the_answer:####}_{i_negative:####}",
267 "{the_answer:.###}_{the_answer:#.##}_{the_answer:###.##}_{i_negative:###.####}",
268 "42.000_42.00_042.00_-07.0000",
274 "{pi:.####}_{e:.###}_{ntsc:.########}_{two:.##}_{f_negative:.##}_{huge:.##}_{tiny:.##}",
275 "3.1416_2.718_29.97002997_2.00_-3.14_200000000000000010732324408786944.00_0.00",
281 "{pi:##.####}_{e:####.###}_{ntsc:#.########}_{two:###.##}_{f_negative:###.##}_{huge:###."
283 "03.1416_0002.718_29.97002997_002.00_-03.14_200000000000000010732324408786944.00_000.00",
289 "{pi:##}_{e:####}_{ntsc:#}_{two:###}",
296 "{hi}_{{hi}}_{{{bye}}}_{bye}",
297 "hello_{hi}_{goodbye}_goodbye",
314 "{pi:##.}_{e:####.}_{ntsc:#.}_{two:###.}_{f_negative:###.}_{huge:###.}_{tiny:###.}",
315 "{pi:##.}_{e:####.}_{ntsc:#.}_{two:###.}_{f_negative:###.}_{huge:###.}_{tiny:###.}",
329 "{hi}_{missing}_{bye}",
330 "{hi}_{missing}_{bye}",
356 "{prime:}_{prime:.}_{prime:#.#.#}_{prime:sup}_{prime::sup}_{prime}",
357 "{prime:}_{prime:.}_{prime:#.#.#}_{prime:sup}_{prime::sup}_{prime}",
394 "___{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}"
395 "{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
396 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
397 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
398 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
399 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
400 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
401 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
402 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
403 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
404 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
405 "long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{long}{"
408 "___This string is exactly 32 bytes_This string is exactly 32 bytes_This string is "
409 "exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This "
410 "string is exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 "
411 "bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This string is "
412 "exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This "
413 "string is exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 "
414 "bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This string is "
415 "exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This "
416 "string is exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 "
417 "bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This string is "
418 "exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 bytes_This "
419 "string is exactly 32 bytes_This string is exactly 32 bytes_This string is exactly 32 "
428 STRNCPY(path, test_case.path_in);
432 EXPECT_EQ(validation_errors, test_case.expected_errors)
434 <<
" Expected errors: " <<
errors_to_string(test_case.expected_errors) << std::endl
435 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
437 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
441 EXPECT_EQ(application_errors, test_case.expected_errors)
442 <<
" Template errors: " <<
errors_to_string(application_errors) << std::endl
443 <<
" Expected errors: " <<
errors_to_string(test_case.expected_errors) << std::endl
444 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
446 <<
" Note: test_case.path_in = " << test_case.path_in << std::endl;
Functions and classes for evaluating template expressions in filepaths.
blender::Vector< blender::bke::path_templates::Error > BKE_path_validate_template(blender::StringRef path, const blender::bke::path_templates::VariableMap &template_variables)
blender::Vector< blender::bke::path_templates::Error > BKE_path_apply_template(char *path, int path_maxncpy, const blender::bke::path_templates::VariableMap &template_variables)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
char * STRNCPY(char(&dst)[N], const char *src)
bool add_path_up_to_file(blender::StringRef var_name, blender::StringRefNull full_path, blender::StringRef fallback)
std::optional< blender::StringRefNull > get_string(blender::StringRef name) const
bool add_filepath(blender::StringRef name, blender::StringRef value)
bool add_filename_only(blender::StringRef var_name, blender::StringRefNull full_path, blender::StringRef fallback)
std::optional< int64_t > get_integer(blender::StringRef name) const
bool add_string(blender::StringRef name, blender::StringRef value)
std::optional< blender::StringRefNull > get_filepath(blender::StringRef name) const
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 void error(const char *str)
static std::string error_to_string(const Error &error)
TEST(action_groups, ReconstructGroupsWithReordering)
static std::string errors_to_string(Span< Error > errors)
char path_result[FILE_MAX]
Vector< Error > expected_errors