summaryrefslogtreecommitdiff
path: root/test/test_file.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2025-01-01 17:41:17 -0600
committerDominick Allen <djallen@librehumanitas.org>2025-01-01 17:41:17 -0600
commit16379362c02a2472f00fac49cad62788547c9519 (patch)
tree9b7f42acbba8dd259a536287a2b130e92ad2e2c7 /test/test_file.cpp
parent012df4bc38777c9053353ec2c4213bba67d63ab4 (diff)
Add CSV parsing, printing, fix buffered file reading.
Diffstat (limited to 'test/test_file.cpp')
-rw-r--r--test/test_file.cpp28
1 files changed, 23 insertions, 5 deletions
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<utf8> output{Vector<utf8>::withSize(testName.size()).takeOkay()};
- auto readResult = bufferedFile.read(
- reinterpret_cast<std::byte*>(output.data()),
- testName.size(),
- testName.size());
+ auto readResult = bufferedFile.read(reinterpret_cast<std::byte*>(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<std::byte*>(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<std::byte*>(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<std::byte*>(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);
}