src/libutil/tests/lru-cache.cc: Check erase()

Co-authored-by: James Lee <jbit@jbit.net>
This commit is contained in:
Eelco Dolstra 2020-06-02 12:06:59 +02:00 committed by GitHub
parent eca1ff7a9f
commit e9fee8e6a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,14 +108,14 @@ namespace nix {
TEST(LRUCache, eraseFromEmptyCache) {
LRUCache<std::string, std::string> c(10);
c.erase("foo");
ASSERT_EQ(c.erase("foo"), false);
ASSERT_EQ(c.size(), 0);
}
TEST(LRUCache, eraseMissingFromNonEmptyCache) {
LRUCache<std::string, std::string> c(10);
c.upsert("one", "eins");
c.erase("foo");
ASSERT_EQ(c.erase("foo"), false);
ASSERT_EQ(c.size(), 1);
ASSERT_EQ(c.get("one").value_or("error"), "eins");
}
@ -123,7 +123,7 @@ namespace nix {
TEST(LRUCache, eraseFromNonEmptyCache) {
LRUCache<std::string, std::string> c(10);
c.upsert("one", "eins");
c.erase("one");
ASSERT_EQ(c.erase("one"), true);
ASSERT_EQ(c.size(), 0);
ASSERT_EQ(c.get("one").value_or("empty"), "empty");
}