Blender V4.3
BLI_path_utils_test.cc File Reference
#include "testing/testing.h"
#include "IMB_imbuf.hh"
#include "BLI_fileops.h"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLI_string_utils.hh"

Go to the source code of this file.

Macros

#define DO_PERF_TESTS   0
 

Functions

Local Utilities
static void str_replace_char_with_relative_exception (char *str, char src, char dst)
 
static char * str_replace_char_strdup (const char *str, char src, char dst)
 
Tests for: #BLI_path_cmp_normalized
Note
BLI_path_normalize tests handle most of the corner cases.
 TEST (path_utils, CompareNormalized)
 
Tests for: #BLI_path_is_unc
 TEST (path_utils, IsUnc)
 
Tests for: #BLI_path_is_win32_drive
 TEST (path_utils, IsWin32Drive)
 
Tests for: #BLI_path_is_win32_drive_only
 TEST (path_utils, IsWin32DriveOnly)
 
Tests for: #BLI_path_is_win32_drive_with_slash
 TEST (path_utils, IsWin32DriveWithSlash)
 
Tests for: #BLI_path_frame
 TEST (path_utils, Frame)
 
Tests for: #BLI_path_split_dir_file
 TEST (path_utils, SplitDirfile)
 
Tests for: #BLI_path_extension
 TEST (path_utils, Extension)
 
Tests for: #BLI_path_is_rel
 TEST (path_utils, PathIsRel)
 
Tests for: #BLI_path_is_abs_from_cwd
 TEST (path_utils, PathIsAbsFromCwd)
 
Tests for: #BLI_path_contains
 TEST (path_utils, Contains)
 
Tests for: #BLI_path_has_hidden_component
 TEST (path_utils, HasHiddenComponents)
 

Tests for: #BLI_path_normalize

#define NORMALIZE(input, output_expect)
 
 TEST (path_utils, Normalize_Nop)
 
 TEST (path_utils, Normalize_NopRelative)
 
 TEST (path_utils, Normalize_Dot)
 
 TEST (path_utils, Normalize_ComplexAbsolute)
 
 TEST (path_utils, Normalize_ComplexRelative)
 
 TEST (path_utils, Normalize_DoubleSlash)
 
 TEST (path_utils, Normalize_Parent)
 
 TEST (path_utils, Normalize_UnbalancedAbsolute)
 
 TEST (path_utils, Normalize_UnbalancedRelative)
 
 TEST (path_utils, Normalize_UnbalancedRelativeTrailing)
 

Tests for: #BLI_path_parent_dir

#define PARENT_DIR(input, output_expect)
 
 TEST (path_utils, ParentDir_Simple)
 
 TEST (path_utils, ParentDir_NOP)
 
 TEST (path_utils, ParentDir_TrailingPeriod)
 
 TEST (path_utils, ParentDir_Complex)
 

Tests for: #BLI_path_name_at_index

#define AT_INDEX(str_input, index_input, str_expect)
 
#define TEST_STR   "./a/./b/./c/."
 
#define TEST_STR   ".//a//.//b//.//c//.//"
 
 TEST (path_utils, NameAtIndex_Single)
 
 TEST (path_utils, NameAtIndex_SingleNeg)
 
 TEST (path_utils, NameAtIndex_Double)
 
 TEST (path_utils, NameAtIndex_DoublNeg)
 
 TEST (path_utils, NameAtIndex_Misc)
 
 TEST (path_utils, NameAtIndex_MiscNeg)
 
 TEST (path_utils, NameAtIndex_SingleDot)
 
 TEST (path_utils, NameAtIndex_SingleDotNeg)
 
 TEST (path_utils, NameAtIndex_SingleDotDoubleSlash)
 
 TEST (path_utils, NameAtIndex_SingleDotDoubleSlashNeg)
 
 TEST (path_utils, NameAtIndex_SingleDotSeries)
 
 TEST (path_utils, NameAtIndex_SingleDotSeriesNeg)
 
 TEST (path_utils, NameAtIndex_MiscComplex)
 
 TEST (path_utils, NameAtIndex_MiscComplexNeg)
 
 TEST (path_utils, NameAtIndex_NoneComplex)
 
 TEST (path_utils, NameAtIndex_NoneComplexNeg)
 

Tests for: #BLI_path_join

#define JOIN_FORWARD_SLASH(str_expect, out_size, ...)
 
