diff options
author | Christian C <cc@localhost> | 2025-03-07 23:48:17 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-07 23:48:17 -0800 |
commit | 9be81ef43c8cfabe72fba16651dbfe62ed0f1123 (patch) | |
tree | e767747b5fd49b3bb2c2693328844b5ea0368b52 /include | |
parent | afad16ce636dd54fa1fdedd100eb93f1d7b508d6 (diff) |
Testing suite
Diffstat (limited to 'include')
-rw-r--r-- | include/lib/color.h | 4 | ||||
-rw-r--r-- | include/test/__meta__.h | 11 | ||||
-rw-r--r-- | include/test/lib/color.h | 6 |
3 files changed, 13 insertions, 8 deletions
diff --git a/include/lib/color.h b/include/lib/color.h index 5e7128b..1bc9393 100644 --- a/include/lib/color.h +++ b/include/lib/color.h @@ -7,11 +7,11 @@ // Color Equal to Background // Background: zeros in RGB, alpha can be whatever -bool_t color_zero(uint8_t* color1, size_t channels); +bool_t color_zero(const uint8_t* color1, size_t channels); // Color Equality // Determine if two colors are identical -bool_t color_equal(uint8_t* color1, uint8_t* color2, size_t channels); +bool_t color_equal(const uint8_t* color1, const uint8_t* color2, size_t channels); // Print out the `channels` length color vector void print_color(uint8_t* color, size_t channels); diff --git a/include/test/__meta__.h b/include/test/__meta__.h index 05a202f..b4cc360 100644 --- a/include/test/__meta__.h +++ b/include/test/__meta__.h @@ -4,11 +4,16 @@ #include <lib/bool.h> #include <stdio.h> -#define _TEST_PASS(s,n) fprintf(stderr, "%s/%02X: \x1b[92mPASS\x1b[0m\n", s, ++n) -#define _TEST_FAIL(s,n) fprintf(stderr, "%s/%02X: \x1b[91mFAIL\x1b[0m\n", s, ++n) +#ifdef TEST_SHOW_PASS +#define _TEST_PASS(s,sub,n) fprintf(stderr, "%s/%s/%02X: \x1b[92mPASS\x1b[0m\n", s, sub, ++n) +#else +#define _TEST_PASS(s,sub,n) ++n +#endif + +#define _TEST_FAIL(s,sub,n) fprintf(stderr, "%s%s/%02X: \x1b[91mFAIL\x1b[0m\n", s, sub, ++n) #ifndef _TEST_RESULT -#define _TEST_RESULT(docstring,result,n,n_success) if (!result) {_TEST_FAIL(docstring, n);} else {_TEST_PASS(docstring,n);n_success++;} +#define _TEST_RESULT(main_string,subtest_string,result,n,n_success) if (!result) {_TEST_FAIL(main_string,subtest_string, n);} else {_TEST_PASS(main_string,subtest_string,n);n_success++;} #endif #endif diff --git a/include/test/lib/color.h b/include/test/lib/color.h index 835cb0a..be0d62f 100644 --- a/include/test/lib/color.h +++ b/include/test/lib/color.h @@ -3,13 +3,13 @@ #include <test/__meta__.h> #ifndef TEST_RESULT -#define TEST_RESULT(result,n,n_success) _TEST_RESULT("LIB/COLOR",result,n,n_success) +#define TEST_RESULT(subtest,result,n,n_success) _TEST_RESULT("LIB/COLOR",subtest,result,n,n_success) #endif #include <lib/color.h> -bool_t test_color_zero(uint8_t* color1, size_t channels, bool_t result); -bool_t test_color_equal(uint8_t* color1, uint8_t* color2, size_t channels, bool_t result); +bool_t test_color_zero(const uint8_t* color1, size_t channels, bool_t result); +bool_t test_color_equal(const uint8_t* color1, const uint8_t* color2, size_t channels, bool_t result); // Meta test function bool_t TEST_lib_color(); |