diff options
author | EuAndreh <eu@euandre.org> | 2024-04-18 15:59:03 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-04-18 15:59:03 -0300 |
commit | de381b68afed455b5be5e669ec6db57087f48aa5 (patch) | |
tree | 3629bb82dbb7b584e0406f15016e035da96a5c09 | |
parent | src/string.c: Add new empty file structure (diff) | |
download | pindaiba-de381b68afed455b5be5e669ec6db57087f48aa5.tar.gz pindaiba-de381b68afed455b5be5e669ec6db57087f48aa5.tar.xz |
src/testing.c: Fix show_colour() logic; add it to tests
-rw-r--r-- | src/testing.c | 2 | ||||
-rw-r--r-- | tests/testing.c | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/testing.c b/src/testing.c index aa58bc7..e2c087c 100644 --- a/src/testing.c +++ b/src/testing.c @@ -18,7 +18,7 @@ ENVVAR_NAME = "NO_COLOR"; static bool show_colour(void) { const char *const no_colour = getenv(ENVVAR_NAME); - return (no_colour != NULL) && (no_colour[0] != '\0'); + return (no_colour == NULL) || (no_colour[0] == '\0'); } void diff --git a/tests/testing.c b/tests/testing.c index eeb0a39..3c605a7 100644 --- a/tests/testing.c +++ b/tests/testing.c @@ -1,18 +1,21 @@ #include "../src/testing.c" +#include <assert.h> + int main(void) { - int rc = -1; + int rc = 1; test_start("testing.c"); - const int should_overwrite = 1; + const bool should_overwrite = true; if (unsetenv(ENVVAR_NAME)) { perror("unsetenv(\"NO_COLOR\")"); goto out; } { + assert(show_colour() == true); testing("unset NO_COLOR"); test_ok(); } @@ -22,6 +25,7 @@ main(void) { goto out; } { + assert(show_colour() == true); testing("empty NO_COLOR"); test_ok(); } @@ -31,11 +35,12 @@ main(void) { goto out; } { + assert(show_colour() == false); testing("defined NO_COLOR"); test_ok(); } rc = 0; out: - return !!rc; + return rc; } |