Skip to content

Commit 57c1670

Browse files
committed
Added more tests for IResearchMemoryManager
1 parent 8224853 commit 57c1670

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/memory/IResearchMemoryManager_tests.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,36 @@
2929

3030
using namespace irs;
3131

32+
struct LargeData {
33+
char data[1024];
34+
};
35+
36+
TEST(IResearchMemoryLimitTest, no_limit_set_allows_infinite_allocations) {
37+
38+
// The expectation is to allow potentially infinite allocations
39+
// even if we're testing with just 1MB.
40+
41+
// allocate vector
42+
ManagedVector<LargeData> vec;
43+
44+
for (size_t i = 0; i < 1024; i++) {
45+
ASSERT_NO_THROW(vec.push_back(LargeData()));
46+
}
47+
}
48+
49+
TEST(IResearchMemoryLimitTest, zero_limit_allow_infinite_allocations) {
50+
51+
auto memoryMgr = IResearchMemoryManager::GetInstance();
52+
memoryMgr->SetMemoryLimit(0);
53+
54+
// allocate vector
55+
ManagedVector<LargeData> vec;
56+
57+
for (size_t i = 0; i < 1024; i++) {
58+
ASSERT_NO_THROW(vec.push_back(LargeData()));
59+
}
60+
}
61+
3262
TEST(IResearchMemoryLimitTest, managed_allocator_smoke_test) {
3363

3464
auto memoryMgr = IResearchMemoryManager::GetInstance();

0 commit comments

Comments
 (0)