Home | History | Annotate | Download | only in tests

Lines Matching refs:test_data

48 static void AllocPtr(TestDataType* test_data, size_t size) {
49 test_data->allocs.resize(test_data->allocs.size() + 1);
50 AllocDataType* alloc = &test_data->allocs.back();
59 static void FreePtrs(TestDataType* test_data) {
60 for (size_t i = 0; i < test_data->allocs.size(); i++) {
61 free(test_data->allocs[i].ptr);
66 TestDataType* test_data = reinterpret_cast<TestDataType*>(data);
68 test_data->total_allocated_bytes += size;
76 for (size_t i = 0; i < test_data->allocs.size(); i++) {
77 uintptr_t ptr = reinterpret_cast<uintptr_t>(test_data->allocs[i].ptr);
79 test_data->allocs[i].count++;
82 if (max_size > test_data->allocs[i].size) {
83 test_data->allocs[i].size_reported = test_data->allocs[i].size;
85 test_data->allocs[i].size_reported = max_size;
91 static void VerifyPtrs(TestDataType* test_data) {
92 test_data->total_allocated_bytes = 0;
100 malloc_iterate(start, end - start, SavePointers, test_data);
105 for (size_t i = 0; i < test_data->allocs.size(); i++) {
106 EXPECT_EQ(1UL, test_data->allocs[i].count) << "Failed on size " << test_data->allocs[i].size;
107 if (test_data->allocs[i].count == 1) {
108 EXPECT_EQ(test_data->allocs[i].size, test_data->allocs[i].size_reported);
113 static void AllocateSizes(TestDataType* test_data, const std::vector<size_t>& sizes) {
127 AllocPtr(test_data, size);
137 TestDataType test_data;
146 AllocateSizes(&test_data, sizes);
149 VerifyPtrs(&test_data);
151 FreePtrs(&test_data);
161 TestDataType test_data;
165 AllocateSizes(&test_data, sizes);
168 VerifyPtrs(&test_data);
170 FreePtrs(&test_data);
181 TestDataType test_data = {};
189 malloc_iterate(start, end - start, SavePointers, &test_data);
194 ASSERT_EQ(0UL, test_data.total_allocated_bytes);