2016-12-01 00:20:48 +08:00
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
#include "data_structures/ptr_int.hpp"
|
|
|
|
|
2016-12-02 16:37:08 +08:00
|
|
|
TEST_CASE("Size of pointer integer object")
|
|
|
|
{
|
|
|
|
REQUIRE(sizeof(PtrInt<int *, 1, int>) == sizeof(uintptr_t));
|
|
|
|
}
|
|
|
|
|
2016-12-01 00:20:48 +08:00
|
|
|
TEST_CASE("Construct and read pointer integer pair type")
|
|
|
|
{
|
|
|
|
auto ptr1 = std::make_unique<int>(2);
|
|
|
|
PtrInt<int *, 2, int> pack1(ptr1.get(), 1);
|
|
|
|
|
|
|
|
REQUIRE(pack1.get_int() == 1);
|
|
|
|
REQUIRE(pack1.get_ptr() == ptr1.get());
|
|
|
|
|
|
|
|
|
|
|
|
auto ptr2 = std::make_unique<int>(2);
|
2016-12-02 16:37:08 +08:00
|
|
|
PtrInt<int *, 3, int> pack2(ptr2.get(), 4);
|
2016-12-01 00:20:48 +08:00
|
|
|
|
2016-12-02 16:37:08 +08:00
|
|
|
REQUIRE(pack2.get_int() == 4);
|
2016-12-01 00:20:48 +08:00
|
|
|
REQUIRE(pack2.get_ptr() == ptr2.get());
|
|
|
|
}
|