const Allocator& alloc = Allocator())
: allocator_(alloc)
{
- size_t capacity = maxSize / std::max(1.0f, maxLoadFactor) + 128;
+ size_t capacity = maxSize / std::min(1.0f, maxLoadFactor) + 128;
size_t avail = size_t{1} << (8 * sizeof(IndexType) - 2);
if (capacity > avail && maxSize < avail) {
// we'll do our best
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);