Make folly's T_CHECK_TIMEOUT/T_CHECK_TIME_LT use SKIP() on failure
[folly.git] / folly / test / AtomicUnorderedMapTest.cpp
index 5d4e5a390c0eb154f4cc2c05e8ca918efb3388d6..b830a3886235abf0c8522f4dce4e7522eb76b813 100644 (file)
@@ -94,8 +94,8 @@ using UIM =
                              (boost::has_trivial_destructor<Key>::value &&
                               boost::has_trivial_destructor<Value>::value),
                              Atom,
-                             Allocator,
-                             IndexType>;
+                             IndexType,
+                             Allocator>;
 
 namespace {
 template <typename T>
@@ -134,6 +134,26 @@ TYPED_TEST(AtomicUnorderedInsertMapTest, basic) {
   EXPECT_TRUE(a != b);
 }
 
+TEST(AtomicUnorderedInsertMap, load_factor) {
+  AtomicUnorderedInsertMap<int, bool> m(5000, 0.5f);
+
+  // we should be able to put in much more than 5000 things because of
+  // our load factor request
+  for (int i = 0; i < 10000; ++i) {
+    m.emplace(i, true);
+  }
+}
+
+TEST(AtomicUnorderedInsertMap, capacity_exceeded) {
+  AtomicUnorderedInsertMap<int, bool> m(5000, 1.0f);
+
+  EXPECT_THROW({
+    for (int i = 0; i < 6000; ++i) {
+      m.emplace(i, false);
+    }
+  }, std::bad_alloc);
+}
+
 TYPED_TEST(AtomicUnorderedInsertMapTest, value_mutation) {
   UIM<int, MutableAtom<int>, TypeParam> m(100);