diff options
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); } |