Skip to content

Commit 2464d28

Browse files
committed
Add default constructor for node_ram_cache for testing
1 parent 6a5ee88 commit 2464d28

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/node-ram-cache.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class node_ram_cache
4848
};
4949

5050
public:
51+
/**
52+
* The default constructor creates a "dummy" cache which will never
53+
* cache anything. It is used for testing.
54+
*/
55+
node_ram_cache() = default;
56+
5157
node_ram_cache(int strategy, int cacheSizeMB);
5258

5359
node_ram_cache(node_ram_cache const &) = delete;
@@ -96,7 +102,7 @@ class node_ram_cache
96102
osmium::Location get_sparse(osmid_t id) const;
97103
osmium::Location get_dense(osmid_t id) const;
98104

99-
int allocStrategy;
105+
int allocStrategy = 0;
100106

101107
ramNodeBlock *blocks = nullptr;
102108
int usedBlocks = 0;
@@ -113,7 +119,7 @@ class node_ram_cache
113119
osmid_t maxSparseId = 0;
114120

115121
int64_t cacheUsed = 0;
116-
int64_t cacheSize;
122+
int64_t cacheSize = 0;
117123
osmid_t storedNodes = 0;
118124
osmid_t totalNodes = 0;
119125
long nodesCacheHits = 0;

tests/test-persistent-cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST_CASE("Persistent cache", "[NoDB]")
2929
{
3030
options_t const options = testing::opt_t().flatnodes();
3131
testing::cleanup::file_t flatnode_cleaner{options.flat_node_file.get()};
32-
auto ram_cache = std::make_shared<node_ram_cache>(0, 0); // empty cache
32+
auto ram_cache = std::make_shared<node_ram_cache>(); // dummy cache
3333

3434
// create a new cache
3535
{

0 commit comments

Comments
 (0)