2016-12-19 03:26:08 +08:00
|
|
|
#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
|
2016-12-22 04:33:58 +08:00
|
|
|
EXPECT_EQ(true, true);
|
2016-12-19 03:26:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|