diff options
author | Daniel Mack <daniel@zonque.org> | 2015-07-06 17:31:44 -0400 |
---|---|---|
committer | Daniel Mack <daniel@zonque.org> | 2015-07-06 17:31:44 -0400 |
commit | 40beecdb6d1c73e5acb62ebac2ccbfd7891f2418 (patch) | |
tree | 40626ff5f761e898e7343939878a10d87e9d29a8 /src/test/test-fileio.c | |
parent | eff8efe671e9ffa81e80ad13f791a32262567dfe (diff) |
fileio: add 'enforce_newline' argument to write_string_stream()
Add a flag to control whether write_string_stream() should always enforce a
trailing newline character in the file.
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r-- | src/test/test-fileio.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 4c31b776bd..725c2fab4a 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -302,17 +302,27 @@ static void test_write_string_stream(void) { f = fdopen(fd, "r"); assert_se(f); - assert_se(write_string_stream(f, "boohoo") < 0); + assert_se(write_string_stream(f, "boohoo", true) < 0); f = freopen(fn, "r+", f); assert_se(f); - assert_se(write_string_stream(f, "boohoo") == 0); + assert_se(write_string_stream(f, "boohoo", true) == 0); rewind(f); assert_se(fgets(buf, sizeof(buf), f)); assert_se(streq(buf, "boohoo\n")); + f = freopen(fn, "w+", f); + assert_se(f); + + assert_se(write_string_stream(f, "boohoo", false) == 0); + rewind(f); + + assert_se(fgets(buf, sizeof(buf), f)); + printf(">%s<", buf); + assert_se(streq(buf, "boohoo")); + unlink(fn); } |