summaryrefslogtreecommitdiff
path: root/tests/testing.c
blob: 14e545de06b19771cffc91d12b74b4066461000f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "../src/testing.c"

#include <assert.h>


int
main(void) {
	int rc = EXIT_FAILURE;

	test_start("testing.c");
	const bool should_overwrite = true;

	if (unsetenv(ENVVAR_NAME)) {
		perror("unsetenv(\"NO_COLOUR\")");
		goto out;
	}
	{
		assert(show_colour() == true);
		testing("unset NO_COLOUR");
		test_ok();
	}

	if (setenv(ENVVAR_NAME, "", should_overwrite)) {
		perror("setenv(\"NO_COLOUR\", \"\", 1)");
		goto out;
	}
	{
		assert(show_colour() == true);
		testing("empty NO_COLOUR");
		test_ok();
	}

	if (setenv(ENVVAR_NAME, "something", should_overwrite)) {
		perror("setenv(\"NO_COLOUR\", \"something\", 1)");
		goto out;
	}
	{
		assert(show_colour() == false);
		testing("defined NO_COLOUR");
		test_ok();
	}

	rc = EXIT_SUCCESS;
out:
	return rc;
}