109 |
109 |
110 TEST(TestingAllocator, ExpectFree) { |
110 TEST(TestingAllocator, ExpectFree) { |
111 CxTestingAllocator allocator; |
111 CxTestingAllocator allocator; |
112 |
112 |
113 ASSERT_TRUE(allocator.verify()); |
113 ASSERT_TRUE(allocator.verify()); |
|
114 EXPECT_FALSE(allocator.used()); |
114 auto ptr = cxMalloc(&allocator, 16); |
115 auto ptr = cxMalloc(&allocator, 16); |
|
116 EXPECT_TRUE(allocator.used()); |
115 ASSERT_NE(ptr, nullptr); |
117 ASSERT_NE(ptr, nullptr); |
116 EXPECT_FALSE(allocator.verify()); |
118 EXPECT_FALSE(allocator.verify()); |
117 |
119 |
118 cxFree(&allocator, ptr); |
120 cxFree(&allocator, ptr); |
119 EXPECT_TRUE(allocator.verify()); |
121 EXPECT_TRUE(allocator.verify()); |
155 EXPECT_TRUE(allocator.verify()); |
157 EXPECT_TRUE(allocator.verify()); |
156 } |
158 } |
157 |
159 |
158 TEST(TestingAllocator, CallocInitializes) { |
160 TEST(TestingAllocator, CallocInitializes) { |
159 CxTestingAllocator allocator; |
161 CxTestingAllocator allocator; |
160 const char* zeros[16] = {0}; |
162 const char zeros[16] = {0}; |
161 auto ptr = cxCalloc(&allocator, 16, 1); |
163 auto ptr = cxCalloc(&allocator, 16, 1); |
162 EXPECT_EQ(memcmp(ptr, zeros, 16), 0); |
164 EXPECT_EQ(memcmp(ptr, zeros, 16), 0); |
163 cxFree(&allocator, ptr); |
165 cxFree(&allocator, ptr); |
164 EXPECT_TRUE(allocator.verify()); |
166 EXPECT_TRUE(allocator.verify()); |
165 } |
167 } |