From 16379362c02a2472f00fac49cad62788547c9519 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Wed, 1 Jan 2025 17:41:17 -0600 Subject: Add CSV parsing, printing, fix buffered file reading. --- test/test_file.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'test/test_file.cpp') diff --git a/test/test_file.cpp b/test/test_file.cpp index 62df1ae..9727e94 100644 --- a/test/test_file.cpp +++ b/test/test_file.cpp @@ -143,15 +143,33 @@ TEST(FudBufferedFile, OpenReadWrite) ASSERT_EQ(bufferedFile.seekStart(), FudStatus::Success); Vector output{Vector::withSize(testName.size()).takeOkay()}; - auto readResult = bufferedFile.read( - reinterpret_cast(output.data()), - testName.size(), - testName.size()); + auto readResult = bufferedFile.read(reinterpret_cast(output.data()), testName.size(), NullOpt); ASSERT_EQ(readResult, expected); - + EXPECT_EQ(output.size(), testName.size()); EXPECT_EQ(0, compareMem(output.data(), output.size(), testName.data(), testName.size()).takeOkayOr(-1)); + ASSERT_EQ(bufferedFile.flush(), nullExpected); + ASSERT_EQ(bufferedFile.seekStart(), FudStatus::Success); + + expected.bytesDrained = 1; + readResult = bufferedFile.read(reinterpret_cast(output.data()), 1, NullOpt); + ASSERT_EQ(readResult, expected); + EXPECT_EQ(output[0], testName.data()[0]); + + expected.bytesDrained = testName.size() - 2; + readResult = bufferedFile.read(reinterpret_cast(output.data()) + 1, testName.size() - 2, NullOpt); + ASSERT_EQ(readResult, expected); + EXPECT_EQ( + 0, + compareMem(output.data() + 1, output.size() - 1, testName.data() + 1, testName.size() - 2).takeOkayOr(-1)); + + expected.bytesDrained = 1; + readResult = bufferedFile.read(reinterpret_cast(output.data()), 1, NullOpt); + + EXPECT_TRUE(readResult.status == FudStatus::Success || readResult.status == FudStatus::Partial); + EXPECT_EQ(output[testName.size() - 1], testName.data()[testName.size() - 1]); + EXPECT_EQ(bufferedFile.close(true), FudStatus::Success); ASSERT_EQ(rmFile(testName), 0); } -- cgit v1.2.3