Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-06-10 19:26:11 +0300
committerJacques Lucke <jacques@blender.org>2020-06-10 19:27:18 +0300
commit4c172f7ca6cff1387220696166a6e0ee9758ac98 (patch)
tree161331e2fc05c9537cb1de78972f0f37f081a5dd /tests
parent2d695367a7880faac46b583686dfaa4d65f7ec14 (diff)
BLI: support constructing StringRef from start and end pointer
Diffstat (limited to 'tests')
-rw-r--r--tests/gtests/blenlib/BLI_string_ref_test.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_string_ref_test.cc b/tests/gtests/blenlib/BLI_string_ref_test.cc
index 6823a79da06..5bb0c396288 100644
--- a/tests/gtests/blenlib/BLI_string_ref_test.cc
+++ b/tests/gtests/blenlib/BLI_string_ref_test.cc
@@ -36,6 +36,30 @@ TEST(string_ref, DefaultConstructor)
EXPECT_EQ(ref.size(), 0);
}
+TEST(string_ref, StartEndConstructor)
+{
+ const char *text = "hello world";
+ StringRef ref(text, text + 5);
+ EXPECT_EQ(ref.size(), 5);
+ EXPECT_TRUE(ref == "hello");
+ EXPECT_FALSE(ref == "hello ");
+}
+
+TEST(string_ref, StartEndConstructorNullptr)
+{
+ StringRef ref(nullptr, nullptr);
+ EXPECT_EQ(ref.size(), 0);
+ EXPECT_TRUE(ref == "");
+}
+
+TEST(string_ref, StartEndConstructorSame)
+{
+ const char *text = "hello world";
+ StringRef ref(text, text);
+ EXPECT_EQ(ref.size(), 0);
+ EXPECT_TRUE(ref == "");
+}
+
TEST(string_ref, CStringConstructor)
{
const char *str = "Test";