/Users/deen/code/yugabyte-db/src/yb/util/lru_cache-test.cc
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #include <gtest/gtest.h> |
15 | | |
16 | | #include "yb/util/lru_cache.h" |
17 | | #include "yb/util/tostring.h" |
18 | | |
19 | | namespace yb { |
20 | | |
21 | 1 | TEST(LRUCacheTest, Simple) { |
22 | 1 | LRUCache<int> cache(2); |
23 | 1 | cache.insert(1); |
24 | 1 | cache.insert(2); |
25 | 1 | cache.insert(3); |
26 | 1 | ASSERT_EQ(AsString(cache), "[3, 2]"); |
27 | 1 | ASSERT_EQ(0, cache.erase(1)); |
28 | 1 | ASSERT_EQ(1, cache.erase(3)); |
29 | 1 | ASSERT_EQ(AsString(cache), "[2]"); |
30 | 1 | } |
31 | | |
32 | | } // namespace yb |