#define JOIN_BACK_SLASH(str_expect, out_size, ...)
 
#define JOIN   JOIN_FORWARD_SLASH
 
 TEST (path_utils, JoinNop)
 
 TEST (path_utils, JoinSingle)
 
 TEST (path_utils, JoinTriple)
 
 TEST (path_utils, JoinTruncateShort)
 
 TEST (path_utils, JoinTruncateLong)
 
 TEST (path_utils, JoinComplex)
 
 TEST (path_utils, JoinRelativePrefix)
 

Tests for: #BLI_path_append

#define APPEND(str_expect, size, path, filename)
 
 TEST (path_utils, AppendFile)
 
 TEST (path_utils, AppendFile_Truncate)
 

Tests for: #BLI_path_frame_strip

#define PATH_FRAME_STRIP(input_path, expect_path, expect_ext)
 
 TEST (path_utils, FrameStrip)
 

Tests for: #BLI_path_extension_check

#define PATH_EXTENSION_CHECK(input_path, input_ext, expect_ext)
 
 TEST (path_utils, ExtensionCheck)
 

Tests for: #BLI_path_extension_replace

#define PATH_EXTENSION_REPLACE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, maxlen)
 
#define PATH_EXTENSION_REPLACE(input_path, input_ext, expect_result, expect_path)    PATH_EXTENSION_REPLACE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, FILE_MAX)
 
 TEST (path_utils, ExtensionReplace)
 
 TEST (path_utils, ExtensionReplace_Overflow)
 

Tests for: #BLI_path_extension_ensure

#define PATH_EXTENSION_ENSURE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, maxlen)
 
#define PATH_EXTENSION_ENSURE(input_path, input_ext, expect_result, expect_path)    PATH_EXTENSION_ENSURE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, FILE_MAX)
 
 TEST (path_utils, ExtensionEnsure)
 
 TEST (path_utils, ExtensionEnsure_Overflow)
 

Tests for: #BLI_path_frame_check_chars

#define PATH_FRAME_CHECK_CHARS(input_path, expect_hasChars)
 
 TEST (path_utils, FrameCheckChars)
 

Tests for: #BLI_path_frame_range

#define PATH_FRAME_RANGE(input_path, sta, end, digits, expect_outpath)
 
 TEST (path_utils, FrameRange)
 

Tests for: #BLI_path_frame_get

#define PATH_FRAME_GET(input_path, expect_frame, expect_numdigits, expect_pathisvalid)
 
 TEST (path_utils, FrameGet)
 

Tests for: #BLI_path_sequence_decode

#define PATH_SEQ_DECODE(path_literal, expect_result, expect_head, expect_tail, expect_numdigits)
 
 TEST (path_utils, SequenceDecode)
 

Tests for: #BLI_path_suffix

#define PATH_SUFFIX(path_literal, path_literal_max, sep, suffix, expect_result, expect_path)
 
 TEST (path_utils, Suffix)
 

Tests for: #BLI_path_slash_find

#define PATH_SLASH_FIND(path, expect_index)
 
 TEST (path_util, SlashFind)
 

Tests for: #BLI_path_slash_rfind

#define PATH_SLASH_RFIND(path, expect_index)
 
 TEST (path_util, SlashRFind)
 

Tests for: #BLI_path_slash_ensure

#define PATH_SLASH_ENSURE(input, size, output_expect, length_expect)
 
 TEST (path_util, SlashEnsure)
 

Tests for: #BLI_path_slash_rstrip

#define PATH_SLASH_RSTRIP(input, expected)
 
 TEST (path_util, SlashRStrip)
 

Tests for: #BLI_path_slash_skip

#define PATH_SLASH_SKIP(input, expected)
 
 TEST (path_util, SlashSkip)
 

Tests for: #BLI_path_slash_native

#define PATH_SLASH_NATIVE(input, expected)
 
 TEST (path_util, SlashNative)
 

Tests for: #BLI_path_rel

#define PATH_REL(abs_path, ref_path, rel_path_expect)
 
#define ABS_PREFIX   ""
 
 TEST (path_utils, RelPath_Simple)
 
 TEST (path_utils, RelPath_SimpleSubdir)
 
 TEST (path_utils, RelPath_BufferOverflowRoot)
 
 TEST (path_utils, RelPath_BufferOverflowSubdir)
 

Macro Definition Documentation

