Add dprintf test
Change-Id: I0fe1b4d45c1312cf01deed6ce5db032d5513e908
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 4990582..fa1b260 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -54,6 +54,25 @@
fclose(fp);
}
+TEST(stdio, dprintf) {
+ TemporaryFile tf;
+
+ int rc = dprintf(tf.fd, "hello\n");
+ ASSERT_EQ(rc, 6);
+
+ lseek(tf.fd, SEEK_SET, 0);
+
+ char buf[6];
+ int bytes_to_read = 6;
+ do {
+ int bytes_read = read(tf.fd, buf, bytes_to_read);
+ ASSERT_TRUE(bytes_to_read >= 0);
+ bytes_to_read -= bytes_read;
+ } while (bytes_to_read > 0);
+
+ ASSERT_STREQ("hello\n", buf);
+}
+
TEST(stdio, getdelim) {
FILE* fp = tmpfile();
ASSERT_TRUE(fp != NULL);