Correct and revise OpenGL texture pooling (#2709)

This commit is contained in:
alasram
2024-08-29 14:13:26 -07:00
committed by GitHub
parent 290bf927f5
commit b850c257a3
79 changed files with 817 additions and 247 deletions

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