aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Romanko <me@blankhex.com>2025-08-02 14:37:18 +0300
committerMikhail Romanko <me@blankhex.com>2025-08-02 14:50:33 +0300
commitd94055b3026d5970b9fd82fceb06d19534fbe4d2 (patch)
tree4341090b645cf0b850c8d4670a77ab395a820a98
parente5f4de2923c1fd72c993b98692cefabe0b86bcaf (diff)
downloadbhlib-d94055b3026d5970b9fd82fceb06d19534fbe4d2.tar.gz
Add basic unit test for BH_Color
-rw-r--r--test/src/TestColor.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/src/TestColor.c b/test/src/TestColor.c
new file mode 100644
index 0000000..78f6348
--- /dev/null
+++ b/test/src/TestColor.c
@@ -0,0 +1,59 @@
+#include <BH/Color.h>
+#include <BH/Unit.h>
+
+
+BH_UNIT_TEST(RoundTrip)
+{
+ BH_Color src, dest;
+ uint8_t r, g, b, a;
+
+ BH_ColorSetRGBA8(&src, 123, 210, 34, 50);
+
+ BH_ColorToHSLA(&src, &dest);
+ BH_ColorRGBA8(&dest, &r, &g, &b, &a);
+ BH_VERIFY(r == 123);
+ BH_VERIFY(g == 210);
+ BH_VERIFY(b == 34);
+ BH_VERIFY(a == 50);
+
+ BH_ColorToHSVA(&dest, &dest);
+ BH_ColorRGBA8(&dest, &r, &g, &b, &a);
+ BH_VERIFY(r == 123);
+ BH_VERIFY(g == 210);
+ BH_VERIFY(b == 34);
+ BH_VERIFY(a == 50);
+
+ BH_ColorToRGBA(&dest, &dest);
+ BH_ColorRGBA8(&dest, &r, &g, &b, &a);
+ BH_VERIFY(r == 123);
+ BH_VERIFY(g == 210);
+ BH_VERIFY(b == 34);
+ BH_VERIFY(a == 50);
+
+ BH_ColorToHSVA(&dest, &dest);
+ BH_ColorRGBA8(&dest, &r, &g, &b, &a);
+ BH_VERIFY(r == 123);
+ BH_VERIFY(g == 210);
+ BH_VERIFY(b == 34);
+ BH_VERIFY(a == 50);
+
+ BH_ColorToHSLA(&src, &dest);
+ BH_ColorRGBA8(&dest, &r, &g, &b, &a);
+ BH_VERIFY(r == 123);
+ BH_VERIFY(g == 210);
+ BH_VERIFY(b == 34);
+ BH_VERIFY(a == 50);
+
+ return 0;
+}
+
+
+int main(int argc, char **argv)
+{
+ BH_UNUSED(argc);
+ BH_UNUSED(argv);
+
+ BH_UNIT_ADD(RoundTrip);
+
+ return 0;
+}