summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logerr.c4
-rw-r--r--tests/logerr.c16
2 files changed, 12 insertions, 8 deletions
diff --git a/src/logerr.c b/src/logerr.c
index f6b3d46..284f8ad 100644
--- a/src/logerr.c
+++ b/src/logerr.c
@@ -27,5 +27,9 @@ vlogerr(
}
va_end(args);
+ if (fprintf(stream, "\n") < 0) {
+ perror(__FILE__ ":vlogerr(): fprintf() < 0");
+ }
+
return;
}
diff --git a/tests/logerr.c b/tests/logerr.c
index c692bdc..3dd700e 100644
--- a/tests/logerr.c
+++ b/tests/logerr.c
@@ -45,7 +45,7 @@ test_vlogerr(void) {
}
const char *const expected =
- "tests/logerr.c:test_vlogerr:100: ";
+ "tests/logerr.c:test_vlogerr:100: \n";
assert(strcmp(expected, str) == 0);
free(str);
@@ -79,7 +79,7 @@ test_vlogerr(void) {
}
const char *const expected =
- "tests/logerr.c:test_vlogerr:200: \n";
+ "tests/logerr.c:test_vlogerr:200: \n\n";
assert(strcmp(expected, str) == 0);
free(str);
@@ -98,7 +98,7 @@ test_vlogerr(void) {
#line 300
vlogerr(__FILE__, __func__, __LINE__, file,
- "some static string\n");
+ "some static string");
const int ret = fclose(file);
file = NULL;
@@ -132,7 +132,7 @@ test_vlogerr(void) {
#line 400
vlogerr(__FILE__, __func__, __LINE__, file,
- "fn(%s)\n", "an-arg");
+ "fn(%s)", "an-arg");
const int ret = fclose(file);
file = NULL;
@@ -166,7 +166,7 @@ test_vlogerr(void) {
#line 500
vlogerr(__FILE__, __func__, __LINE__, file,
- "int (%d), string (%s) and char (%c)\n",
+ "int (%d), string (%s) and char (%c)",
123,
"another-str",
'z');
@@ -224,21 +224,21 @@ test_logerr(void) {
{
testing("can be called with a static string");
- logerr("some err\n");
+ logerr("some err");
test_ok();
}
{
testing("can be called with a formatted string");
- logerr("some err: %s\n", strerror(errno));
+ logerr("some err: %s", strerror(errno));
test_ok();
}
{
testing("can be called with formatting arguments");
- logerr("int: %d\nstr: %s\n", 123, "an example string");
+ logerr("int: %d\tstr: %s", 123, "an example string");
test_ok();
}