From 07fb91b9571fc0add797cbcd0adcc8711401a2be Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 27 Dec 2025 12:00:21 -0800 Subject: Enough stuff to draw a cube --- test/test.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'test/test.c') 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 @@ +#include "test.h" + #include #include @@ -24,7 +26,7 @@ static bool WritePPM(int width, int height, const RGB* image, const char* path) return true; } -void ToRGB(int width, int height, const sgPixel* rgba, RGB* rgb) { +static void ToRGB(int width, int height, const sgPixel* rgba, RGB* rgb) { assert(rgba); assert(rgb); for (int y = 0; y < height; ++y) { @@ -71,18 +73,21 @@ static void TestTriangle(swgfx* gfx) { ToRGB(BufferWidth, BufferHeight, colour, rgb); WritePPM(BufferWidth, BufferHeight, rgb, "triangle.ppm"); + // TODO: Assert the contents. Turn this file into a unit test executable. + // Write a helper function that first writes the image to a file and then + // asserts its contents. } -int main() { - swgfx* gfx = 0; - if (!(gfx = sgNew())) { - fprintf(stderr, "Failed to create swgfx\n"); - return 1; +#define GFX_TEST(NAME, FUNC) \ + TEST_CASE(NAME) {\ + swgfx* gfx = nullptr;\ + if (!(gfx = sgNew())) {\ + SET_FAILURE("Failed to create swgfx\n", false);\ + }\ + FUNC(gfx);\ + sgDel(&gfx);\ } - - TestTriangle(gfx); - - sgDel(&gfx); - return 0; -} +GFX_TEST(triangle, TestTriangle) + +int main() { return 0; } -- cgit v1.2.3