TEST(TestHarness_c, cpputest_malloc_out_of_memory) { cpputest_malloc_set_out_of_memory(); CHECK(0 == cpputest_malloc(100)); cpputest_malloc_set_not_out_of_memory(); void * mem = cpputest_malloc(100); CHECK(0 != mem); cpputest_free(mem); }
TEST(TestHarness_c, cpputest_malloc_out_of_memory_after_n_mallocs) { cpputest_malloc_set_out_of_memory_countdown(3); void * m1 = cpputest_malloc(10); void * m2 = cpputest_malloc(11); void * m3 = cpputest_malloc(12); CHECK(m1); CHECK(m2); POINTERS_EQUAL(0, m3); cpputest_malloc_set_not_out_of_memory(); cpputest_free(m1); cpputest_free(m2); }
TEST(TestHarness_c, cpputest_malloc_out_of_memory_after_n_mallocs) { cpputest_malloc_set_out_of_memory_countdown(3); void * m1 = cpputest_malloc(10); void * m2 = cpputest_malloc(11); void * m3 = cpputest_malloc(12); CHECK(m1 != NULLPTR); CHECK(m2 != NULLPTR); CHECK(m3 == NULLPTR); cpputest_malloc_set_not_out_of_memory(); cpputest_free(m1); cpputest_free(m2); }