diff options
author | Frank Richter <frank.richter@gmail.com> | 2021-12-21 12:39:17 +0100 |
---|---|---|
committer | Frank Richter <frank.richter@gmail.com> | 2021-12-21 12:48:51 +0100 |
commit | d7105c20a9020116bd5bdbacaa61e9458f53ea52 (patch) | |
tree | d9b703cc0d084f73397e2feadc47238a8a205025 /test/test-api.c | |
parent | 6ead2840ec620f1fc06297c310c902e56835c0a7 (diff) |
Move test macros/helpers to a separate header
Diffstat (limited to 'test/test-api.c')
-rw-r--r-- | test/test-api.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/test/test-api.c b/test/test-api.c index f057799..8ecd31a 100644 --- a/test/test-api.c +++ b/test/test-api.c @@ -23,7 +23,6 @@ we therefore test the API over various inputs. Please add more tests :-) [1] https://github.com/daanx/mimalloc-bench */ -#include <stdio.h> #include <assert.h> #include <stdbool.h> #include <stdint.h> @@ -36,33 +35,7 @@ we therefore test the API over various inputs. Please add more tests :-) #include "mimalloc.h" // #include "mimalloc-internal.h" -// --------------------------------------------------------------------------- -// Test macros: CHECK(name,predicate) and CHECK_BODY(name,body) -// --------------------------------------------------------------------------- -static int ok = 0; -static int failed = 0; - -#define CHECK_BODY(name,body) \ - do { \ - fprintf(stderr,"test: %s... ", name ); \ - bool result = true; \ - do { body } while(false); \ - if (!(result)) { \ - failed++; \ - fprintf(stderr, \ - "\n FAILED: %s:%d:\n %s\n", \ - __FILE__, \ - __LINE__, \ - #body); \ - /* exit(1); */ \ - } \ - else { \ - ok++; \ - fprintf(stderr,"ok.\n"); \ - } \ - } while (false) - -#define CHECK(name,expr) CHECK_BODY(name,{ result = (expr); }) +#include "testhelper.h" // --------------------------------------------------------------------------- // Test functions @@ -219,10 +192,7 @@ int main(void) { // --------------------------------------------------- // Done // ---------------------------------------------------[] - fprintf(stderr,"\n\n---------------------------------------------\n" - "succeeded: %i\n" - "failed : %i\n\n", ok, failed); - return failed; + return print_test_summary(); } // --------------------------------------------------- |