Blender V5.3
BLI_string_test.cc File Reference
#include "testing/testing.h"
#include <array>
#include <initializer_list>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "MEM_guardedalloc.h"
#include "BLI_string.hh"
#include "BLI_string_utf8.hh"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.hh"

Go to the source code of this file.

Classes

struct  blender::WordInfo
class  blender::StringFindSplitWords
class  blender::StringCasecmpNatural
class  blender::StringEscape

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define STR_N_CAT(dst_init, dst_size, src, result_expect)
#define STRNCPY_ENSURE_PAD_EXPECT(src, dst_expect, dst_maxncpy)
#define STR_REPLACE_RANGE(src, size, beg, end, dst, result_expect)
#define STR_ESCAPE_TRUNC_EXPECT(src, dst_expect, dst_maxncpy)
#define STR_UNESCAPE_EXPECT(src, dst_expect, src_len)

Functions

 blender::TEST (BLI_string, bounded_strcpy)
 blender::TEST (BLI_string, StartsWith)
 blender::TEST (BLI_string, EndsWith)
String Concatenate
 blender::TEST (string, StrCat)
String Copy (Ensure Pad)
 blender::TEST (string, StrCopyEnsurePad)
String Replace
 blender::TEST (string, StrReplaceRange)
String Partition
 blender::TEST (string, StrPartition)
 blender::TEST (string, StrRPartition)
 blender::TEST (string, StrPartitionEx)
 blender::TEST (string, StrPartitionUtf8)
 blender::TEST (string, StrRPartitionUtf8)
 blender::TEST (string, StrPartitionExUtf8)
String Format Integer (Grouped)
 blender::TEST (string, StrFormatIntGrouped)
 blender::TEST (string, StrFormatUint64Grouped)
String Format Byte Units
 blender::TEST (string, StrFormatByteUnits)
 blender::TEST (string, StrFormatByteUnitsCompact)
String Format Decimal Units
 blender::TEST (string, StrFormatDecimalUnits)
 blender::TEST (string, StrFormatIntegerUnits)
String Length (Clamped)
 blender::TEST (string, StringNLen)
String Find Split Words
static std::ostream & blender::operator<< (std::ostream &os, const WordInfo &word_info)
 blender::TEST_F (StringFindSplitWords, Simple)
 blender::TEST_F (StringFindSplitWords, Triple)
 blender::TEST_F (StringFindSplitWords, Spacing)
 blender::TEST_F (StringFindSplitWords, Trailing_Left)
 blender::TEST_F (StringFindSplitWords, Trailing_Right)
 blender::TEST_F (StringFindSplitWords, Trailing_LeftRight)
 blender::TEST_F (StringFindSplitWords, Blank)
 blender::TEST_F (StringFindSplitWords, Whitespace)
 blender::TEST_F (StringFindSplitWords, LimitWords)
 blender::TEST_F (StringFindSplitWords, LimitChars)
String Element
 blender::TEST (string, StringElemEmpty)
 blender::TEST (string, StringElemSingle)
 blender::TEST (string, StringElemComplex)
String Search (Case Insensitive)
 blender::TEST (string, StringStrncasestr)
String Maximum Word Count
 blender::TEST (string, StringMaxPossibleWordCount)
String is Decimal
 blender::TEST (string, StrIsDecimal)
String Case Insensitive Comparison
 blender::TEST_F (StringCasecmpNatural, Empty)
 blender::TEST_F (StringCasecmpNatural, Whitespace)
 blender::TEST_F (StringCasecmpNatural, TextOnlyLowerCase)
 blender::TEST_F (StringCasecmpNatural, TextMixedCase)
 blender::TEST_F (StringCasecmpNatural, Period)
 blender::TEST_F (StringCasecmpNatural, OnlyNumbers)
 blender::TEST_F (StringCasecmpNatural, TextAndNumbers)
String Escape/Un-Escape
 blender::TEST_F (StringEscape, Simple)
 blender::TEST_F (StringEscape, Control)
 blender::TEST_F (StringEscape, Truncate)
 blender::TEST_F (StringEscape, UnescapeTrailingBackslash)
 blender::TEST_F (StringEscape, UnescapeLen)

String Join

#define BUFFER_SIZE   128
static void blender::string_join_array_test_truncate (const char *strings[], int strings_num, char buffer[BUFFER_SIZE])
static void blender::string_join_array_with_sep_char_test_truncate (const char *strings[], int strings_num, char buffer[BUFFER_SIZE])
 blender::TEST (string, StrJoin_Truncate)

Macro Definition Documentation

◆ BUFFER_SIZE

◆ STR_ESCAPE_TRUNC_EXPECT

#define STR_ESCAPE_TRUNC_EXPECT ( src,
dst_expect,
dst_maxncpy )
Value:
{ \
char dst[dst_maxncpy + 1]; \
dst[dst_maxncpy] = 0xff; \
size_t len = BLI_str_escape(dst, src, dst_maxncpy); \
EXPECT_EQ(len, strlen(dst)); \
EXPECT_STREQ(dst, dst_expect); \
EXPECT_EQ(dst[dst_maxncpy], 0xff); \
}
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263

Referenced by blender::TEST_F().

◆ STR_N_CAT

#define STR_N_CAT ( dst_init,
dst_size,
src,
result_expect )
Value:
{ \
char dst[dst_size + 1] = dst_init; \
dst[dst_size] = 0xff; \
BLI_strncat(dst, src, dst_size); \
EXPECT_STREQ(dst, result_expect); \
EXPECT_EQ(dst[dst_size], 0xff); \
}

Referenced by blender::TEST().

◆ STR_REPLACE_RANGE

#define STR_REPLACE_RANGE ( src,
size,
beg,
end,
dst,
result_expect )
Value:
{ \
char string[size] = src; \
BLI_string_replace_range(string, sizeof(string), beg, end, dst); \
EXPECT_STREQ(string, result_expect); \
}

Referenced by blender::TEST().

◆ STR_UNESCAPE_EXPECT

#define STR_UNESCAPE_EXPECT ( src,
dst_expect,
src_len )
Value:
{ \
char dst[src_len + 2]; \
dst[src_len + 1] = 0xff; \
size_t len = BLI_str_unescape(dst, src, src_len); \
EXPECT_EQ(len, strlen(dst)); \
EXPECT_STREQ(dst, dst_expect); \
EXPECT_EQ(dst[src_len + 1], 0xff); \
}

Referenced by blender::TEST_F().

◆ STRNCPY_ENSURE_PAD_EXPECT

#define STRNCPY_ENSURE_PAD_EXPECT ( src,
dst_expect,
dst_maxncpy )
Value:
{ \
char dst[dst_maxncpy + 5]; \
memset(dst, 0xff, sizeof(dst)); \
dst[sizeof(dst) - 1] = '\0'; \
BLI_strncpy_ensure_pad(dst, src, '*', dst_maxncpy); \
EXPECT_STREQ(dst, dst_expect); \
EXPECT_STREQ(dst + dst_maxncpy, "\xff\xff\xff\xff"); \
}

Referenced by blender::TEST().