summaryrefslogtreecommitdiff
path: root/test/test_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_string.cpp')
-rw-r--r--test/test_string.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_string.cpp b/test/test_string.cpp
index 6bcbd37..ba2df6c 100644
--- a/test/test_string.cpp
+++ b/test/test_string.cpp
@@ -56,11 +56,25 @@ TEST(FudString, BasicStringOps)
StringView view1{};
ASSERT_FALSE(view1.utf8Valid());
+
StringView view2{fudString};
ASSERT_TRUE(view2.utf8Valid());
ASSERT_TRUE(view2.nullTerminated());
}
+TEST(FudString, ViewFromCString)
+{
+ StringView viewFromU8{u8"Test"};
+ EXPECT_EQ(viewFromU8.length(), 4);
+ EXPECT_TRUE(viewFromU8.utf8Valid());
+ EXPECT_TRUE(viewFromU8.nullTerminated());
+
+ StringView viewFromCString{StringView::makeFromCString("Test")};
+ EXPECT_EQ(viewFromCString.length(), 4);
+ EXPECT_TRUE(viewFromCString.utf8Valid());
+ EXPECT_TRUE(viewFromCString.nullTerminated());
+}
+
TEST(FudString, HeapAlloc)
{
constexpr const char filenameLiteral[] = "Amazing Saga Volume 01/000.jpg";