From 2066e4911948d11cac5a234d2f7773dc5f06ba96 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 18 Mar 2024 23:41:20 +0100 Subject: 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. --- FoundationEx/test/reader.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'FoundationEx/test/reader.cpp') 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 buffer(reader.available()); + const auto s = reader.available(); + std::vector 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(size); - for (auto i = 0; i < size; ++i) - ptr[i] = ref[i]; + auto ptr = std::make_unique(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); } -- cgit v1.1