Blender  V3.3
Macros | Functions
BLI_path_util_test.cc File Reference
#include "testing/testing.h"
#include "IMB_imbuf.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"

Go to the source code of this file.

Macros

#define AT_INDEX(str_input, index_input, str_expect)
 
#define JOIN(str_expect, out_size, ...)
 
#define PATH_FRAME_STRIP(input_path, expect_path, expect_ext)
 
#define PATH_EXTENSION_CHECK(input_path, input_ext, expect_ext)
 
#define PATH_FRAME_CHECK_CHARS(input_path, expect_hasChars)
 
#define PATH_FRAME_RANGE(input_path, sta, end, digits, expect_outpath)
 
#define PATH_FRAME_GET(input_path, expect_frame, expect_numdigits, expect_pathisvalid)
 
#define PATH_REL(abs_path, ref_path, rel_path)
 

Functions

 TEST (path_util, Clean)
 
 TEST (path_util, NameAtIndex_Single)
 
 TEST (path_util, NameAtIndex_SingleNeg)
 
 TEST (path_util, NameAtIndex_Double)
 
 TEST (path_util, NameAtIndex_DoublNeg)
 
 TEST (path_util, NameAtIndex_Misc)
 
 TEST (path_util, NameAtIndex_MiscNeg)
 
 TEST (path_util, NameAtIndex_MiscComplex)
 
 TEST (path_util, NameAtIndex_MiscComplexNeg)
 
 TEST (path_util, NameAtIndex_NoneComplex)
 
 TEST (path_util, NameAtIndex_NoneComplexNeg)
 
 TEST (path_util, JoinNop)
 
 TEST (path_util, JoinSingle)
 
 TEST (path_util, JoinTriple)
 
 TEST (path_util, JoinTruncateShort)
 
 TEST (path_util, JoinTruncateLong)
 
 TEST (path_util, JoinComplex)
 
 TEST (path_util, Frame)
 
 TEST (path_util, SplitDirfile)
 
 TEST (path_util, PathFrameStrip)
 
 TEST (path_util, PathExtensionCheck)
 
 TEST (path_util, PathFrameCheckChars)
 
 TEST (path_util, PathFrameRange)
 
 TEST (path_util, PathFrameGet)
 
 TEST (path_util, PathExtension)
 
 TEST (path_util, PathRelPath)
 
 TEST (path_util, PathContains)
 

Macro Definition Documentation

◆ AT_INDEX

#define AT_INDEX (   str_input,
  index_input,
  str_expect 
)
Value:
{ \
char path[] = str_input; \
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 == NULL) { \
EXPECT_FALSE(ret); \
} \
else { \
EXPECT_TRUE(ret); \
EXPECT_EQ(strlen(expect), len_output); \
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() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1659
SyclQueue void void size_t num_bytes void
return ret

Definition at line 72 of file BLI_path_util_test.cc.

◆ JOIN

#define JOIN (   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__, NULL); \
/* simplify expected string */ \
BLI_str_replace_char(result, '\\', '/'); \
EXPECT_STREQ(result, expect); \
EXPECT_EQ(result[out_size], '\0'); \
} \
((void)0)

Definition at line 204 of file BLI_path_util_test.cc.

◆ 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 (strcmp(input_ext, expect_ext) == 0) { \
EXPECT_TRUE(ret); \
} \
else { \
EXPECT_FALSE(ret); \
} \
} \
((void)0)
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1299

Definition at line 459 of file BLI_path_util_test.cc.

◆ 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 BLI_path_frame_check_chars(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:853

Definition at line 497 of file BLI_path_util_test.cc.

◆ 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; \
BLI_strncpy(path, input_path, FILE_MAX); \
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)
#define FILE_MAX
bool BLI_path_frame_get(char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL()
Definition: path_util.c:753

Definition at line 561 of file BLI_path_util_test.cc.

◆ PATH_FRAME_RANGE

#define PATH_FRAME_RANGE (   input_path,
  sta,
  end,
  digits,
  expect_outpath 
)
Value:
{ \
char path[FILE_MAX]; \
bool ret; \
BLI_strncpy(path, input_path, FILE_MAX); \
ret = BLI_path_frame_range(path, sta, end, digits); \
if (expect_outpath == NULL) { \
EXPECT_FALSE(ret); \
} \
else { \
EXPECT_TRUE(ret); \
EXPECT_STREQ(path, expect_outpath); \
} \
} \
((void)0)
bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL()
Definition: path_util.c:727

Definition at line 529 of file BLI_path_util_test.cc.

