diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-04 14:03:07 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-06 15:17:52 +0200 |
commit | 612339e574293b248c44cc04a4fae0c77a64ad53 (patch) | |
tree | ebc9a280800f40e26ef32fa9189845ba74bc9c40 /o3tl | |
parent | 4435135e68f7d1024875defc3df18de183607048 (diff) |
Add a glyph-bound-rect cache to the font cache
This way the font cache can correctly invalidate the cached glyph
rects when a font is dropped from the cache.
Change-Id: I050866099742334f01cac1b872228a017ddb5e9b
Reviewed-on: https://gerrit.libreoffice.org/61371
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'o3tl')
-rw-r--r-- | o3tl/qa/test-lru_map.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx index 096b21ec5189..7a4886d3be3e 100644 --- a/o3tl/qa/test-lru_map.cxx +++ b/o3tl/qa/test-lru_map.cxx @@ -27,6 +27,7 @@ public: void testReplaceValue(); void testLruRemoval(); void testCustomHash(); + void testRemoveIf(); CPPUNIT_TEST_SUITE(lru_map_test); CPPUNIT_TEST(testBaseUsage); @@ -34,6 +35,7 @@ public: CPPUNIT_TEST(testReplaceValue); CPPUNIT_TEST(testLruRemoval); CPPUNIT_TEST(testCustomHash); + CPPUNIT_TEST(testRemoveIf); CPPUNIT_TEST_SUITE_END(); }; @@ -234,6 +236,59 @@ void lru_map_test::testCustomHash() CPPUNIT_ASSERT_EQUAL(13, lru.find(TestClassKey(2,1))->second); } +void lru_map_test::testRemoveIf() +{ + typedef o3tl::lru_map<int, int> IntMap; + typedef IntMap::key_value_pair_t IntMapPair; + struct limit_except : public std::exception {}; + + IntMap lru(6); + int i = 0; + for (; i < 8; i++) + lru.insert({i, i}); + CPPUNIT_ASSERT_EQUAL(size_t(6), lru.size()); + // now contains 7..2 + + // remove everything < 4 from the back + try + { + lru.remove_if([] (IntMapPair const& rPair) { + if (rPair.first >= 4) + throw limit_except(); + return true; + }); + CPPUNIT_ASSERT(false); // not reached + } + catch (limit_except) + { + // contains 7..4 + CPPUNIT_ASSERT_EQUAL(size_t(4), lru.size()); + } + + // remove all even numbers + lru.remove_if([] (IntMapPair const& rPair) { return (0 == rPair.first % 2); }); + CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size()); + // contains 7, 5 + + lru.insert({5, 5}); + // contains 5, 7 + + i = 5; + for (auto &rPair : lru) + { + CPPUNIT_ASSERT_EQUAL(i, rPair.first); + i += 2; + } + + // remove the first item + lru.remove_if([] (IntMapPair const& rPair) { return (rPair.first == 5); }); + CPPUNIT_ASSERT_EQUAL(size_t(1), lru.size()); + + // remove the only item + lru.remove_if([] (IntMapPair const& rPair) { return (rPair.first == 7); }); + CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(lru_map_test); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |