Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/tests/BLI_cpp_type_test.cc
- This file was moved from source/blender/functions/tests/FN_cpp_type_test.cc.
| /* SPDX-License-Identifier: Apache-2.0 */ | /* SPDX-License-Identifier: Apache-2.0 */ | ||||
| #include "testing/testing.h" | #include "testing/testing.h" | ||||
| #include "FN_cpp_type.hh" | #include "BLI_cpp_type.hh" | ||||
| #include "FN_cpp_type_make.hh" | #include "BLI_cpp_type_make.hh" | ||||
| namespace blender::fn::tests { | namespace blender::tests { | ||||
| static const int default_constructed_value = 1; | static const int default_constructed_value = 1; | ||||
| static const int copy_constructed_value = 2; | static const int copy_constructed_value = 2; | ||||
| static const int move_constructed_value = 3; | static const int move_constructed_value = 3; | ||||
| static const int copy_constructed_from_value = 4; | static const int copy_constructed_from_value = 4; | ||||
| static const int move_constructed_from_value = 5; | static const int move_constructed_from_value = 5; | ||||
| static const int copy_assigned_value = 6; | static const int copy_assigned_value = 6; | ||||
| static const int copy_assigned_from_value = 7; | static const int copy_assigned_from_value = 7; | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | struct TestType { | ||||
| } | } | ||||
| uint64_t hash() const | uint64_t hash() const | ||||
| { | { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| }; | }; | ||||
| } // namespace blender::fn::tests | } // namespace blender::tests | ||||
| MAKE_CPP_TYPE(TestType, blender::fn::tests::TestType, CPPTypeFlags::BasicType) | MAKE_CPP_TYPE(TestType, blender::tests::TestType, CPPTypeFlags::BasicType) | ||||
| namespace blender::fn::tests { | namespace blender::tests { | ||||
| static const CPPType &CPPType_TestType = CPPType::get<TestType>(); | static const CPPType &CPPType_TestType = CPPType::get<TestType>(); | ||||
| TEST(cpp_type, Size) | TEST(cpp_type, Size) | ||||
| { | { | ||||
| EXPECT_EQ(CPPType_TestType.size(), sizeof(TestType)); | EXPECT_EQ(CPPType_TestType.size(), sizeof(TestType)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| int value = 42; | int value = 42; | ||||
| std::stringstream ss; | std::stringstream ss; | ||||
| CPPType::get<int32_t>().print((void *)&value, ss); | CPPType::get<int32_t>().print((void *)&value, ss); | ||||
| std::string text = ss.str(); | std::string text = ss.str(); | ||||
| EXPECT_EQ(text, "42"); | EXPECT_EQ(text, "42"); | ||||
| } | } | ||||
| } // namespace blender::fn::tests | } // namespace blender::tests | ||||