◆ ABS_PREFIX

#define ABS_PREFIX   ""

Definition at line 1571 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ APPEND

#define APPEND ( str_expect,
size,
path,
filename )
Value:
{ \
const char *expect = str_expect; \
char result[(size) + 1024] = path; \
char filename_native[] = filename; \
/* Check we don't write past the last byte. */ \
if (SEP == '\\') { \
BLI_string_replace_char(filename_native, '/', '\\'); \
BLI_string_replace_char(result, '/', '\\'); \
} \
BLI_path_append(result, size, filename_native); \
if (SEP == '\\') { \
BLI_string_replace_char(result, '\\', '/'); \
} \
EXPECT_STREQ(result, expect); \
} \
((void)0)
#define SEP
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52

Definition at line 693 of file BLI_path_utils_test.cc.

Referenced by TEST(), and TEST().

◆ AT_INDEX

#define AT_INDEX ( str_input,
index_input,
str_expect )
Value:
{ \
char path[] = str_input; \
/* Test input assumes forward slash, support back-slash on WIN32. */ \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
} \
const char *expect = str_expect; \
int index_output, len_output; \
const bool ret = BLI_path_name_at_index(path, index_input, &index_output, &len_output); \
if (expect == nullptr) { \
EXPECT_FALSE(ret); \
} \
else { \
EXPECT_TRUE(ret); \
EXPECT_EQ(len_output, strlen(expect)); \
path[index_output + len_output] = '\0'; \
EXPECT_STREQ(&path[index_output], expect); \
} \
} \
((void)0)
bool BLI_path_name_at_index(const char *__restrict path, int index, int *__restrict r_offset, int *__restrict r_len) ATTR_NONNULL(1
return ret

Definition at line 252 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ DO_PERF_TESTS

#define DO_PERF_TESTS   0

Definition at line 14 of file BLI_path_utils_test.cc.

◆ JOIN

Definition at line 590 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ JOIN_BACK_SLASH

#define JOIN_BACK_SLASH ( str_expect,
out_size,
... )
Value:
{ \
const char *expect = str_expect; \
char result[(out_size) + 1024]; \
const char *input_forward_slash[] = {__VA_ARGS__}; \
char *input_back_slash[ARRAY_SIZE(input_forward_slash)] = {nullptr}; \
for (int i = 0; i < ARRAY_SIZE(input_forward_slash); i++) { \
input_back_slash[i] = strdup(input_forward_slash[i]); \
BLI_string_replace_char(input_back_slash[i], '/', '\\'); \
} \
/* Check we don't write past the last byte. */ \
result[out_size] = '\0'; \
BLI_path_join_array(result, \
out_size, \
const_cast<const char **>(input_back_slash), \
ARRAY_SIZE(input_back_slash)); \
BLI_string_replace_char(result, '\\', '/'); \
EXPECT_STREQ(result, expect); \
EXPECT_EQ(result[out_size], '\0'); \
for (int i = 0; i < ARRAY_SIZE(input_forward_slash); i++) { \
free(input_back_slash[i]); \
} \
} \
((void)0)
#define ARRAY_SIZE(arr)

Definition at line 562 of file BLI_path_utils_test.cc.

◆ JOIN_FORWARD_SLASH

#define JOIN_FORWARD_SLASH ( str_expect,
out_size,
... )
Value:
{ \
const char *expect = str_expect; \
char result[(out_size) + 1024]; \
/* Check we don't write past the last byte. */ \
result[out_size] = '\0'; \
BLI_path_join(result, out_size, __VA_ARGS__); \
EXPECT_STREQ(result, expect); \
EXPECT_EQ(result[out_size], '\0'); \
} \
((void)0)

Definition at line 547 of file BLI_path_utils_test.cc.

◆ NORMALIZE

#define NORMALIZE ( input,
output_expect )
Value:
{ \
char path[FILE_MAX] = input; \
if (SEP == '\\') { \
str_replace_char_with_relative_exception(path, '/', '\\'); \
} \
const int path_len_test = BLI_path_normalize(path); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
} \
EXPECT_STREQ(path, output_expect); \
EXPECT_EQ(path_len_test, strlen(path)); \
} \
((void)0)
#define FILE_MAX
int BLI_path_normalize(char *path) ATTR_NONNULL(1)

Definition at line 50 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ PARENT_DIR

