Add overloads of Range::{start,end}sWith with custom comparator
[folly.git] / folly / test / EvictingCacheMapTest.cpp
index cf326c923838facff72deddc841f2bb19da2fcd8..cac076412de0e07d21cedf0c14bdc9938de1c7df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#include <gtest/gtest.h>
-
 #include <set>
 
 #include <folly/EvictingCacheMap.h>
+#include <folly/portability/GTest.h>
 
 using namespace folly;
 
@@ -617,3 +616,20 @@ TEST(EvictingCacheMap, IteratorOrderingTest) {
     EXPECT_EQ(-1, expected);
   }
 }
+
+TEST(EvictingCacheMap, MoveTest) {
+  const int nItems = 1000;
+  EvictingCacheMap<int, int> map(nItems);
+  for (int i = 0; i < nItems; i++) {
+    map.set(i, i);
+    EXPECT_TRUE(map.exists(i));
+    EXPECT_EQ(i, map.get(i));
+  }
+
+  EvictingCacheMap<int, int> map2 = std::move(map);
+  EXPECT_TRUE(map.empty());
+  for (int i = 0; i < nItems; i++) {
+    EXPECT_TRUE(map2.exists(i));
+    EXPECT_EQ(i, map2.get(i));
+  }
+}