Use UnitTest-Cpp library for testing
This commit is contained in:
parent
79d018ffb4
commit
b8bcf58a29
53 changed files with 1046 additions and 1383 deletions
|
|
@ -1,12 +1,9 @@
|
|||
|
||||
#include "Testing.hpp"
|
||||
#include "UnitTest++/UnitTest++.h"
|
||||
|
||||
#include "Allocators.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
#include "ChunkAllocator.hpp"
|
||||
#include "HeapAllocator.hpp"
|
||||
#include "HeapAllocatorGlobal.hpp"
|
||||
#include "PoolAllocator.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace tp;
|
||||
|
|
@ -80,7 +77,7 @@ private:
|
|||
if (mIsLoaded[idx]) return;
|
||||
verifyIntegrity();
|
||||
mLoaded[idx] = new (mAlloc.allocate(sizeof(TestStruct))) TestStruct(mData[idx]);
|
||||
TEST(mLoaded[idx]);
|
||||
ASSERT(mLoaded[idx]);
|
||||
mIsLoaded[idx] = true;
|
||||
mLoadedNum++;
|
||||
verifyIntegrity();
|
||||
|
|
@ -181,7 +178,7 @@ private:
|
|||
uint1 val = *address;
|
||||
*address = 5;
|
||||
|
||||
TEST(!mAlloc.checkWrap());
|
||||
ASSERT(!mAlloc.checkWrap());
|
||||
|
||||
*address = val;
|
||||
}
|
||||
|
|
@ -208,38 +205,45 @@ void testAlloc() {
|
|||
TestBenches<size, Alloc> heapTests{};
|
||||
heapTests.runTests();
|
||||
} catch (...) {
|
||||
TEST(false);
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(GlobalHeap) { testAlloc<HeapAllocGlobal>(); }
|
||||
SUITE(Allocators) {
|
||||
TEST(GlobalHeap) { testAlloc<HeapAllocGlobal>(); }
|
||||
|
||||
TEST_DEF_STATIC(Heap) { testAlloc<tp::HeapAlloc>(); }
|
||||
TEST(Heap) { testAlloc<tp::HeapAlloc>(); }
|
||||
|
||||
TEST_DEF_STATIC(Chunk) {
|
||||
testAlloc<ChunkAlloc<TestStruct, size>>();
|
||||
testAlloc<ChunkAlloc<TestStruct, size * 2>>();
|
||||
TEST(Chunk) {
|
||||
testAlloc<ChunkAlloc<TestStruct, size>>();
|
||||
testAlloc<ChunkAlloc<TestStruct, size * 2>>();
|
||||
}
|
||||
|
||||
TEST(Pool) {
|
||||
testAlloc<PoolAlloc<TestStruct, 1>>();
|
||||
testAlloc<PoolAlloc<TestStruct, size / 100>>();
|
||||
testAlloc<PoolAlloc<TestStruct, size>>();
|
||||
}
|
||||
|
||||
TEST(Simple) {
|
||||
auto a = new TestStruct(-1);
|
||||
delete a;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(Pool) {
|
||||
testAlloc<PoolAlloc<TestStruct, 1>>();
|
||||
testAlloc<PoolAlloc<TestStruct, size / 100>>();
|
||||
testAlloc<PoolAlloc<TestStruct, size>>();
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
auto a = new TestStruct(-1);
|
||||
delete a;
|
||||
}
|
||||
int main() {
|
||||
|
||||
TEST_DEF(All) {
|
||||
testSimple();
|
||||
tp::ModuleManifest* deps[] = { &tp::gModuleAllocators, &tp::gModuleUtils, nullptr };
|
||||
tp::ModuleManifest testModule("AllocatorsTest", nullptr, nullptr, deps);
|
||||
|
||||
testGlobalHeap();
|
||||
testHeap();
|
||||
testChunk();
|
||||
testPool();
|
||||
if (!testModule.initialize()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TEST(HeapAllocGlobal::checkLeaks());
|
||||
// TEST(false);
|
||||
bool res = UnitTest::RunAllTests();
|
||||
|
||||
testModule.deinitialize();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
#include "Allocators.hpp"
|
||||
|
||||
#include "Tests.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
int main() {
|
||||
|
||||
tp::ModuleManifest* deps[] = { &tp::gModuleAllocators, &tp::gModuleUtils, nullptr };
|
||||
tp::ModuleManifest testModule("AllocatorsTest", nullptr, nullptr, deps);
|
||||
|
||||
if (!testModule.initialize()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
testAll();
|
||||
|
||||
testModule.deinitialize();
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "Testing.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
void testAll();
|
||||
Loading…
Add table
Add a link
Reference in a new issue