#define PARENT_DIR ( input,
output_expect )
Value:
{ \
char path[FILE_MAX] = input; \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
} \
BLI_path_parent_dir(path); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
} \
EXPECT_STREQ(path, output_expect); \
} \
((void)0)

Definition at line 192 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ PATH_EXTENSION_CHECK

#define PATH_EXTENSION_CHECK ( input_path,
input_ext,
expect_ext )
Value:
{ \
const bool ret = BLI_path_extension_check(input_path, input_ext); \
if (STREQ(input_ext, expect_ext)) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
} \
((void)0)
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
#define STREQ(a, b)

Definition at line 944 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_EXTENSION_ENSURE

#define PATH_EXTENSION_ENSURE ( input_path,
input_ext,
expect_result,
expect_path )    PATH_EXTENSION_ENSURE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, FILE_MAX)

Definition at line 1075 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_EXTENSION_ENSURE_WITH_MAXLEN

#define PATH_EXTENSION_ENSURE_WITH_MAXLEN ( input_path,
input_ext,
expect_result,
expect_path,
maxlen )
Value:
{ \
BLI_assert(maxlen <= FILE_MAX); \
char path[FILE_MAX]; \
STRNCPY(path, input_path); \
const bool ret = BLI_path_extension_ensure(path, maxlen, input_ext); \
if (expect_result) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
EXPECT_STREQ(path, expect_path); \
} \
((void)0)
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1

Definition at line 1058 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_EXTENSION_REPLACE

#define PATH_EXTENSION_REPLACE ( input_path,
input_ext,
expect_result,
expect_path )    PATH_EXTENSION_REPLACE_WITH_MAXLEN(input_path, input_ext, expect_result, expect_path, FILE_MAX)

Definition at line 1004 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_EXTENSION_REPLACE_WITH_MAXLEN

#define PATH_EXTENSION_REPLACE_WITH_MAXLEN ( input_path,
input_ext,
expect_result,
expect_path,
maxlen )
Value:
{ \
BLI_assert(maxlen <= FILE_MAX); \
char path[FILE_MAX]; \
STRNCPY(path, input_path); \
const bool ret = BLI_path_extension_replace(path, maxlen, input_ext); \
if (expect_result) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
EXPECT_STREQ(path, expect_path); \
} \
((void)0)
bool BLI_path_extension_replace(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1

Definition at line 987 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_FRAME_CHECK_CHARS

#define PATH_FRAME_CHECK_CHARS ( input_path,
expect_hasChars )
Value:
{ \
const bool ret = BLI_path_frame_check_chars(input_path); \
if (expect_hasChars) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
} \
((void)0)
bool void bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT

Definition at line 1123 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_FRAME_GET

#define PATH_FRAME_GET ( input_path,
expect_frame,
expect_numdigits,
expect_pathisvalid )
Value:
{ \
char path[FILE_MAX]; \
int out_frame = -1, out_numdigits = -1; \
STRNCPY(path, input_path); \
const bool ret = BLI_path_frame_get(path, &out_frame, &out_numdigits); \
if (expect_pathisvalid) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
EXPECT_EQ(out_frame, expect_frame); \
EXPECT_EQ(out_numdigits, expect_numdigits); \
} \
((void)0)
bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1

Definition at line 1197 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_FRAME_RANGE

#define PATH_FRAME_RANGE ( input_path,
sta,
end,
digits,
expect_outpath )
Value:
{ \
char path[FILE_MAX]; \
bool ret; \
STRNCPY(path, input_path); \
ret = BLI_path_frame_range(path, sizeof(path), sta, end, digits); \
if (expect_outpath == nullptr) { \
EXPECT_FALSE(ret); \
} \
else { \
EXPECT_TRUE(ret); \
EXPECT_STREQ(path, expect_outpath); \
} \
} \
((void)0)
bool BLI_path_frame_range(char *path, size_t path_maxncpy, int sta, int end, int digits) ATTR_NONNULL(1)

Definition at line 1160 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_FRAME_STRIP

#define PATH_FRAME_STRIP ( input_path,
expect_path,
expect_ext )
Value:
{ \
char path[FILE_MAX]; \
char ext[FILE_MAX]; \
STRNCPY(path, (input_path)); \
BLI_path_frame_strip(path, ext, sizeof(ext)); \
EXPECT_STREQ(path, expect_path); \
EXPECT_STREQ(ext, expect_ext); \
} \
((void)0)

