aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/stllike
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-05-11 11:12:29 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-05-11 11:12:29 +0000
commitefe84b0f2c3720e98a26a509fd70a9e2307e14db (patch)
treee42bc81d52bf766d8b669c2f13ba1626b1d72ea9 /vespalib/src/tests/stllike
parent331679dc85953f6ab6db2706da92722b03277967 (diff)
Use a smart allocator for allocating memory for large 'long' lived
vectors. Large vectors will be allocated directly with mmap. This cancels the main reason for using vespalib::Array.
Diffstat (limited to 'vespalib/src/tests/stllike')
-rw-r--r--vespalib/src/tests/stllike/hash_test.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp
index d23c2c6b68c..e86a9ad020a 100644
--- a/vespalib/src/tests/stllike/hash_test.cpp
+++ b/vespalib/src/tests/stllike/hash_test.cpp
@@ -4,6 +4,7 @@
#include <vespa/vespalib/stllike/hash_set.hpp>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/stllike/hash_map_equal.hpp>
+#include <vespa/vespalib/stllike/allocator.h>
#include <cstddef>
#include <algorithm>
@@ -553,4 +554,17 @@ TEST("test that begin and end are identical with empty hashtables") {
EXPECT_TRUE(empty_but_reserved.begin() == empty_but_reserved.end());
}
+TEST ("test that large_allocator works fine with std::vector") {
+ using V = std::vector<uint64_t, allocator_large<uint64_t>>;
+ V a;
+ a.push_back(1);
+ a.reserve(14);
+ for (size_t i(0); i < 400000; i++) {
+ a.push_back(i);
+ }
+ V b = std::move(a);
+ V c = b;
+ ASSERT_EQUAL(b.size(), c.size());
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }