diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-06-09 17:10:42 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-06-09 21:20:09 +0200 |
commit | 62b58e88d897f51a7c4e12b41d14121ab8d3396f (patch) | |
tree | 291bc6fe16262c091fb4f045a0897b495044a7dd /o3tl/qa | |
parent | e9838a1d1de8d9d44fd1bac603a1d29ff97a12ff (diff) |
allow altering the max size of o3tl::lru_cache
Change-Id: Id119b70275e1c88a8c57f89d915241427be9dbf5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116927
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'o3tl/qa')
-rw-r--r-- | o3tl/qa/test-lru_map.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx index ef46f44d17b9..aac8a3e25283 100644 --- a/o3tl/qa/test-lru_map.cxx +++ b/o3tl/qa/test-lru_map.cxx @@ -29,6 +29,7 @@ public: void testCustomHash(); void testRemoveIf(); void testNoAutoCleanup(); + void testChangeMaxSize(); CPPUNIT_TEST_SUITE(lru_map_test); CPPUNIT_TEST(testBaseUsage); @@ -38,6 +39,7 @@ public: CPPUNIT_TEST(testCustomHash); CPPUNIT_TEST(testRemoveIf); CPPUNIT_TEST(testNoAutoCleanup); + CPPUNIT_TEST(testChangeMaxSize); CPPUNIT_TEST_SUITE_END(); }; @@ -310,6 +312,18 @@ void lru_map_test::testNoAutoCleanup() } } +void lru_map_test::testChangeMaxSize() +{ + o3tl::lru_map<int, int> lru(3); + CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); + lru.insert({ 0, 0 }); + lru.insert({ 1, 1 }); + lru.insert({ 2, 2 }); + CPPUNIT_ASSERT_EQUAL(size_t(3), lru.size()); + lru.setMaxSize(1); + CPPUNIT_ASSERT_EQUAL(size_t(1), lru.size()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(lru_map_test); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |