summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r--src/test/test-fileio.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 4c31b776bd..be3a87958f 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);
}
@@ -324,7 +334,7 @@ static void test_write_string_file(void) {
fd = mkostemp_safe(fn, O_RDWR);
assert_se(fd >= 0);
- assert_se(write_string_file(fn, "boohoo") == 0);
+ assert_se(write_string_file(fn, "boohoo", WRITE_STRING_FILE_CREATE) == 0);
assert_se(read(fd, buf, sizeof(buf)) == 7);
assert_se(streq(buf, "boohoo\n"));
@@ -340,8 +350,8 @@ static void test_write_string_file_no_create(void) {
fd = mkostemp_safe(fn, O_RDWR);
assert_se(fd >= 0);
- assert_se(write_string_file_no_create("/a/file/which/does/not/exists/i/guess", "boohoo") < 0);
- assert_se(write_string_file_no_create(fn, "boohoo") == 0);
+ assert_se(write_string_file("/a/file/which/does/not/exists/i/guess", "boohoo", 0) < 0);
+ assert_se(write_string_file(fn, "boohoo", 0) == 0);
assert_se(read(fd, buf, sizeof(buf)) == strlen("boohoo\n"));
assert_se(streq(buf, "boohoo\n"));
@@ -367,8 +377,8 @@ static void test_load_env_file_pairs(void) {
"ANSI_COLOR=\"0;36\"\n"
"HOME_URL=\"https://www.archlinux.org/\"\n"
"SUPPORT_URL=\"https://bbs.archlinux.org/\"\n"
- "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n"
- );
+ "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n",
+ WRITE_STRING_FILE_CREATE);
assert_se(r == 0);
f = fdopen(fd, "r");