summaryrefslogtreecommitdiff
path: root/test/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test.c')
-rw-r--r--test/test.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/test/test.c b/test/test.c
index 668dec8..be3be93 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1,3 +1,5 @@
1#include "test.h"
2
1#include <swgfx.h> 3#include <swgfx.h>
2 4
3#include <assert.h> 5#include <assert.h>
@@ -24,7 +26,7 @@ static bool WritePPM(int width, int height, const RGB* image, const char* path)
24 return true; 26 return true;
25} 27}
26 28
27void ToRGB(int width, int height, const sgPixel* rgba, RGB* rgb) { 29static void ToRGB(int width, int height, const sgPixel* rgba, RGB* rgb) {
28 assert(rgba); 30 assert(rgba);
29 assert(rgb); 31 assert(rgb);
30 for (int y = 0; y < height; ++y) { 32 for (int y = 0; y < height; ++y) {
@@ -71,18 +73,21 @@ static void TestTriangle(swgfx* gfx) {
71 73
72 ToRGB(BufferWidth, BufferHeight, colour, rgb); 74 ToRGB(BufferWidth, BufferHeight, colour, rgb);
73 WritePPM(BufferWidth, BufferHeight, rgb, "triangle.ppm"); 75 WritePPM(BufferWidth, BufferHeight, rgb, "triangle.ppm");
76 // TODO: Assert the contents. Turn this file into a unit test executable.
77 // Write a helper function that first writes the image to a file and then
78 // asserts its contents.
74} 79}
75 80
76int main() { 81#define GFX_TEST(NAME, FUNC) \
77 swgfx* gfx = 0; 82 TEST_CASE(NAME) {\
78 if (!(gfx = sgNew())) { 83 swgfx* gfx = nullptr;\
79 fprintf(stderr, "Failed to create swgfx\n"); 84 if (!(gfx = sgNew())) {\
80 return 1; 85 SET_FAILURE("Failed to create swgfx\n", false);\
86 }\
87 FUNC(gfx);\
88 sgDel(&gfx);\
81 } 89 }
82
83 TestTriangle(gfx);
84
85 sgDel(&gfx);
86 return 0;
87}
88 90
91GFX_TEST(triangle, TestTriangle)
92
93int main() { return 0; }