s0146
This commit is contained in:
26
tests/s0146_lru_cache.cpp
Normal file
26
tests/s0146_lru_cache.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "s0146_lru_cache.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Problem146, Case1) {
|
||||
LRUCache *lru = new LRUCache(2);
|
||||
lru->put(1, 1);
|
||||
lru->put(2, 2);
|
||||
EXPECT_EQ(lru->get(1), 1);
|
||||
lru->put(3, 3);
|
||||
EXPECT_EQ(lru->get(2), -1);
|
||||
lru->put(4, 4);
|
||||
EXPECT_EQ(lru->get(1), -1);
|
||||
EXPECT_EQ(lru->get(3), 3);
|
||||
EXPECT_EQ(lru->get(4), 4);
|
||||
}
|
||||
|
||||
TEST(Problem146, Case2) {
|
||||
LRUCache *lru = new LRUCache(2);
|
||||
lru->put(2, 1);
|
||||
lru->put(1, 1);
|
||||
lru->put(2, 3);
|
||||
lru->put(4, 1);
|
||||
EXPECT_EQ(lru->get(1), -1);
|
||||
EXPECT_EQ(lru->get(2), 3);
|
||||
}
|
Reference in New Issue
Block a user