From 16a338e173083954a9932a3a4005f172309c784e Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Fri, 5 Oct 2018 17:08:49 +0200 Subject: Convert ImplFontCache to use o3tl::lru_map We still do our own cleanup of the LRU map, as we can't drop any fonts in use. Change-Id: I8ec5c6ce8f80893635621357e9085950e7010f5b Reviewed-on: https://gerrit.libreoffice.org/61455 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski --- o3tl/qa/test-lru_map.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'o3tl') diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx index 7a4886d3be3e..a7f9777e2c5f 100644 --- a/o3tl/qa/test-lru_map.cxx +++ b/o3tl/qa/test-lru_map.cxx @@ -28,6 +28,7 @@ public: void testLruRemoval(); void testCustomHash(); void testRemoveIf(); + void testNoAutoCleanup(); CPPUNIT_TEST_SUITE(lru_map_test); CPPUNIT_TEST(testBaseUsage); @@ -36,6 +37,7 @@ public: CPPUNIT_TEST(testLruRemoval); CPPUNIT_TEST(testCustomHash); CPPUNIT_TEST(testRemoveIf); + CPPUNIT_TEST(testNoAutoCleanup); CPPUNIT_TEST_SUITE_END(); }; @@ -289,6 +291,24 @@ void lru_map_test::testRemoveIf() CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); } +void lru_map_test::testNoAutoCleanup() +{ + o3tl::lru_map lru(0); + CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); + lru.insert({0,0}); + lru.insert({1,1}); + CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size()); + lru.insert({0,0}); + CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size()); + + int i = 0; + for (auto &rPair : lru) + { + CPPUNIT_ASSERT_EQUAL(i, rPair.first); + ++i; + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(lru_map_test); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit