Changeset View
Changeset View
Standalone View
Standalone View
tests/gtests/blenlib/BLI_path_util_test.cc
| Show First 20 Lines • Show All 612 Lines • ▼ Show 20 Lines | TEST(path_util, PathFrameGet) | ||||
| PATH_FRAME_GET("001.avi", 1, 3, true); | PATH_FRAME_GET("001.avi", 1, 3, true); | ||||
| PATH_FRAME_GET("0000299.ext", 299, 7, true); | PATH_FRAME_GET("0000299.ext", 299, 7, true); | ||||
| PATH_FRAME_GET("path/to/frame_2810.dummy_quite_long_extension", 2810, 4, true); | PATH_FRAME_GET("path/to/frame_2810.dummy_quite_long_extension", 2810, 4, true); | ||||
| PATH_FRAME_GET("notframe_7_frame00018.bla", 18, 5, true); | PATH_FRAME_GET("notframe_7_frame00018.bla", 18, 5, true); | ||||
| PATH_FRAME_GET("", -1, -1, false); | PATH_FRAME_GET("", -1, -1, false); | ||||
| } | } | ||||
| #undef PATH_FRAME_GET | #undef PATH_FRAME_GET | ||||
| #define MAKE_SAFE(input_path, expect_path) \ | |||||
| { \ | |||||
| char path[FILE_MAX]; \ | |||||
| BLI_strncpy(path, input_path, FILE_MAX); \ | |||||
| const bool ret = BLI_path_make_safe(path); \ | |||||
| if (expect_path != NULL) { \ | |||||
| ASSERT_TRUE(ret); \ | |||||
| ASSERT_STREQ(path, expect_path); \ | |||||
| } \ | |||||
| else { \ | |||||
| ASSERT_FALSE(ret); \ | |||||
| } \ | |||||
| } | |||||
| /* BLI_path_make_safe */ | |||||
| TEST(path_util, MakeSafe) | |||||
| { | |||||
| MAKE_SAFE("safename", NULL); | |||||
| MAKE_SAFE("", NULL); | |||||
| MAKE_SAFE("white space seperated name", NULL); | |||||
| MAKE_SAFE("Allowed $$ chars & ()!!02", NULL); | |||||
| MAKE_SAFE("bad but allowed äöü#@§", NULL); | |||||
| MAKE_SAFE("still allowed #{}=ß", NULL); | |||||
| MAKE_SAFE("0192837465 + letters", NULL); | |||||
| MAKE_SAFE("dots.are.ok", NULL); | |||||
| MAKE_SAFE("unsafe<>name", "unsafe__name"); | |||||
| MAKE_SAFE("<<<<<<<<", "________"); | |||||
| MAKE_SAFE("end with :", "end with _"); | |||||
| MAKE_SAFE("|", "_"); | |||||
| MAKE_SAFE("| ", "_ "); | |||||
| MAKE_SAFE(" |", " _"); | |||||
| MAKE_SAFE("| not allowed |", "_ not allowed _"); | |||||
| MAKE_SAFE("*please_no_stars*", "_please_no_stars_"); | |||||
| MAKE_SAFE("\x01", "_"); | |||||
| MAKE_SAFE("\x10", "_"); | |||||
| MAKE_SAFE("? * : | < >", "_ _ _ _ _ _") | |||||
| /* following tests are failing */ | |||||
| MAKE_SAFE("path/to/file/as/filename.h", "path_to_file_as_filename.h"); | |||||
| MAKE_SAFE("\\", "_"); | |||||
| MAKE_SAFE("/", "_"); | |||||
| MAKE_SAFE("\\ / ", "_ _"); | |||||
| } | |||||