◆ PATH_FRAME_STRIP

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

Definition at line 436 of file BLI_path_util_test.cc.

◆ PATH_REL

#define PATH_REL (   abs_path,
  ref_path,
  rel_path 
)
Value:
{ \
char path[FILE_MAX]; \
BLI_strncpy(path, abs_path, sizeof(path)); \
BLI_path_rel(path, ref_path); \
EXPECT_STREQ(rel_path, path); \
} \
void(0)

Definition at line 607 of file BLI_path_util_test.cc.

Function Documentation

◆ TEST() [1/27]

TEST ( path_util  ,
Clean   
)

Definition at line 16 of file BLI_path_util_test.cc.

References BLI_path_normalize(), and FILE_MAX.

◆ TEST() [2/27]

TEST ( path_util  ,
Frame   
)

Definition at line 304 of file BLI_path_util_test.cc.

References BLI_path_frame(), FILE_MAX, and ret.

◆ TEST() [3/27]

TEST ( path_util  ,
JoinComplex   
)

Definition at line 294 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [4/27]

TEST ( path_util  ,
JoinNop   
)

Definition at line 219 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [5/27]

TEST ( path_util  ,
JoinSingle   
)

Definition at line 230 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [6/27]

TEST ( path_util  ,
JoinTriple   
)

Definition at line 242 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [7/27]

TEST ( path_util  ,
JoinTruncateLong   
)

Definition at line 274 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [8/27]

TEST ( path_util  ,
JoinTruncateShort   
)

Definition at line 257 of file BLI_path_util_test.cc.

References JOIN.

◆ TEST() [9/27]

TEST ( path_util  ,
NameAtIndex_Double   
)

Definition at line 118 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [10/27]

TEST ( path_util  ,
NameAtIndex_DoublNeg   
)

Definition at line 132 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [11/27]

TEST ( path_util  ,
NameAtIndex_Misc   
)

Definition at line 146 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [12/27]

TEST ( path_util  ,
NameAtIndex_MiscComplex   
)

Definition at line 166 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [13/27]

TEST ( path_util  ,
NameAtIndex_MiscComplexNeg   
)

Definition at line 176 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [14/27]

TEST ( path_util  ,
NameAtIndex_MiscNeg   
)

Definition at line 156 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [15/27]

TEST ( path_util  ,
NameAtIndex_NoneComplex   
)

Definition at line 186 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [16/27]

TEST ( path_util  ,
NameAtIndex_NoneComplexNeg   
)

Definition at line 194 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [17/27]

TEST ( path_util  ,
NameAtIndex_Single   
)

Definition at line 91 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [18/27]

TEST ( path_util  ,
NameAtIndex_SingleNeg   
)

Definition at line 104 of file BLI_path_util_test.cc.

References AT_INDEX.

◆ TEST() [19/27]

TEST ( path_util  ,
PathContains   
)

Definition at line 660 of file BLI_path_util_test.cc.

References BLI_path_contains().

◆ TEST() [20/27]

TEST ( path_util  ,
PathExtension   
)

Definition at line 591 of file BLI_path_util_test.cc.

References BLI_path_extension(), and EXPECT_EQ().

◆ TEST() [21/27]

TEST ( path_util  ,
PathExtensionCheck   
)

Definition at line 472 of file BLI_path_util_test.cc.

References PATH_EXTENSION_CHECK.

◆ TEST() [22/27]

TEST ( path_util  ,
PathFrameCheckChars   
)

Definition at line 510 of file BLI_path_util_test.cc.

References PATH_FRAME_CHECK_CHARS.

◆ TEST() [23/27]

TEST ( path_util  ,
PathFrameGet   
)

Definition at line 579 of file BLI_path_util_test.cc.

References PATH_FRAME_GET.

◆ TEST() [24/27]

TEST ( path_util  ,
PathFrameRange   
)

Definition at line 546 of file BLI_path_util_test.cc.

References PATH_FRAME_RANGE.

◆ TEST() [25/27]

TEST ( path_util  ,
PathFrameStrip   
)

Definition at line 448 of file BLI_path_util_test.cc.

References PATH_FRAME_STRIP.

◆ TEST() [26/27]

TEST ( path_util  ,
PathRelPath   
)

Definition at line 616 of file BLI_path_util_test.cc.

References FILE_MAX, and PATH_REL.

◆ TEST() [27/27]

TEST ( path_util  ,
SplitDirfile   
)

Definition at line 381 of file BLI_path_util_test.cc.

References BLI_split_dirfile(), file, and FILE_MAX.