summaryrefslogtreecommitdiff
path: root/test/test_string.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-15 20:56:26 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-15 20:56:26 -0500
commitf3ac764684c64fbdd2094853a80b23e570cd5d9c (patch)
tree3b7f64480a1247455d28e23b6bb5ff63303c9170 /test/test_string.cpp
parent71976e927cca43b970cb659c03fd6908c352ea3d (diff)
Conver to using static constructors for string, sqlite, files.
Diffstat (limited to 'test/test_string.cpp')
-rw-r--r--test/test_string.cpp19
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);