Arbutils/tests/MemoryTests.cpp

27 lines
659 B
C++

#ifdef TESTS_BUILD
#include "../extern/catch.hpp"
#include "../src/Memory/NonNullOwnPtr.hpp"
#include "../src/Memory/OwnPtr.hpp"
struct TestClass{
bool GetTestBool(){
return true;
}
};
TEST_CASE("Access OwnPtr", "[Utilities]") {
auto v = Arbutils::Memory::OwnPtr<TestClass>(new TestClass());
CHECK(v->GetTestBool());
}
TEST_CASE("Access NonNullOwnPtr", "[Utilities]") {
auto v = Arbutils::Memory::NonNullOwnPtr<TestClass>(new TestClass());
CHECK(v->GetTestBool());
}
TEST_CASE("Instantiate NonNullOwnPtr fails with nullptr", "[Utilities]") {
CHECK_THROWS(Arbutils::Memory::NonNullOwnPtr<TestClass>(nullptr));
}
#endif