TEST(TestHarness_c, count_mallocs) { cpputest_malloc_count_reset(); void * m1 = cpputest_malloc(10); void * m2 = cpputest_malloc(11); void * m3 = cpputest_malloc(12); cpputest_free(m1); cpputest_free(m2); cpputest_free(m3); LONGS_EQUAL(3, cpputest_malloc_get_count()); }
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); }
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(BasicBehavior, freeInvalidatesMemory) { unsigned char* memory = (unsigned char*) cpputest_malloc(sizeof(unsigned char)); *memory = 0xAD; cpputest_free(memory); CHECK(*memory != 0xAD); }
TEST(TestHarness_c, cpputest_strndup) { char * mem = cpputest_strndup("0123456789", 3); CHECK(0 != mem); STRCMP_EQUAL("012", mem) cpputest_free(mem); }
TEST(TestHarness_c, cpputest_strdup) { char * mem = cpputest_strdup("0123456789"); CHECK(NULLPTR != mem); STRCMP_EQUAL("0123456789", mem); cpputest_free(mem); }
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); }
void teardown() { SlimList_Destroy(slimList); if (deserializedList) SlimList_Destroy(deserializedList); if (serializedList != 0) cpputest_free((void*)serializedList); }
void teardown() { LemmaList_Destroy(lemmaList); if (deserializedList) LemmaList_Destroy(deserializedList); if (serializedList != 0) cpputest_free(serializedList); }
TEST(TestHarness_c, cpputest_realloc_larger) { const char* number_string = "123456789"; char* mem1 = (char*) cpputest_malloc(10); PlatformSpecificStrCpy(mem1, number_string); CHECK(mem1 != 0); char* mem2 = (char*) cpputest_realloc(mem1, 1000); CHECK(mem2 != 0); STRCMP_EQUAL(number_string, mem2); cpputest_free(mem2); }
TEST(TestHarness_c, cpputest_realloc_larger) { const char* number_string = "123456789"; char* mem1 = (char*) cpputest_malloc(10); SimpleString::StrNCpy(mem1, number_string, 10); CHECK(mem1 != NULLPTR); char* mem2 = (char*) cpputest_realloc(mem1, 1000); CHECK(mem2 != NULLPTR); STRCMP_EQUAL(number_string, mem2); cpputest_free(mem2); }
TEST(TestHarness_c, cpputest_calloc) { void * mem = cpputest_calloc(10, 10); CHECK(0 != mem); cpputest_free(mem); }