diff options
Diffstat (limited to 'test/test_string.cpp')
-rw-r--r-- | test/test_string.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/test_string.cpp b/test/test_string.cpp index 15646bd..6d963c4 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -37,13 +37,20 @@ TEST(FudString, BasicStringOps) const Array<utf8, 2> invalid{0xFF, 0x00}; ASSERT_FALSE(Ascii::valid(invalid[0])); const Array<utf8, 2> invalid2{0xFF, 0x00}; - String fudString{invalid2.data()}; + + auto stringResult = String::makeFromCString(invalid2.data()); + ASSERT_TRUE(stringResult.isOkay()); + + String fudString{stringResult.getOkay()}; ASSERT_EQ(fudString.length(), 1); ASSERT_EQ(fudString.data()[0], invalid[0]); ASSERT_FALSE(Ascii::valid(fudString.data()[0])); ASSERT_FALSE(fudString.utf8Valid()); - fudString = String{"TEST"}; + stringResult = String::makeFromCString("TEST"); + ASSERT_TRUE(stringResult.isOkay()); + fudString = stringResult.getOkay(); + ASSERT_TRUE(fudString.utf8Valid()); StringView view1{}; @@ -56,7 +63,9 @@ TEST(FudString, BasicStringOps) TEST(FudString, HeapAlloc) { constexpr const char filenameLiteral[] = "Amazing Saga Volume 01/000.jpg"; - String filename{filenameLiteral}; + auto filenameResult{String::makeFromCString(filenameLiteral)}; + ASSERT_TRUE(filenameResult.isOkay()); + auto filename{filenameResult.getOkay()}; ASSERT_EQ(filename.length(), sizeof(filenameLiteral) - 1); } @@ -102,7 +111,7 @@ TEST(TestFudString, StringBuffer) Array<uint8_t, 1> data1{}; bufferResult = FixedStringBuffer<1>::fromArray(data1); ASSERT_TRUE(bufferResult.isOkay()); - FixedStringBuffer<1> buffer1{std::move(bufferResult.getOkay())}; + FixedStringBuffer<1> buffer1{std::move(bufferResult).getOkay()}; ASSERT_EQ(buffer1.m_string.m_data[0], '\0'); ASSERT_EQ(buffer1.m_string.m_length, 0); ASSERT_EQ(buffer1.m_string.m_size, 1); @@ -137,7 +146,7 @@ TEST(TestFudString, StringBuffer) Array<uint8_t, sizeof("test")> data2{"test"}; auto bufferResult2{FixedStringBuffer<data2.size()>::fromArray(data2)}; ASSERT_TRUE(bufferResult2.isOkay()); - FixedStringBuffer<data2.size()> bufferTest{std::move(bufferResult2.getOkay())}; + FixedStringBuffer<data2.size()> bufferTest{std::move(bufferResult2).getOkay()}; ASSERT_EQ(bufferTest.m_string.m_data[0], 't'); ASSERT_EQ(bufferTest.m_string.m_data[4], '\0'); ASSERT_EQ(bufferTest.m_string.m_length, data2.size() - 1); |