Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Unified Diff: util/file/string_file_test.cc

Issue 913223008: Add FileReaderInterface::ReadExactly() and FileSeekerInterface::SeekSet() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/file/file_writer.h ('k') | util/util.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/string_file_test.cc
diff --git a/util/file/string_file_test.cc b/util/file/string_file_test.cc
index 93301f1f41eb1f0ee92fdfffe7891f9dd71cb30b..c585610b225233d9db92b16932162f384a14cb4f 100644
--- a/util/file/string_file_test.cc
+++ b/util/file/string_file_test.cc
@@ -117,6 +117,17 @@ TEST(StringFile, SetString) {
EXPECT_EQ(kString3, string_file.string());
}
+TEST(StringFile, ReadExactly) {
+ StringFile string_file;
+ string_file.SetString("1234567");
+ char buf[4] = "***";
+ EXPECT_TRUE(string_file.ReadExactly(buf, 3));
+ EXPECT_STREQ("123", buf);
+ EXPECT_TRUE(string_file.ReadExactly(buf, 3));
+ EXPECT_STREQ("456", buf);
+ EXPECT_FALSE(string_file.ReadExactly(buf, 3));
+}
+
TEST(StringFile, Reset) {
StringFile string_file;
@@ -465,6 +476,22 @@ TEST(StringFile, SeekInvalid) {
EXPECT_LT(string_file.Seek(kMaxOffset, SEEK_CUR), 0);
}
+TEST(StringFile, SeekSet) {
+ StringFile string_file;
+ EXPECT_TRUE(string_file.SeekSet(1));
+ EXPECT_EQ(1, string_file.Seek(0, SEEK_CUR));
+ EXPECT_TRUE(string_file.SeekSet(0));
+ EXPECT_EQ(0, string_file.Seek(0, SEEK_CUR));
+ EXPECT_TRUE(string_file.SeekSet(10));
+ EXPECT_EQ(10, string_file.Seek(0, SEEK_CUR));
+ EXPECT_FALSE(string_file.SeekSet(-1));
+ EXPECT_EQ(10, string_file.Seek(0, SEEK_CUR));
+ EXPECT_FALSE(string_file.SeekSet(std::numeric_limits<ssize_t>::min()));
+ EXPECT_EQ(10, string_file.Seek(0, SEEK_CUR));
+ EXPECT_FALSE(string_file.SeekSet(std::numeric_limits<FileOffset>::min()));
+ EXPECT_EQ(10, string_file.Seek(0, SEEK_CUR));
+}
+
} // namespace
} // namespace test
} // namespace crashpad
« no previous file with comments | « util/file/file_writer.h ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698