Stack Allocator Unit Test
Summary: Stack Allocator Unit Test Test Plan: manual (unit tests are not passing because malloc and free counters have to be added) Reviewers: sale Subscribers: sale, buda Differential Revision: https://memgraph.phacility.com/D21
This commit is contained in:
parent
4d6c315c1e
commit
dc3433aa8a
@ -3,6 +3,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "utils/exceptions/out_of_memory.hpp"
|
||||
#include "utils/likely.hpp"
|
||||
#include "utils/memory/block_allocator.hpp"
|
||||
|
||||
// http://en.cppreference.com/w/cpp/language/new
|
||||
|
@ -14,7 +14,7 @@ TEST(BlockAllocatorTest, UnusedVsReleaseSize)
|
||||
TEST(BlockAllocatorTest, CountMallocAndFreeCalls)
|
||||
{
|
||||
// TODO: implementation
|
||||
EXPECT_EQ(true, true);
|
||||
EXPECT_EQ(true, false);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
34
tests/unit/stack_allocator.cpp
Normal file
34
tests/unit/stack_allocator.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "utils/memory/stack_allocator.hpp"
|
||||
|
||||
struct Object
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
||||
Object(int a, int b) : a(a), b(b) {}
|
||||
};
|
||||
|
||||
TEST(StackAllocatorTest, AllocationAndObjectValidity)
|
||||
{
|
||||
StackAllocator allocator;
|
||||
for (int i = 0; i < 64 * 1024; ++i)
|
||||
{
|
||||
auto object = allocator.make<Object>(1, 2);
|
||||
ASSERT_EQ(object->a, 1);
|
||||
ASSERT_EQ(object->b, 2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(StackAllocatorTest, CountMallocAndFreeCalls)
|
||||
{
|
||||
// TODO: implementation
|
||||
EXPECT_EQ(true, false);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Loading…
Reference in New Issue
Block a user