diff --git a/test/c/gif/basic.c b/test/c/gif/basic.c index 92888c8b..3cbe8304 100644 --- a/test/c/gif/basic.c +++ b/test/c/gif/basic.c @@ -11,15 +11,26 @@ for cc in clang gcc; do done It should print: -clang: PASS -gcc: PASS +clang: PASS (N tests run) +gcc: PASS (N tests run) +for some value of N. */ -#include +#include "../testlib/testlib.c" #include "../../../gen/c/gif.c" -int main(int argc, char** argv) { - printf("PASS\n"); - return 0; +void test_default_literal_width() { + puffs_gif_lzw_decoder dec; + puffs_gif_lzw_decoder_constructor(&dec); + if (dec.f_literal_width != 0) { + FAIL("test_default_literal_width: got %d, want %d", dec.f_literal_width, 0); + puffs_gif_lzw_decoder_destructor(&dec); + return; + } + puffs_gif_lzw_decoder_destructor(&dec); } + +test tests[] = { + test_default_literal_width, NULL, +}; diff --git a/test/c/testlib/testlib.c b/test/c/testlib/testlib.c new file mode 100644 index 00000000..8b99eb16 --- /dev/null +++ b/test/c/testlib/testlib.c @@ -0,0 +1,27 @@ +// Use of this source code is governed by a BSD-style license that can be found +// in the LICENSE file. + +#include + +char fail_msg[65536] = {0}; + +#define FAIL(...) snprintf(fail_msg, sizeof fail_msg, ##__VA_ARGS__) + +int tests_run = 0; + +typedef void (*test)(); + +test tests[]; + +int main(int argc, char** argv) { + for (test* t = tests; *t; t++) { + (*t)(); + if (fail_msg[0]) { + printf("FAIL %s\n", fail_msg); + return 1; + } + tests_run++; + } + printf("PASS (%d tests run)\n", tests_run); + return 0; +}