Definition at line 885 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_REL

#define PATH_REL ( abs_path,
ref_path,
rel_path_expect )
Value:
{ \
char path[FILE_MAX]; \
const char *ref_path_test = ref_path; \
STRNCPY(path, abs_path); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
ref_path_test = str_replace_char_strdup(ref_path_test, '/', '\\'); \
} \
BLI_path_rel(path, ref_path_test); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
free((void *)ref_path_test); \
} \
EXPECT_STREQ(path, rel_path_expect); \
} \
void(0)
static char * str_replace_char_strdup(const char *str, char src, char dst)

Definition at line 1550 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ PATH_SEQ_DECODE

#define PATH_SEQ_DECODE ( path_literal,
expect_result,
expect_head,
expect_tail,
expect_numdigits )
Value:
{ \
const char *path = path_literal; \
char head[FILE_MAX]; \
char tail[FILE_MAX]; \
ushort numdigits = 0; \
const int result = BLI_path_sequence_decode( \
path, head, sizeof(head), tail, sizeof(tail), &numdigits); \
EXPECT_EQ(result, expect_result); \
EXPECT_STREQ(head, expect_head); \
EXPECT_STREQ(tail, expect_tail); \
EXPECT_EQ(numdigits, expect_numdigits); \
} \
(void)0;
int BLI_path_sequence_decode(const char *path, char *head, size_t head_maxncpy, char *tail, size_t tail_maxncpy, unsigned short *r_digits_len)
Definition path_utils.cc:57
unsigned short ushort

Definition at line 1231 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_ENSURE

#define PATH_SLASH_ENSURE ( input,
size,
output_expect,
length_expect )
Value:
{ \
char path[size] = input; \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
} \
int result = BLI_path_slash_ensure(path, size); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
} \
EXPECT_STREQ(path, output_expect); \
EXPECT_EQ(result, length_expect); \
} \
((void)0)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)

Definition at line 1374 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_FIND

#define PATH_SLASH_FIND ( path,
expect_index )
Value:
{ \
const char *result = BLI_path_slash_find(path); \
EXPECT_EQ(result, &path[expect_index]); \
} \
(void)0;
const char * BLI_path_slash_find(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT

Definition at line 1310 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_NATIVE

#define PATH_SLASH_NATIVE ( input,
expected )
Value:
{ \
char path[FILE_MAX] = input; \
BLI_path_slash_native(path); \
EXPECT_STREQ(path, expected); \
} \
((void)0)

Definition at line 1483 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_RFIND

#define PATH_SLASH_RFIND ( path,
expect_index )
Value:
{ \
const char *result = BLI_path_slash_rfind(path); \
EXPECT_STREQ(result, &path[expect_index]); \
} \
(void)0;
const char * BLI_path_slash_rfind(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT

Definition at line 1341 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_RSTRIP

#define PATH_SLASH_RSTRIP ( input,
expected )
Value:
{ \
char path[FILE_MAX] = input; \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
} \
BLI_path_slash_rstrip(path); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
} \
EXPECT_STREQ(path, expected); \
} \
((void)0)

Definition at line 1412 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SLASH_SKIP

