changeset 3454:0e3c26e4b8ec

LeastRecentlyUsedIndex::GetAllKeys (test)
author Alain Mazy <alain@mazy.be>
date Wed, 03 Jul 2019 10:19:27 +0200
parents 8c663bbe5363
children d3e81dea3017
files UnitTestsSources/MemoryCacheTests.cpp
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/UnitTestsSources/MemoryCacheTests.cpp	Wed Jul 03 10:18:05 2019 +0200
+++ b/UnitTestsSources/MemoryCacheTests.cpp	Wed Jul 03 10:19:27 2019 +0200
@@ -35,6 +35,7 @@
 #include "gtest/gtest.h"
 
 #include <memory>
+#include <algorithm>
 #include <boost/thread.hpp>
 #include <boost/lexical_cast.hpp>
 
@@ -170,6 +171,24 @@
   ASSERT_TRUE(r.IsEmpty());
 }
 
+TEST(LRU, GetAllKeys)
+{
+  Orthanc::LeastRecentlyUsedIndex<std::string, int> r;
+  std::vector<std::string> keys;
+
+  r.AddOrMakeMostRecent("a", 420);
+  r.GetAllKeys(keys);
+
+  ASSERT_EQ(1, keys.size());
+  ASSERT_EQ("a", keys[0]);
+
+  r.AddOrMakeMostRecent("b", 421);
+  r.GetAllKeys(keys);
+
+  ASSERT_EQ(2, keys.size());
+  ASSERT_TRUE(std::find(keys.begin(), keys.end(),"a") != keys.end());
+  ASSERT_TRUE(std::find(keys.begin(), keys.end(),"b") != keys.end());
+}