summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vespalib/src/tests/datastore/unique_store/unique_store_test.cpp')
-rw-r--r--vespalib/src/tests/datastore/unique_store/unique_store_test.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
index 917c91f2dff..7f279689985 100644
--- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
+++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
@@ -9,6 +9,7 @@
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/test/datastore/buffer_stats.h>
#include <vespa/vespalib/test/insertion_operators.h>
+#include <vespa/vespalib/test/memory_allocator_observer.h>
#include <vespa/vespalib/util/traits.h>
#include <vector>
@@ -21,6 +22,9 @@ using namespace vespalib::datastore;
using vespalib::ArrayRef;
using generation_t = vespalib::GenerationHandler::generation_t;
using vespalib::datastore::test::BufferStats;
+using vespalib::alloc::MemoryAllocator;
+using vespalib::alloc::test::MemoryAllocatorObserver;
+using AllocStats = MemoryAllocatorObserver::Stats;
template <typename UniqueStoreT>
struct TestBaseValues {
@@ -39,6 +43,7 @@ struct TestBase : public ::testing::Test {
using ReferenceStoreValueType = std::conditional_t<std::is_same_v<ValueType, const char *>, std::string, ValueType>;
using ReferenceStore = std::map<EntryRef, std::pair<ReferenceStoreValueType,uint32_t>>;
+ AllocStats stats;
UniqueStoreType store;
ReferenceStore refStore;
generation_t generation;
@@ -148,7 +153,8 @@ struct TestBase : public ::testing::Test {
template <typename UniqueStoreTypeAndDictionaryType>
TestBase<UniqueStoreTypeAndDictionaryType>::TestBase()
- : store(),
+ : stats(),
+ store(std::make_unique<MemoryAllocatorObserver>(stats)),
refStore(),
generation(1)
{
@@ -424,6 +430,15 @@ TYPED_TEST(TestBase, store_can_be_enumerated)
EXPECT_EQ(2u, enumValue2);
}
+TYPED_TEST(TestBase, provided_memory_allocator_is_used)
+{
+ if constexpr (std::is_same_v<const char *, typename TestFixture::ValueType>) {
+ EXPECT_EQ(AllocStats(18, 0), this->stats);
+ } else {
+ EXPECT_EQ(AllocStats(1, 0), this->stats);
+ }
+}
+
#pragma GCC diagnostic pop
TEST_F(DoubleTest, nan_is_handled)