void test_a(void) { bhp a; int i; void* v; a = mbh_new((void*)NULL, &mbh_compare_int); test_cycle(a); for (i = 0; i < 3; ++i) { mbh_insert(a, I2P(i)); } test_b(); i = mbh_size(a); if (i != 3) { ++g_fail; printf("Error: expected suspended heap to have size 3, got %d\n", i); } for (i = 0; i < 3; ++i) { v = mbh_shift(a); if (P2I(v) != i) { ++g_fail; printf("Error: heap a corrupted by heap b: expected %d, got %d\n", i, P2I(v)); } ++g_test; } }
void test_leak () { // test memory leak. for (;;) { // use top4.1 to watch memory usage test_constructor(); test_assign(); test_conversion_deref(); test_bind_cmp(); test_use(); test_cycle(); } }
int main (void) { START("CoolHandle"); test_constructor(); test_assign(); test_conversion_deref(); test_bind_cmp(); test_use(); test_cycle(); #if LEAK test_leak(); #endif SUMMARY(); return 0; }
void test_b(void) { bhp b; b = mbh_new((void*)NULL, &mbh_compare_int); test_cycle(b); }