Arbutils/tests/MemoryTests.cpp

24 lines
648 B
C++
Raw Normal View History

2020-03-28 20:08:55 +00:00
#ifdef TESTS_BUILD
#include "../extern/catch.hpp"
#include "../src/Memory/NonNullOwnPtr.hpp"
#include "../src/Memory/OwnPtr.hpp"
2020-04-28 14:55:00 +00:00
struct TestClass {
bool GetTestBool() { return true; }
2020-03-28 20:08:55 +00:00
};
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