diff options
author | Elliott Hughes <enh@google.com> | 2015-01-16 16:40:55 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-01-16 16:40:55 -0800 |
commit | df8f1a42d1cde97bcd46f5a29a67a44330c5c4f2 (patch) | |
tree | ddd25b569e9659b7a042eed1121b0f28b0de2228 /tests | |
parent | 5a388898cfa9befb7626dfcd9940713ce942cadd (diff) | |
download | bionic-df8f1a42d1cde97bcd46f5a29a67a44330c5c4f2.zip bionic-df8f1a42d1cde97bcd46f5a29a67a44330c5c4f2.tar.gz bionic-df8f1a42d1cde97bcd46f5a29a67a44330c5c4f2.tar.bz2 |
Improve <stdio_ext.h> testing.
I almost fixed a non-bug. Add a test to prevent me from doing that.
Change-Id: I4a1dc13e603a7a377bdaee2e78132015087f7107
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdio_ext_test.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/stdio_ext_test.cpp b/tests/stdio_ext_test.cpp index 3dbc485..950c7ed 100644 --- a/tests/stdio_ext_test.cpp +++ b/tests/stdio_ext_test.cpp @@ -34,7 +34,13 @@ TEST(stdio_ext, __fbufsize) { FILE* fp = fopen("/proc/version", "r"); + // Initially, there's no buffer in case the first thing you do is disable buffering. + ASSERT_EQ(0U, __fbufsize(fp)); + + // A read forces a buffer to be created. char buf[128]; + fgets(buf, sizeof(buf), fp); + ASSERT_EQ(1024U, __fbufsize(fp)); ASSERT_EQ(0, setvbuf(fp, buf, _IOFBF, 1)); ASSERT_EQ(1U, __fbufsize(fp)); |