9#include "testing/testing.h"
15TEST(string_ref_null, DefaultConstructor)
22TEST(string_ref_null, CStringConstructor)
24 const char *
str =
"Hello";
30TEST(string_ref_null, CStringLengthConstructor)
32 const char *
str =
"Hello";
38TEST(string_ref_null, CompareEqual)
43 EXPECT_TRUE(ref1 == ref2);
44 EXPECT_FALSE(ref1 == ref3);
45 EXPECT_TRUE(ref1 != ref3);
46 EXPECT_FALSE(ref1 != ref2);
49TEST(string_ref_null, CompareEqualCharPtr1)
52 EXPECT_TRUE(ref ==
"test");
53 EXPECT_FALSE(ref ==
"other");
54 EXPECT_TRUE(ref !=
"other");
55 EXPECT_FALSE(ref !=
"test");
58TEST(string_ref_null, CompareEqualCharPtr2)
61 EXPECT_TRUE(
"test" == ref);
62 EXPECT_FALSE(
"other" == ref);
63 EXPECT_TRUE(ref !=
"other");
64 EXPECT_FALSE(ref !=
"test");
67TEST(string_ref_null, CompareEqualString1)
70 EXPECT_TRUE(ref == std::string(
"test"));
71 EXPECT_FALSE(ref == std::string(
"other"));
72 EXPECT_TRUE(ref != std::string(
"other"));
73 EXPECT_FALSE(ref != std::string(
"test"));
76TEST(string_ref_null, CompareEqualString2)
79 EXPECT_TRUE(std::string(
"test") == ref);
80 EXPECT_FALSE(std::string(
"other") == ref);
81 EXPECT_TRUE(std::string(
"other") != ref);
82 EXPECT_FALSE(std::string(
"test") != ref);
85TEST(string_ref_null, CompareEqualStringRef1)
94TEST(string_ref_null, CompareEqualStringRef2)
103TEST(string_ref_null, Constexpr)
108 std::array<int, std::size_t(sref.
find_first_of(
'o'))> compiles = {1};
112TEST(string_ref, DefaultConstructor)
118TEST(string_ref, StartEndConstructor)
120 const char *text =
"hello world";
123 EXPECT_TRUE(ref ==
"hello");
124 EXPECT_FALSE(ref ==
"hello ");
127TEST(string_ref, StartEndConstructorNullptr)
131 EXPECT_TRUE(ref ==
"");
134TEST(string_ref, StartEndConstructorSame)
136 const char *text =
"hello world";
139 EXPECT_TRUE(ref ==
"");
142TEST(string_ref, CStringConstructor)
144 const char *
str =
"Test";
150TEST(string_ref, PointerWithLengthConstructor)
152 const char *
str =
"Test";
158TEST(string_ref, StdStringConstructor)
160 std::string
str =
"Test";
166TEST(string_ref, SpanConstructor)
172TEST(string_ref, SubscriptOperator)
186 std::string
str = ref;
194 std::stringstream ss;
197 std::string
str = ss.str();
213 std::string
result = ref +
"qwe";
220 std::string
result =
"qwe" + ref;
227 std::string
result = ref + std::string(
"asd");
234 std::string
result = std::string(
"asd") + ref;
243 EXPECT_TRUE(ref1 == ref2);
244 EXPECT_FALSE(ref1 == ref3);
245 EXPECT_TRUE(ref1 != ref3);
246 EXPECT_FALSE(ref1 != ref2);
249TEST(string_ref, CompareEqualCharPtr1)
252 EXPECT_TRUE(ref ==
"test");
253 EXPECT_FALSE(ref ==
"other");
254 EXPECT_TRUE(ref !=
"other");
255 EXPECT_FALSE(ref !=
"test");
258TEST(string_ref, CompareEqualCharPtr2)
261 EXPECT_TRUE(
"test" == ref);
262 EXPECT_FALSE(
"other" == ref);
263 EXPECT_TRUE(ref !=
"other");
264 EXPECT_FALSE(ref !=
"test");
267TEST(string_ref, CompareEqualString1)
270 EXPECT_TRUE(ref == std::string(
"test"));
271 EXPECT_FALSE(ref == std::string(
"other"));
272 EXPECT_TRUE(ref != std::string(
"other"));
273 EXPECT_FALSE(ref != std::string(
"test"));
276TEST(string_ref, CompareEqualString2)
279 EXPECT_TRUE(std::string(
"test") == ref);
280 EXPECT_FALSE(std::string(
"other") == ref);
281 EXPECT_TRUE(std::string(
"other") != ref);
282 EXPECT_FALSE(std::string(
"test") != ref);
319 EXPECT_FALSE(ref.
endswith(
" test"));
334TEST(string_ref, DropPrefixLargeN)
342TEST(string_ref, DropKnownPrefix)
358TEST(string_ref, DropSuffixLargeN)
381TEST(string_ref, TrimWhitespace)
415TEST(string_ref, CopyUtf8Truncated)
420 memset(dst, 0xFF, 10);
429 memset(dst, 0xFF, 4);
467TEST(string_ref, CopyBytesTruncated)
472 memset(dst, 0xFF, 10);
481 memset(dst, 0xFF, 4);
519TEST(string_ref, FromStringView)
521 std::string_view view =
"hello";
529 std::string_view view = ref;
538 std::array<int, std::size_t(sref.
find_first_of(
'o'))> compiles = {1};
#define BLI_STATIC_ASSERT(a, msg)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
#define BLI_STR_UTF8_SUPERSCRIPT_2
constexpr StringRef substr(int64_t start, int64_t size) const
void copy_bytes_truncated(char *dst, int64_t dst_size) const
constexpr bool startswith(StringRef prefix) const
constexpr bool endswith(StringRef suffix) const
constexpr int64_t find_first_of(StringRef chars, int64_t pos=0) const
constexpr int64_t size() const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
constexpr StringRef trim() const
constexpr const char * data() const
constexpr StringRef drop_prefix(int64_t n) const
constexpr StringRef drop_suffix(int64_t n) const
constexpr StringRef drop_known_prefix(StringRef prefix) const
void append(const T &value)