aboutsummaryrefslogtreecommitdiff
path: root/dependencies/jsmn/test/test.h
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-11-13 14:45:57 +0100
committerToni Uhlig <matzeton@googlemail.com>2020-11-13 14:45:57 +0100
commitaac0e77a2c050995f921e39e9927098c5f7054a4 (patch)
tree4f96ba2aa399537550aa61055b03eecff49ea3bc /dependencies/jsmn/test/test.h
parentf79991d70c66040426cb2c59876d0c48f80fdfe6 (diff)
parent053d3cd29200edb1bfd181d917d140c16c1f8834 (diff)
Add 'dependencies/jsmn/' from commit '053d3cd29200edb1bfd181d917d140c16c1f8834'
git-subtree-dir: dependencies/jsmn git-subtree-mainline: f79991d70c66040426cb2c59876d0c48f80fdfe6 git-subtree-split: 053d3cd29200edb1bfd181d917d140c16c1f8834
Diffstat (limited to 'dependencies/jsmn/test/test.h')
-rw-r--r--dependencies/jsmn/test/test.h31
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__ */