diff options
author | Aki <please@ignore.pl> | 2024-03-18 23:41:20 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-03-18 23:41:20 +0100 |
commit | 2066e4911948d11cac5a234d2f7773dc5f06ba96 (patch) | |
tree | 27c7672aad884d1307736b3d15e704d7d786b314 /FoundationEx/test/reader.cpp | |
parent | 3df6ccddcbd881c2474746f5f1758b095c866a67 (diff) | |
download | starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.zip starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.tar.gz starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.tar.bz2 |
Added filesystem-only starshatter::data DataLoader replacement
Step by step. The intent is to find a good spot between current data
representations and the standard library and put the intermediate
stage there. After it matures a bit, we can move further away.
Diffstat (limited to 'FoundationEx/test/reader.cpp')
-rw-r--r-- | FoundationEx/test/reader.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/FoundationEx/test/reader.cpp b/FoundationEx/test/reader.cpp index 395ad81..4bc4882 100644 --- a/FoundationEx/test/reader.cpp +++ b/FoundationEx/test/reader.cpp @@ -17,7 +17,8 @@ TEST(FoundationEx, ReadFromView) { Reader reader("Hello, World!"); ASSERT_TRUE(reader.valid()); - std::vector<char> buffer(reader.available()); + const auto s = reader.available(); + std::vector<char> buffer(s); ASSERT_EQ(14, buffer.size()); const auto bytes = reader.read(buffer.data()); ASSERT_EQ(14, bytes); @@ -54,12 +55,10 @@ TEST(FoundationEx, RelativeSeek) TEST(FoundationEx, CreateTextFromReader) { const char* ref = "Hello!"; - const auto size = 7; - auto ptr = std::make_unique<char[]>(size); - for (auto i = 0; i < size; ++i) - ptr[i] = ref[i]; + auto ptr = std::make_unique<char[]>(std::strlen(ref) + 1); + std::strcpy(ptr.get(), ref); Reader reader(std::move(ptr)); ASSERT_TRUE(reader.valid()); - Text text(reader.data()); - ASSERT_EQ("Hello!", text); + const auto text = reader.more(); + ASSERT_STREQ(ref, text); } |