diff options
author | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-07 00:49:16 +0400 |
---|---|---|
committer | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-07 00:49:16 +0400 |
commit | f56c8875766f2de7ad6f69a6bd93685ac1ddd8dd (patch) | |
tree | 85f48e444610866da70adf757a30f05334ac053b /source/kit_test | |
parent | 653f939ac56ad27468318e4b9913f23d31105098 (diff) | |
download | kit-f56c8875766f2de7ad6f69a6bd93685ac1ddd8dd.zip |
Add limit checks
Diffstat (limited to 'source/kit_test')
-rw-r--r-- | source/kit_test/run_tests.c | 12 |
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; |