memgraph/tests/unit/ptr_int.cpp

31 lines
646 B
C++
Raw Normal View History

2016-12-23 02:28:21 +08:00
#include "gtest/gtest.h"
#include "data_structures/ptr_int.hpp"
2016-12-23 02:28:21 +08:00
TEST(PtrInt, SizeOf)
{
2016-12-23 02:28:21 +08:00
ASSERT_EQ(sizeof(PtrInt<int *, 1, int>), sizeof(uintptr_t));
}
2016-12-23 02:28:21 +08:00
TEST(PtrInt, ConstructionAndRead)
{
auto ptr1 = std::make_unique<int>(2);
PtrInt<int *, 2, int> pack1(ptr1.get(), 1);
2016-12-23 02:28:21 +08:00
ASSERT_EQ(pack1.get_int(), 1);
ASSERT_EQ(pack1.get_ptr(), ptr1.get());
auto ptr2 = std::make_unique<int>(2);
PtrInt<int *, 3, int> pack2(ptr2.get(), 4);
2016-12-23 02:28:21 +08:00
ASSERT_EQ(pack2.get_int(), 4);
ASSERT_EQ(pack2.get_ptr(), ptr2.get());
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}