aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_reorder_rasters.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-23 20:34:03 +0100
committerMattias Andrée <maandree@kth.se>2023-01-23 20:34:03 +0100
commitb6bb688199abc342a6e85f80859c8cbb5a41b58a (patch)
tree46d953c3689f5f75210c7667c3a4f1c4d1386aab /libglitter_reorder_rasters.c
parentAdd libglitter_reorder_rasters (diff)
downloadlibglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.gz
libglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.bz2
libglitter-b6bb688199abc342a6e85f80859c8cbb5a41b58a.tar.xz
Add some tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libglitter_reorder_rasters.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libglitter_reorder_rasters.c b/libglitter_reorder_rasters.c
index 5df590e..c56873c 100644
--- a/libglitter_reorder_rasters.c
+++ b/libglitter_reorder_rasters.c
@@ -1,5 +1,6 @@
/* See LICENSE file for copyright and license details. */
#include "common.h"
+#ifndef TEST
void
@@ -13,3 +14,40 @@ libglitter_reorder_rasters(void **rasters, enum libglitter_colour colour1,
rasters[1] = channel2;
rasters[2] = channel3;
}
+
+
+#else
+
+
+int
+main(void)
+{
+ const char r = 'R', g = 'G', b = 'B';
+ const void *rasters[3];
+
+#define T(CH1, CH2, CH3)\
+ do {\
+ rasters[0] = &r;\
+ rasters[1] = &g;\
+ rasters[2] = &b;\
+ libglitter_reorder_rasters((void *)rasters,\
+ LIBGLITTER_CHANNEL_##CH1,\
+ LIBGLITTER_CHANNEL_##CH2,\
+ LIBGLITTER_CHANNEL_##CH3);\
+ ASSERT(*(const char *)rasters[0] == *#CH1);\
+ ASSERT(*(const char *)rasters[1] == *#CH2);\
+ ASSERT(*(const char *)rasters[2] == *#CH3);\
+ } while (0)
+
+ T(RED, GREEN, BLUE);
+ T(RED, BLUE, GREEN);
+ T(GREEN, RED, BLUE);
+ T(GREEN, BLUE, RED);
+ T(BLUE, RED, GREEN);
+ T(BLUE, GREEN, RED);
+
+ return 0;
+}
+
+
+#endif