summaryrefslogtreecommitdiffstats
path: root/adb/adb_io_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'adb/adb_io_test.cpp')
-rw-r--r--adb/adb_io_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp
index dd09919..8fd5cbf 100644
--- a/adb/adb_io_test.cpp
+++ b/adb/adb_io_test.cpp
@@ -152,3 +152,16 @@ TEST(io, WriteFdExactly_string) {
ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
EXPECT_STREQ(str, s.c_str());
}
+
+TEST(io, WriteFdFmt) {
+ TemporaryFile tf;
+ ASSERT_NE(-1, tf.fd);
+
+ // Test writing a partial string to the file.
+ ASSERT_TRUE(WriteFdFmt(tf.fd, "Foo%s%d", "bar", 123)) << strerror(errno);
+ ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
+
+ std::string s;
+ ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
+ EXPECT_STREQ("Foobar123", s.c_str());
+}