25 #include "lib/res/file/file_cache.h"
35 typedef std::map<void*, size_t> AllocMap;
41 size_t total_size_used = 0;
45 total_size_used += size;
50 p = file_cache_allocator_alloc(size);
55 size_t chosen_idx = (size_t)
rand(0, (
size_t)allocations.size());
56 AllocMap::iterator it = allocations.begin();
57 for(; chosen_idx != 0; chosen_idx--)
59 file_cache_allocator_free(it->first, it->second);
60 allocations.erase(it);
64 TS_ASSERT_EQUALS(allocations.find(p), allocations.end());
65 allocations[p] = size;
71 file_cache_allocator_reset();
void test_cache_allocator()
size_t rand(size_t min_inclusive, size_t max_exclusive)
return random integer in [min, max).