summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 00:49:16 +0400
committerMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 00:49:16 +0400
commitf56c8875766f2de7ad6f69a6bd93685ac1ddd8dd (patch)
tree85f48e444610866da70adf757a30f05334ac053b
parent653f939ac56ad27468318e4b9913f23d31105098 (diff)
downloadkit-f56c8875766f2de7ad6f69a6bd93685ac1ddd8dd.zip
Add limit checks
-rw-r--r--source/kit_test/run_tests.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/kit_test/run_tests.c b/source/kit_test/run_tests.c
index a4ebd12..c08f946 100644
--- a/source/kit_test/run_tests.c
+++ b/source/kit_test/run_tests.c
@@ -6,8 +6,20 @@
struct kit_tests_list kit_tests_list = { 0 };
static void report(int i, char const *file, int line, int ok) {
+ if (i >= KIT_TESTS_SIZE_LIMIT) {
+ printf("Kit Test error: Too many tests!");
+ return;
+ }
+
int const n = kit_tests_list.tests[i].assertions++;
+ if (n >= KIT_TEST_ASSERTIONS_LIMIT) {
+ printf(
+ "Kit Test error: Too many test assertions for test \"%s\"!",
+ kit_tests_list.tests[i].test_name);
+ return;
+ }
+
kit_tests_list.tests[i].file[n] = file;
kit_tests_list.tests[i].line[n] = line;
kit_tests_list.tests[i].status[n] = ok;