summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-06-26 18:57:33 -0400
committerPaul Duncan <pabs@pablotron.org>2018-06-26 18:57:33 -0400
commitecb2187d1c8023acdd6f3de937e1cf66db1a5521 (patch)
tree6f80fc827e9a69d5e56ae83f864f0d52016f91d4
parentd5d0b54054f5db7cad86fc08c1a12857b2ac04ca (diff)
downloadgb-c-ecb2187d1c8023acdd6f3de937e1cf66db1a5521.tar.bz2
gb-c-ecb2187d1c8023acdd6f3de937e1cf66db1a5521.zip
add test_write_image()
-rw-r--r--test.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test.c b/test.c
index e2c66f0..929bdd5 100644
--- a/test.c
+++ b/test.c
@@ -268,6 +268,25 @@ test_execute_steps(
free((void*) rom_data);
}
+static const uint8_t
+TEST_IMAGE[] = {
+ 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF,
+ 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
+ 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
+};
+
+static void
+test_write_image(
+ const char * const img_path
+) {
+ // save png
+ if (lodepng_encode24_file(img_path, TEST_IMAGE, 3, 3)) {
+ fprintf(stderr, "lode_png_encode24_file() failed\n");
+ exit(EXIT_FAILURE);
+ }
+ fprintf(stderr, "saved image as \"%s\"\n", img_path);
+}
+
int main(int argc, char *argv[]) {
// render 600 frames
for (int i = 2; i < argc; i++) {
@@ -275,6 +294,8 @@ int main(int argc, char *argv[]) {
test_render_frames("out.png", argv[i]);
} else if (argv[1][0] == 'e') {
test_execute_steps(argv[i]);
+ } else if (argv[1][0] == 'i') {
+ test_write_image(argv[i]);
} else {
fprintf(stderr, "unknown test: %s\n", argv[i]);
exit(EXIT_FAILURE);