diff options
-rw-r--r-- | tests/test.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/test.c b/tests/test.c index 3dc9236c..f0dcddc8 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1093,13 +1093,8 @@ void * GC_CALLBACK inc_int_counter(void *pcounter) void run_one_test(void) { # ifndef DBG_HDRS_ALL - char *x; + char *x, *y; char **z; -# ifdef LINT - char *y = 0; -# else - char *y = (char *)(GC_word)fail_proc1; -# endif CLOCK_TYPE typed_time; # endif CLOCK_TYPE start_time; @@ -1114,21 +1109,35 @@ void run_one_test(void) # endif GC_FREE(0); # ifndef DBG_HDRS_ALL - collectable_count += 3; - if ((GC_size(GC_malloc(7)) != 8 && - GC_size(GC_malloc(7)) != MIN_WORDS * sizeof(GC_word)) - || GC_size(GC_malloc(15)) != 16) { + collectable_count++; + x = (char*)GC_malloc(7); + CHECK_OUT_OF_MEMORY(x); + collectable_count++; + y = (char*)GC_malloc(7); + CHECK_OUT_OF_MEMORY(y); + if (GC_size(x) != 8 && GC_size(y) != MIN_WORDS * sizeof(GC_word)) { GC_printf("GC_size produced unexpected results\n"); FAIL; } + collectable_count++; + x = (char*)GC_malloc(15); + CHECK_OUT_OF_MEMORY(x); + if (GC_size(x) != 16) { + GC_printf("GC_size produced unexpected results 2\n"); + FAIL; + } collectable_count += 1; - if (GC_size(GC_malloc(0)) != MIN_WORDS * sizeof(GC_word)) { + x = (char*)GC_malloc(0); + CHECK_OUT_OF_MEMORY(x); + if (GC_size(x) != MIN_WORDS * sizeof(GC_word)) { GC_printf("GC_malloc(0) failed: GC_size returns %ld\n", - (unsigned long)GC_size(GC_malloc(0))); + (unsigned long)GC_size(x)); FAIL; } collectable_count += 1; - if (GC_size(GC_malloc_uncollectable(0)) != MIN_WORDS * sizeof(GC_word)) { + x = (char*)GC_malloc_uncollectable(0); + CHECK_OUT_OF_MEMORY(x); + if (GC_size(x) != MIN_WORDS * sizeof(GC_word)) { GC_printf("GC_malloc_uncollectable(0) failed\n"); FAIL; } @@ -1136,6 +1145,7 @@ void run_one_test(void) GC_is_visible_print_proc = fail_proc1; collectable_count += 1; x = GC_malloc(16); + CHECK_OUT_OF_MEMORY(x); if (GC_base(GC_PTR_ADD(x, 13)) != x) { GC_printf("GC_base(heap ptr) produced incorrect result\n"); FAIL; @@ -1147,6 +1157,7 @@ void run_one_test(void) GC_printf("Bad INCR/DECR result\n"); FAIL; } + y = (char *)(GC_word)fail_proc1; # ifndef PCR if (GC_base(y) != 0) { GC_printf("GC_base(fn_ptr) produced incorrect result\n"); |