aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-04-01 17:38:32 -0700
committerChristian C <cc@localhost>2025-04-01 17:38:32 -0700
commita18cea2fef7aa1545c9a984b60919541b26a6f84 (patch)
treed1ab991e28b701bdfdc9035704389ad6c57391c9 /test
parent2bc54ac42b831a7dfcba26c2d12ba002f80a5e40 (diff)
Clang Format
Diffstat (limited to 'test')
-rw-r--r--test/lib/color.c73
-rw-r--r--test/lib/dir.c47
-rw-r--r--test/lib/time.c31
-rw-r--r--test/test.c10
4 files changed, 80 insertions, 81 deletions
diff --git a/test/lib/color.c b/test/lib/color.c
index e791d95..a93d47d 100644
--- a/test/lib/color.c
+++ b/test/lib/color.c
@@ -1,13 +1,13 @@
#include <test/lib/color.h>
-const ImageData_t test_rgba[4] = {0,0,0,0};
-const ImageData_t test_Rgba[4] = {1,0,0,0};
-const ImageData_t test_rGba[4] = {0,1,0,0};
-const ImageData_t test_rgBa[4] = {0,0,1,0};
-const ImageData_t test_rgbA[4] = {0,0,0,1};
-
-bool_t test_color_zero(const ImageData_t* color1, size_t channels, bool_t result)
-{
+const ImageData_t test_rgba[4] = {0, 0, 0, 0};
+const ImageData_t test_Rgba[4] = {1, 0, 0, 0};
+const ImageData_t test_rGba[4] = {0, 1, 0, 0};
+const ImageData_t test_rgBa[4] = {0, 0, 1, 0};
+const ImageData_t test_rgbA[4] = {0, 0, 0, 1};
+
+bool_t test_color_zero(const ImageData_t *color1, size_t channels,
+ bool_t result) {
bool_t fcall_result = color_zero(color1, channels);
if (fcall_result == result) {
return TRUE;
@@ -15,66 +15,66 @@ bool_t test_color_zero(const ImageData_t* color1, size_t channels, bool_t result
return FALSE;
}
-void _TEST_color_zero(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_color_zero(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: 1 channel zero color
// Should result: True
sub_result = test_color_zero(test_rgba, 1, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 2: 1 channel non-zero color
// Should result: False
sub_result = test_color_zero(test_Rgba, 1, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 3: 2 channel zero color
// Should result: True
sub_result = test_color_zero(test_rgba, 2, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 4: 2 channel non-zero color
// Should result: False
sub_result = test_color_zero(test_rGba, 2, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 5: 3 channel zero color
// Should result: True
sub_result = test_color_zero(test_rgba, 3, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 6: 3 channel non-zero color
// Should result: False
sub_result = test_color_zero(test_rgBa, 3, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 7: 4 channel zero color
// Should result: True
sub_result = test_color_zero(test_rgba, 4, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 8: 4 channel non-zero color
// Should result: False
sub_result = test_color_zero(test_rgBa, 4, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
// Test 9: 4 channel non-zero color (Alpha non-zero)
// Should result: True
sub_result = test_color_zero(test_rgbA, 4, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_ZERO",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_ZERO", sub_result, *test_count, (*test_pass));
}
-bool_t test_color_equal(const ImageData_t* color1, const ImageData_t* color2, size_t channels, bool_t result)
-{
+bool_t test_color_equal(const ImageData_t *color1, const ImageData_t *color2,
+ size_t channels, bool_t result) {
bool_t fcall_result = color_equal(color1, color2, channels);
if (fcall_result == result) {
return TRUE;
@@ -82,85 +82,84 @@ bool_t test_color_equal(const ImageData_t* color1, const ImageData_t* color2, si
return FALSE;
}
-void _TEST_color_equal(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_color_equal(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: 1 channel equal (zero)
// Should result: True
sub_result = test_color_equal(test_rgba, test_rgba, 1, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 2: 1 channel equal (nonzero)
// Should result: True
sub_result = test_color_equal(test_Rgba, test_Rgba, 1, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 3: 1 channel nonequal
// Should result: True
sub_result = test_color_equal(test_rgba, test_Rgba, 1, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 4: 2 channel equal (zero)
// Should result: True
sub_result = test_color_equal(test_rgba, test_rgba, 2, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 5: 2 channel equal (nonzero)
// Should result: True
sub_result = test_color_equal(test_rGba, test_rGba, 2, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 6: 2 channel nonequal
// Should result: False
sub_result = test_color_equal(test_Rgba, test_rGba, 2, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 7: 3 channel equal (zero)
// Should result: True
sub_result = test_color_equal(test_rgba, test_rgba, 3, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 8: 3 channel equal (nonzero)
// Should result: True
sub_result = test_color_equal(test_rgBa, test_rgBa, 3, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 9: 3 channel nonequal
// Should result: False
sub_result = test_color_equal(test_Rgba, test_rgBa, 3, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 7: 4 channel equal (zero)
// Should result: True
sub_result = test_color_equal(test_rgba, test_rgba, 4, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 8: 4 channel equal (nonzero)
// Should result: True
sub_result = test_color_equal(test_rgbA, test_rgbA, 4, TRUE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
// Test 9: 4 channel nonequal
// Should result: False
sub_result = test_color_equal(test_Rgba, test_rgbA, 4, FALSE);
*result &= sub_result;
- TEST_RESULT("COLOR_EQUAL",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("COLOR_EQUAL", sub_result, *test_count, (*test_pass));
}
// Meta test function
-bool_t TEST_lib_color()
-{
+bool_t TEST_lib_color() {
TestCount_t test_count = 0;
TestCount_t test_pass = 0;
bool_t result = TRUE;
diff --git a/test/lib/dir.c b/test/lib/dir.c
index 21b4284..85ef400 100644
--- a/test/lib/dir.c
+++ b/test/lib/dir.c
@@ -1,10 +1,9 @@
-#include <test/lib/dir.h>
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <test/lib/dir.h>
-bool_t test_is_directory(char* dirname, bool_t result)
-{
+bool_t test_is_directory(char *dirname, bool_t result) {
bool_t fcall_result = is_directory(dirname);
if (fcall_result == result) {
return TRUE;
@@ -12,23 +11,22 @@ bool_t test_is_directory(char* dirname, bool_t result)
return FALSE;
}
-void _TEST_is_directory(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_is_directory(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: sample_data/ (TRUE) [On clean git folder]
sub_result = test_is_directory("sample_data", TRUE);
*result &= sub_result;
- TEST_RESULT("IS_DIRECTORY",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("IS_DIRECTORY", sub_result, *test_count, (*test_pass));
// Test 2: asdf/ (FALSE) [On clean git folder]
sub_result = test_is_directory("asdf", FALSE);
*result &= sub_result;
- TEST_RESULT("IS_DIRECTORY",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("IS_DIRECTORY", sub_result, *test_count, (*test_pass));
}
-bool_t test_full_path(char* dirname, char* file, char* result)
-{
- char* fpath = full_path(dirname, file);
+bool_t test_full_path(char *dirname, char *file, char *result) {
+ char *fpath = full_path(dirname, file);
bool_t cmp_result = strcmp(result, fpath);
free(fpath);
if (cmp_result == 0) {
@@ -37,47 +35,46 @@ bool_t test_full_path(char* dirname, char* file, char* result)
return FALSE;
}
-void _TEST_full_path(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_full_path(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: sample_data/small + small.tif = sample_data/small/small.tif
- sub_result = test_full_path("sample_data/small", "small.tif", "sample_data/small/small.tif");
+ sub_result = test_full_path("sample_data/small", "small.tif",
+ "sample_data/small/small.tif");
*result &= sub_result;
- TEST_RESULT("FULL_PATH",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("FULL_PATH", sub_result, *test_count, (*test_pass));
}
-bool_t test_is_tif_ext(char* file_name, bool_t result)
-{
+bool_t test_is_tif_ext(char *file_name, bool_t result) {
size_t file_name_len = strlen(file_name);
file_name_len -= 3;
- bool_t cmp_result = strcmp(file_name+file_name_len, "tif");
+ bool_t cmp_result = strcmp(file_name + file_name_len, "tif");
if (cmp_result == 0) {
return TRUE == result;
}
return FALSE == result;
}
-void _TEST_is_tif_ext(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_is_tif_ext(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: sample_data/small/small.tif (TRUE)
sub_result = test_is_tif_ext("sample_data/small/small.tif", TRUE);
*result &= sub_result;
- TEST_RESULT("IS_TIF_EXT",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("IS_TIF_EXT", sub_result, *test_count, (*test_pass));
// Test 2: data/test.tif (TRUE)
sub_result = test_is_tif_ext("data/test.tif", TRUE);
*result &= sub_result;
- TEST_RESULT("IS_TIF_EXT",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("IS_TIF_EXT", sub_result, *test_count, (*test_pass));
// Test 3: sample_data/small/small (FALSE)
sub_result = test_is_tif_ext("sample_data/small/small", FALSE);
*result &= sub_result;
- TEST_RESULT("IS_TIF_EXT",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("IS_TIF_EXT", sub_result, *test_count, (*test_pass));
}
-bool_t TEST_lib_dir()
-{
+bool_t TEST_lib_dir() {
TestCount_t test_count = 0;
TestCount_t test_pass = 0;
bool_t result = TRUE;
diff --git a/test/lib/time.c b/test/lib/time.c
index 67c8f33..a69d5a9 100644
--- a/test/lib/time.c
+++ b/test/lib/time.c
@@ -1,12 +1,12 @@
#include <test/lib/time.h>
-const struct timespec zero = {0,0};
-const struct timespec one_s = {1,0};
-const struct timespec one_ns = {0,1};
-const struct timespec one_s_ns = {1,1};
+const struct timespec zero = {0, 0};
+const struct timespec one_s = {1, 0};
+const struct timespec one_ns = {0, 1};
+const struct timespec one_s_ns = {1, 1};
-bool_t test_diff_time(const struct timespec *time1, const struct timespec *time0, double result)
-{
+bool_t test_diff_time(const struct timespec *time1,
+ const struct timespec *time0, double result) {
double fcall_result = diff_time(time1, time0);
if (fcall_result == result) {
return TRUE;
@@ -14,42 +14,41 @@ bool_t test_diff_time(const struct timespec *time1, const struct timespec *time0
return FALSE;
}
-void _TEST_diff_time(bool_t* result, TestCount_t* test_count, TestCount_t* test_pass)
-{
+void _TEST_diff_time(bool_t *result, TestCount_t *test_count,
+ TestCount_t *test_pass) {
bool_t sub_result;
// Test 1: 0-0=0
sub_result = test_diff_time(&zero, &zero, 0.0);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
// Test 2: 1s-0=1s
sub_result = test_diff_time(&one_s, &zero, 1.0);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
// Test 3: 1ns-0=1ns
sub_result = test_diff_time(&one_ns, &zero, 0.000000001);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
// Test 4: 1s1ns-0=1s1ns
sub_result = test_diff_time(&one_s_ns, &zero, 1.000000001);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
// Test 5: 1s1ns-1ns=1s
sub_result = test_diff_time(&one_s_ns, &one_ns, 1.0);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
// Test 6: 1s1ns-1s=1ns
sub_result = test_diff_time(&one_s_ns, &one_s, 0.000000001);
*result &= sub_result;
- TEST_RESULT("DIFF_TIME",sub_result, *test_count, (*test_pass));
+ TEST_RESULT("DIFF_TIME", sub_result, *test_count, (*test_pass));
}
-bool_t TEST_lib_time()
-{
+bool_t TEST_lib_time() {
TestCount_t test_count = 0;
TestCount_t test_pass = 0;
bool_t result = TRUE;
diff --git a/test/test.c b/test/test.c
index 40e2d6f..786ab2e 100644
--- a/test/test.c
+++ b/test/test.c
@@ -2,10 +2,14 @@
#include <test/lib/dir.h>
#include <test/lib/time.h>
-#define _META_TEST_RESULT(name,result) if (result) { fprintf(stderr, " \x1b[92mPASS\x1b[0m %s\n", name);} else { fprintf(stderr, "%s: \x1b[91mFAIL\x1b[0m\n", name);}
+#define _META_TEST_RESULT(name, result) \
+ if (result) { \
+ fprintf(stderr, " \x1b[92mPASS\x1b[0m %s\n", name); \
+ } else { \
+ fprintf(stderr, "%s: \x1b[91mFAIL\x1b[0m\n", name); \
+ }
-int main()
-{
+int main() {
bool_t all_success = TRUE;
bool_t test_success;
// lib/color.c Test