mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
feat(test): add tests for new allocation helpers
This commit is contained in:
parent
4feaa132ab
commit
61faa87c31
1 changed files with 33 additions and 0 deletions
|
|
@ -1,6 +1,19 @@
|
|||
#include "bc/Memory.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
struct TestObject {
|
||||
int m = 1;
|
||||
TestObject() {
|
||||
// printf("TestObject created\n");
|
||||
}
|
||||
|
||||
~TestObject() {
|
||||
// printf("TestObject destroyed\n");
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("Blizzard::Memory::Allocate", "[memory]") {
|
||||
SECTION("allocates memory and returns pointer") {
|
||||
auto ptr = Blizzard::Memory::Allocate(100);
|
||||
|
|
@ -18,3 +31,23 @@ TEST_CASE("Blizzard::Memory::Allocate", "[memory]") {
|
|||
Blizzard::Memory::Free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("helper macros", "[memory]") {
|
||||
SECTION("ALLOCATE memory and return pointer") {
|
||||
auto m = ALLOC(128);
|
||||
REQUIRE(m);
|
||||
FREE(m);
|
||||
}
|
||||
|
||||
SECTION("NEW object and DELETE it") {
|
||||
auto m = NEW(TestObject);
|
||||
DEL(m);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("operator new", "[memory]") {
|
||||
SECTION("allocate memory through the new operator") {
|
||||
auto m = new uint8_t[0xCAFE];
|
||||
delete m;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue