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); }
static void countdown() { if (malloc_out_of_memory_counter <= NO_COUNTDOWN) return; if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) return; malloc_out_of_memory_counter--; if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) cpputest_malloc_set_out_of_memory(); }
void cpputest_malloc_set_out_of_memory_countdown(int count) { malloc_out_of_memory_counter = count; if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) cpputest_malloc_set_out_of_memory(); }