36 lines
775 B
C
36 lines
775 B
C
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
#include "canvas.h"
|
|
#include "runner.h"
|
|
|
|
static bool canvas_test_0(const char ** scenario)
|
|
{
|
|
*scenario = "Creating a canvas";
|
|
struct canvas c = canvas(10, 20);
|
|
bool zeroized = true;
|
|
for (int i = 0; i < c.width * c.height; i++) {
|
|
zeroized &= tuple_equal(c.pixels[i], color(0.0f, 0.0f, 0.0f));
|
|
}
|
|
return
|
|
c.width == 10 &&
|
|
c.height == 20 &&
|
|
zeroized;
|
|
}
|
|
|
|
static bool canvas_test_1(const char ** scenario)
|
|
{
|
|
*scenario = "Writing pixels to the screen";
|
|
struct canvas c = canvas(10, 20);
|
|
struct tuple red = color(1.0f, 0.0f, 0.0f);
|
|
canvas_write_pixel(c, 2, 3, red);
|
|
return tuple_equal(canvas_pixel_at(c, 2, 3), red);
|
|
}
|
|
|
|
test_t canvas_tests[] = {
|
|
canvas_test_0,
|
|
canvas_test_1,
|
|
};
|
|
|
|
RUNNER(canvas_tests)
|