diff options
| author | Chen Chen <cncn@google.com> | 2020-05-13 15:35:42 -0700 |
|---|---|---|
| committer | Chen Chen <cncn@google.com> | 2020-05-13 15:40:19 -0700 |
| commit | be4b6266147a36b3ea39af6fa924c50ceb0c1104 (patch) | |
| tree | 94834a14db51b536df806b6f3e511fba1d1fdce3 /system/common/lru_unittest.cc | |
| parent | da90ba697aa4ab28517a2444449b757509cd6179 (diff) | |
BluetoothMetrics: Fix LRU eviction callback bug
Test: atest bluetooth_test_common
Bug: 156504089
Tag: #stability
Change-Id: I594070a0dc1c33bd8f971bb8a7752fd317872a55
Diffstat (limited to 'system/common/lru_unittest.cc')
| -rw-r--r-- | system/common/lru_unittest.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/system/common/lru_unittest.cc b/system/common/lru_unittest.cc index aae5827509..d8f998c20d 100644 --- a/system/common/lru_unittest.cc +++ b/system/common/lru_unittest.cc @@ -32,7 +32,7 @@ TEST(BluetoothLruCacheTest, LruCacheMainTest1) { int* value = new int(0); int dummy = 0; int* pointer = &dummy; - auto callback = [pointer](int a, int b) { (*pointer) = 1; }; + auto callback = [pointer](int a, int b) { (*pointer) = a * b; }; LruCache<int, int> cache(3, "testing", callback); // capacity = 3; cache.Put(1, 10); EXPECT_EQ(cache.Size(), 1); @@ -51,8 +51,8 @@ TEST(BluetoothLruCacheTest, LruCacheMainTest1) { EXPECT_EQ(cache.Size(), 3); cache.Put(4, 40); - EXPECT_EQ(dummy, 1); - // 2, 3, 4 should be in cache, 1 should not + EXPECT_EQ(dummy, 10); + // 2, 3, 4 should be in cache, 1 is evicted EXPECT_FALSE(cache.Get(1, value)); EXPECT_TRUE(cache.Get(4, value)); EXPECT_EQ(*value, 40); @@ -63,7 +63,8 @@ TEST(BluetoothLruCacheTest, LruCacheMainTest1) { cache.Put(5, 50); EXPECT_EQ(cache.Size(), 3); - // 2, 3, 5 should be in cache + EXPECT_EQ(dummy, 160); + // 2, 3, 5 should be in cache, 4 is evicted EXPECT_TRUE(cache.Remove(3)); cache.Put(6, 60); |
