leetcode/tests/s0146_lru_cache.cpp
Sainnhe Park bef47e10bf
All checks were successful
ci/woodpecker/push/deploy Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
s0146
2023-03-18 08:42:14 +08:00

27 lines
535 B
C++

#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);
}