silver-ymz commented on code in PR #3004:
URL:
https://github.com/apache/incubator-opendal/pull/3004#discussion_r1314457175
##########
bindings/cpp/tests/basic_test.cpp:
##########
@@ -86,6 +93,41 @@ TEST_F(OpendalTest, BasicTest) {
EXPECT_FALSE(op.is_exist(file_path_renamed));
}
+TEST_F(OpendalTest, ReaderTest) {
+ std::string file_path = "test";
+ constexpr int size = 2000;
+ std::vector<uint8_t> data(size);
+
+ for (auto &d : data) {
+ d = rng() % 256;
+ }
+
+ // write
+ op.write(file_path, data);
+
+ // read
+ auto reader = op.reader(file_path);
+
+ auto read = [&](std::size_t to_read, std::streampos expected_tellg) {
+ std::vector<char> v(to_read);
+ reader.read(v.data(), v.size());
+ EXPECT_TRUE(!!reader);
+ EXPECT_EQ(reader.tellg(), expected_tellg);
+ };
+
+ EXPECT_EQ(reader.tellg(), 0);
+ read(10, 10);
+ read(15, 25);
+ read(15, 40);
+ reader.get();
+ EXPECT_EQ(reader.tellg(), 41);
+ read(1000, 1041);
+
+ reader.seekg(0, std::ios::beg);
Review Comment:
This is cpp std function
https://en.cppreference.com/w/cpp/io/basic_istream/seekg
I guess its meaning is `seek get area`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]