Index: runtime/vm/fixed_cache_test.cc |
diff --git a/runtime/vm/fixed_cache_test.cc b/runtime/vm/fixed_cache_test.cc |
index a4fbf28e83ee0f30e4f9315c919282b0850489e1..bd795b2be04ffd15d2bdd16c1846b2ab445d93f8 100644 |
--- a/runtime/vm/fixed_cache_test.cc |
+++ b/runtime/vm/fixed_cache_test.cc |
@@ -47,17 +47,25 @@ struct Resource { |
Resource() : id(0), stuff(NULL) {} |
explicit Resource(int id_) : id(id_), stuff(new int) {} |
+ Resource(const Resource& r) { |
+ id = r.id; |
+ stuff = new int(*r.stuff); |
+ } |
+ |
+ Resource& operator=(const Resource& r) { |
+ delete stuff; |
+ id = r.id; |
+ stuff = new int(*r.stuff); |
+ return *this; |
+ } |
+ |
+ ~Resource() { delete stuff; } |
Vyacheslav Egorov (Google)
2017/03/10 08:29:33
You need a test that destructor is actually invoke
Dmitry Olshansky
2017/03/13 12:26:31
Done.
|
int id; |
int* stuff; |
}; |
-static void freeResource(Resource* res) { |
- delete res->stuff; |
-} |
- |
- |
-UNIT_TEST_CASE(FixedCacheFullDeleter) { |
- FixedCache<int, Resource, 6> cache(freeResource); |
+UNIT_TEST_CASE(FixedCacheFullResource) { |
+ FixedCache<int, Resource, 6> cache; |
cache.Insert(10, Resource(2)); |
cache.Insert(20, Resource(4)); |
cache.Insert(40, Resource(16)); |