From ea60b1b08015060a08b1ead38e4e81c44a88017f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 5 Apr 2024 16:07:39 -0300 Subject: Move unit tests out of src/*.c into tests/ --- tests/testing.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/testing.c (limited to 'tests/testing.c') diff --git a/tests/testing.c b/tests/testing.c new file mode 100644 index 0000000..65012f9 --- /dev/null +++ b/tests/testing.c @@ -0,0 +1,43 @@ +#include "../src/testing.c" + + +int +main(void) { + int rc = 0; + + test_start("testing.c"); + const int should_overwrite = 1; + + if (unsetenv(ENVVAR_NAME)) { + perror("unsetenv(\"NO_COLOR\")"); + rc = -1; + goto out; + } + { + testing("unset NO_COLOR"); + test_ok(); + } + + if (setenv(ENVVAR_NAME, "", should_overwrite)) { + perror("setenv(\"NO_COLOR\", \"\", 1)"); + rc = -1; + goto out; + } + { + testing("empty NO_COLOR"); + test_ok(); + } + + if (setenv(ENVVAR_NAME, "something", should_overwrite)) { + perror("setenv(\"NO_COLOR\", \"something\", 1)"); + rc = -1; + goto out; + } + { + testing("defined NO_COLOR"); + test_ok(); + } + +out: + return !!rc; +} -- cgit v1.2.3