diff options
Diffstat (limited to 'dependencies/jsmn/test/test.h')
-rw-r--r-- | dependencies/jsmn/test/test.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dependencies/jsmn/test/test.h b/dependencies/jsmn/test/test.h new file mode 100644 index 000000000..a1c0957a7 --- /dev/null +++ b/dependencies/jsmn/test/test.h @@ -0,0 +1,31 @@ +#ifndef __TEST_H__ +#define __TEST_H__ + +static int test_passed = 0; +static int test_failed = 0; + +/* Terminate current test with error */ +#define fail() return __LINE__ + +/* Successful end of the test case */ +#define done() return 0 + +/* Check single condition */ +#define check(cond) \ + do { \ + if (!(cond)) \ + fail(); \ + } while (0) + +/* Test runner */ +static void test(int (*func)(void), const char *name) { + int r = func(); + if (r == 0) { + test_passed++; + } else { + test_failed++; + printf("FAILED: %s (at line %d)\n", name, r); + } +} + +#endif /* __TEST_H__ */ |