summaryrefslogtreecommitdiff
path: root/tests/stdio_test.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-05-29 12:49:35 -0700
committerChristopher Ferris <cferris@google.com>2014-05-29 13:17:40 -0700
commit9e01ea63a7517fe0c811ced3b822cf6e855ee62b (patch)
tree29e905171439f76f82696b9235d53be897ecc469 /tests/stdio_test.cpp
parent1a57de713adfb81842cb2ebdfc051ecb9afa55f1 (diff)
Fix dprintf test.
Change-Id: Ied783d545b6a35a70a158249f3957a9d00971627
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r--tests/stdio_test.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index fa1b26056..0ff85bf00 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -61,16 +61,15 @@ TEST(stdio, dprintf) {
ASSERT_EQ(rc, 6);
lseek(tf.fd, SEEK_SET, 0);
+ FILE* tfile = fdopen(tf.fd, "r");
+ ASSERT_TRUE(tfile != NULL);
- 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);
-
+ char buf[7];
+ ASSERT_EQ(buf, fgets(buf, sizeof(buf), tfile));
ASSERT_STREQ("hello\n", buf);
+ // Make sure there isn't anything else in the file.
+ ASSERT_EQ(NULL, fgets(buf, sizeof(buf), tfile));
+ fclose(tfile);
}
TEST(stdio, getdelim) {