Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: runtime/vm/fixed_cache_test.cc

Issue 2734323003: Re-landing of "replace TrySync with Metadata". (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698