Correct and revise OpenGL texture pooling (#2709)
This commit is contained in:
38
test/util/lru_cache.test.cpp
Normal file
38
test/util/lru_cache.test.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <mbgl/util/lru_cache.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TEST(LRU, LRU) {
|
||||
LRU<int> lru;
|
||||
EXPECT_TRUE(lru.empty());
|
||||
|
||||
lru.touch(1);
|
||||
lru.touch(2);
|
||||
lru.touch(3);
|
||||
EXPECT_FALSE(lru.empty());
|
||||
EXPECT_EQ(lru.size(), 3);
|
||||
|
||||
lru.remove(2);
|
||||
lru.remove(77);
|
||||
EXPECT_EQ(lru.evict(), 1);
|
||||
EXPECT_FALSE(lru.empty());
|
||||
EXPECT_EQ(lru.size(), 1);
|
||||
|
||||
lru.touch(4);
|
||||
EXPECT_EQ(lru.evict(), 3);
|
||||
EXPECT_FALSE(lru.empty());
|
||||
EXPECT_EQ(lru.size(), 1);
|
||||
|
||||
EXPECT_FALSE(lru.isHit(3));
|
||||
EXPECT_FALSE(lru.isHit(33));
|
||||
EXPECT_TRUE(lru.isHit(4));
|
||||
|
||||
EXPECT_EQ(lru.evict(), 4);
|
||||
EXPECT_TRUE(lru.empty());
|
||||
EXPECT_FALSE(lru.isHit(4));
|
||||
EXPECT_THROW(lru.evict(), std::runtime_error);
|
||||
}
|
||||
Reference in New Issue
Block a user