summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-05-22 16:03:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-05-22 16:03:08 +0000
commiteea59ea21e04806fff48fdf4ad5ba117dcb0babb (patch)
tree87c11092c92ff1950584ab07dc76d01dcbf636fa /tests
parent254fa8857f5d88a4140cea2ee05056eae7f102b1 (diff)
parent6afb2a9a9729bbfd70ace602342b0173f3bad328 (diff)
downloadbionic-eea59ea21e04806fff48fdf4ad5ba117dcb0babb.zip
bionic-eea59ea21e04806fff48fdf4ad5ba117dcb0babb.tar.gz
bionic-eea59ea21e04806fff48fdf4ad5ba117dcb0babb.tar.bz2
Merge "Add dprintf test"
Diffstat (limited to 'tests')
-rw-r--r--tests/stdio_test.cpp19
1 files changed, 19 insertions, 0 deletions
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 @@ TEST(stdio, tmpfile_fileno_fprintf_rewind_fgets) {
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);