#define PATH_SLASH_SKIP ( input,
expected )
Value:
{ \
char path[FILE_MAX] = input; \
if (SEP == '\\') { \
BLI_string_replace_char(path, '/', '\\'); \
} \
const char *skipped = BLI_path_slash_skip(path); \
if (SEP == '\\') { \
BLI_string_replace_char(path, '\\', '/'); \
} \
EXPECT_STREQ(skipped, expected); \
} \
((void)0)
const char * BLI_path_slash_skip(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT

Definition at line 1448 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ PATH_SUFFIX

#define PATH_SUFFIX ( path_literal,
path_literal_max,
sep,
suffix,
expect_result,
expect_path )
Value:
{ \
char path[FILE_MAX] = path_literal; \
const bool result = BLI_path_suffix(path, path_literal_max, suffix, sep); \
EXPECT_EQ(result, expect_result); \
EXPECT_STREQ(path, expect_path); \
} \
(void)0;
bool bool BLI_path_suffix(char *path, size_t path_maxncpy, const char *suffix, const char *sep) ATTR_NONNULL(1

Definition at line 1268 of file BLI_path_utils_test.cc.

Referenced by TEST().

◆ TEST_STR [1/2]

#define TEST_STR   "./a/./b/./c/."

Definition at line 349 of file BLI_path_utils_test.cc.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ TEST_STR [2/2]

#define TEST_STR   ".//a//.//b//.//c//.//"

Definition at line 349 of file BLI_path_utils_test.cc.

Function Documentation

◆ str_replace_char_strdup()

static char * str_replace_char_strdup ( const char * str,
char src,
char dst )
static

Definition at line 34 of file BLI_path_utils_test.cc.

References BLI_string_replace_char(), and str.

◆ str_replace_char_with_relative_exception()

static void str_replace_char_with_relative_exception ( char * str,
char src,
char dst )
static

Definition at line 20 of file BLI_path_utils_test.cc.

References BLI_string_replace_char(), and str.

◆ TEST() [1/72]

TEST ( path_util ,
SlashEnsure  )

Definition at line 1389 of file BLI_path_utils_test.cc.

References FILE_MAX, and PATH_SLASH_ENSURE.

◆ TEST() [2/72]

TEST ( path_util ,
SlashFind  )

Definition at line 1317 of file BLI_path_utils_test.cc.

References BLI_path_slash_find(), EXPECT_EQ(), and PATH_SLASH_FIND.

◆ TEST() [3/72]

TEST ( path_util ,
SlashNative  )

Definition at line 1491 of file BLI_path_utils_test.cc.

References PATH_SLASH_NATIVE.

◆ TEST() [4/72]

TEST ( path_util ,
SlashRFind  )

Definition at line 1348 of file BLI_path_utils_test.cc.

References BLI_path_slash_rfind(), EXPECT_EQ(), and PATH_SLASH_RFIND.

◆ TEST() [5/72]

TEST ( path_util ,
SlashRStrip  )

Definition at line 1426 of file BLI_path_utils_test.cc.

References PATH_SLASH_RSTRIP.

◆ TEST() [6/72]

TEST ( path_util ,
SlashSkip  )

Definition at line 1462 of file BLI_path_utils_test.cc.

References PATH_SLASH_SKIP.

◆ TEST() [7/72]

TEST ( path_utils ,
AppendFile  )

Definition at line 711 of file BLI_path_utils_test.cc.

References APPEND.

◆ TEST() [8/72]

TEST ( path_utils ,
AppendFile_Truncate  )

Definition at line 717 of file BLI_path_utils_test.cc.

References APPEND.

◆ TEST() [9/72]

TEST ( path_utils ,
CompareNormalized  )

Definition at line 174 of file BLI_path_utils_test.cc.

References BLI_path_cmp_normalized(), and EXPECT_EQ().

◆ TEST() [10/72]

TEST ( path_utils ,
Contains  )

Definition at line 1683 of file BLI_path_utils_test.cc.

References BLI_path_contains().

◆ TEST() [11/72]

TEST ( path_utils ,
Extension  )

Definition at line 913 of file BLI_path_utils_test.cc.

References BLI_path_extension(), and EXPECT_EQ().

◆ TEST() [12/72]

TEST ( path_utils ,
ExtensionCheck  )

Definition at line 956 of file BLI_path_utils_test.cc.

References PATH_EXTENSION_CHECK.

◆ TEST() [13/72]

TEST ( path_utils ,
ExtensionEnsure  )

Definition at line 1078 of file BLI_path_utils_test.cc.

References PATH_EXTENSION_ENSURE.

◆ TEST() [14/72]

TEST ( path_utils ,
ExtensionEnsure_Overflow  )

Definition at line 1104 of file BLI_path_utils_test.cc.

References PATH_EXTENSION_ENSURE_WITH_MAXLEN.

◆ TEST() [15/72]

TEST ( path_utils ,
ExtensionReplace  )

Definition at line 1007 of file BLI_path_utils_test.cc.

References PATH_EXTENSION_REPLACE.

◆ TEST() [16/72]

TEST ( path_utils ,
ExtensionReplace_Overflow  )

Definition at line 1036 of file BLI_path_utils_test.cc.

References PATH_EXTENSION_REPLACE_WITH_MAXLEN.

◆ TEST() [17/72]

TEST ( path_utils ,
Frame  )

Definition at line 733 of file BLI_path_utils_test.cc.

References BLI_path_frame(), BLI_str_endswith(), FILE_MAX, and ret.

◆ TEST() [18/72]

TEST ( path_utils ,
FrameCheckChars  )

Definition at line 1135 of file BLI_path_utils_test.cc.

References PATH_FRAME_CHECK_CHARS.

◆ TEST() [19/72]

TEST ( path_utils ,
FrameGet  )

Definition at line 1214 of file BLI_path_utils_test.cc.

References PATH_FRAME_GET.

◆ TEST() [20/72]

TEST ( path_utils ,
FrameRange  )

Definition at line 1176 of file BLI_path_utils_test.cc.

References PATH_FRAME_RANGE.

◆ TEST() [21/72]

TEST ( path_utils ,
FrameStrip  )

Definition at line 896 of file BLI_path_utils_test.cc.

References PATH_FRAME_STRIP.

◆ TEST() [22/72]

TEST ( path_utils ,
HasHiddenComponents  )

Definition at line 1719 of file BLI_path_utils_test.cc.

References BLI_path_has_hidden_component().

◆ TEST() [23/72]

TEST ( path_utils ,
IsUnc  )

Definition at line 451 of file BLI_path_utils_test.cc.

References BLI_path_is_unc().

◆ TEST() [24/72]

TEST ( path_utils ,
IsWin32Drive  )

Definition at line 471 of file BLI_path_utils_test.cc.

References BLI_path_is_win32_drive().

◆ TEST() [25/72]

TEST ( path_utils ,
IsWin32DriveOnly  )

Definition at line 496 of file BLI_path_utils_test.cc.

References BLI_path_is_win32_drive_only().

◆ TEST() [26/72]

TEST ( path_utils ,
IsWin32DriveWithSlash  )

Definition at line 522 of file BLI_path_utils_test.cc.

References BLI_path_is_win32_drive_with_slash().

◆ TEST() [27/72]

TEST ( path_utils ,
JoinComplex  )

Definition at line 668 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [28/72]

TEST ( path_utils ,
JoinNop  )

Definition at line 593 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [29/72]

TEST ( path_utils ,
JoinRelativePrefix  )

Definition at line 675 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [30/72]

TEST ( path_utils ,
JoinSingle  )

Definition at line 604 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [31/72]

TEST ( path_utils ,
JoinTriple  )

Definition at line 616 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [32/72]

TEST ( path_utils ,
JoinTruncateLong  )

Definition at line 648 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [33/72]

TEST ( path_utils ,
JoinTruncateShort  )

Definition at line 631 of file BLI_path_utils_test.cc.

References JOIN.

◆ TEST() [34/72]

TEST ( path_utils ,
NameAtIndex_Double  )

Definition at line 301 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [35/72]

TEST ( path_utils ,
NameAtIndex_DoublNeg  )

Definition at line 315 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [36/72]

TEST ( path_utils ,
NameAtIndex_Misc  )

Definition at line 329 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [37/72]

TEST ( path_utils ,
NameAtIndex_MiscComplex  )

Definition at line 407 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [38/72]

TEST ( path_utils ,
NameAtIndex_MiscComplexNeg  )

Definition at line 417 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [39/72]

TEST ( path_utils ,
NameAtIndex_MiscNeg  )

Definition at line 339 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [40/72]

TEST ( path_utils ,
NameAtIndex_NoneComplex  )

Definition at line 427 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [41/72]

TEST ( path_utils ,
NameAtIndex_NoneComplexNeg  )

Definition at line 435 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [42/72]

TEST ( path_utils ,
NameAtIndex_Single  )

Definition at line 274 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [43/72]

TEST ( path_utils ,
NameAtIndex_SingleDot  )

Definition at line 351 of file BLI_path_utils_test.cc.

References AT_INDEX, and TEST_STR.

◆ TEST() [44/72]

TEST ( path_utils ,
NameAtIndex_SingleDotDoubleSlash  )

Definition at line 373 of file BLI_path_utils_test.cc.

References AT_INDEX, and TEST_STR.

◆ TEST() [45/72]

TEST ( path_utils ,
NameAtIndex_SingleDotDoubleSlashNeg  )

Definition at line 382 of file BLI_path_utils_test.cc.

References AT_INDEX, and TEST_STR.

◆ TEST() [46/72]

TEST ( path_utils ,
NameAtIndex_SingleDotNeg  )

Definition at line 360 of file BLI_path_utils_test.cc.

References AT_INDEX, and TEST_STR.

◆ TEST() [47/72]

TEST ( path_utils ,
NameAtIndex_SingleDotSeries  )

Definition at line 393 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [48/72]

TEST ( path_utils ,
NameAtIndex_SingleDotSeriesNeg  )

Definition at line 400 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [49/72]

TEST ( path_utils ,
NameAtIndex_SingleNeg  )

Definition at line 287 of file BLI_path_utils_test.cc.

References AT_INDEX.

◆ TEST() [50/72]

TEST ( path_utils ,
Normalize_ComplexAbsolute  )

Definition at line 93 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [51/72]

TEST ( path_utils ,
Normalize_ComplexRelative  )

Definition at line 98 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [52/72]

TEST ( path_utils ,
Normalize_Dot  )

Definition at line 85 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [53/72]

TEST ( path_utils ,
Normalize_DoubleSlash  )

Definition at line 104 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [54/72]

TEST ( path_utils ,
Normalize_Nop  )

Definition at line 66 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [55/72]

TEST ( path_utils ,
Normalize_NopRelative  )

Definition at line 75 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [56/72]

TEST ( path_utils ,
Normalize_Parent  )

Definition at line 112 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [57/72]

TEST ( path_utils ,
Normalize_UnbalancedAbsolute  )

Definition at line 118 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [58/72]

TEST ( path_utils ,
Normalize_UnbalancedRelative  )

Definition at line 132 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [59/72]

TEST ( path_utils ,
Normalize_UnbalancedRelativeTrailing  )

Definition at line 149 of file BLI_path_utils_test.cc.

References NORMALIZE.

◆ TEST() [60/72]

TEST ( path_utils ,
ParentDir_Complex  )

Definition at line 236 of file BLI_path_utils_test.cc.

References PARENT_DIR.

◆ TEST() [61/72]

TEST ( path_utils ,
ParentDir_NOP  )

Definition at line 213 of file BLI_path_utils_test.cc.

References PARENT_DIR.

◆ TEST() [62/72]

TEST ( path_utils ,
ParentDir_Simple  )

Definition at line 206 of file BLI_path_utils_test.cc.

References PARENT_DIR.

◆ TEST() [63/72]

TEST ( path_utils ,
ParentDir_TrailingPeriod  )

Definition at line 223 of file BLI_path_utils_test.cc.

References PARENT_DIR.

◆ TEST() [64/72]

TEST ( path_utils ,
PathIsAbsFromCwd  )

Definition at line 1648 of file BLI_path_utils_test.cc.

References BLI_path_is_abs_from_cwd().

◆ TEST() [65/72]

TEST ( path_utils ,
PathIsRel  )

Definition at line 1626 of file BLI_path_utils_test.cc.

References BLI_path_is_rel().

◆ TEST() [66/72]

TEST ( path_utils ,
RelPath_BufferOverflowRoot  )

Definition at line 1584 of file BLI_path_utils_test.cc.

References ABS_PREFIX, FILE_MAX, PATH_REL, and STRNCPY_RLEN.

◆ TEST() [67/72]

TEST ( path_utils ,
RelPath_BufferOverflowSubdir  )

Definition at line 1600 of file BLI_path_utils_test.cc.

References ABS_PREFIX, FILE_MAX, int, PATH_REL, and STRNCPY_RLEN.

◆ TEST() [68/72]

TEST ( path_utils ,
RelPath_Simple  )

Definition at line 1574 of file BLI_path_utils_test.cc.

References ABS_PREFIX, and PATH_REL.

◆ TEST() [69/72]

TEST ( path_utils ,
RelPath_SimpleSubdir  )

Definition at line 1579 of file BLI_path_utils_test.cc.

References ABS_PREFIX, and PATH_REL.

◆ TEST() [70/72]

TEST ( path_utils ,
SequenceDecode  )

Definition at line 1246 of file BLI_path_utils_test.cc.

References PATH_SEQ_DECODE.

◆ TEST() [71/72]

TEST ( path_utils ,
SplitDirfile  )

Definition at line 824 of file BLI_path_utils_test.cc.

References BLI_path_split_dir_file(), and FILE_MAX.

◆ TEST() [72/72]

TEST ( path_utils ,
Suffix  )

Definition at line 1277 of file BLI_path_utils_test.cc.

References FILE_MAX, and PATH_SUFFIX.