/** * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #include #include #include #define NAME "Color" TEST(typeTrait, RemoveConstVolatile_1) { typedef etk::RemoveConstVolatile::type type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, RemoveConstVolatile_2) { typedef etk::RemoveConstVolatile::type type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, RemoveConstVolatile_3) { typedef etk::RemoveConstVolatile::type type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, RemoveConstVolatile_4) { typedef etk::RemoveConstVolatile::type type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, RemoveConstVolatile_5) { typedef etk::RemoveConstVolatile::type type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsVoid_1) { auto ret = etk::IsVoid::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsVoid_2) { auto ret = etk::IsVoid::value; EXPECT_EQ(ret, false); } class A {}; class B : A {}; class C {}; TEST(typeTrait, IsBaseOf_1) { auto ret = etk::IsBaseOf::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsBaseOf_2) { auto ret = etk::IsBaseOf::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsBaseOf_3) { auto ret = etk::IsBaseOf::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsBaseOf_4) { auto ret = etk::IsBaseOf::value; EXPECT_EQ(ret, true); } TEST(typeTrait, isSame_null) { typedef etk::NullPtr type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } /* TEST(typeTrait, isSame_null2) { typedef etk::NullPtr type1; auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } */ TEST(typeTrait, IsSame_1) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsSame_2) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsSame_3) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsSame_4) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsSame_5) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsSame_6) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsSame_7) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsSame_8) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsSame_9) { auto ret = etk::IsSame::value; EXPECT_EQ(ret, false); } struct K_A {}; class K_B {}; enum class K_C {}; TEST(typeTrait, IsClass_1) { auto ret = etk::IsClass::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsClass_2) { auto ret = etk::IsClass::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsClass_3) { auto ret = etk::IsClass::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsClass_4) { auto ret = etk::IsClass::value; EXPECT_EQ(ret, false); } struct J_A {}; typedef union { int a; float b; } J_B; struct J_C { J_B d; }; TEST(typeTrait, IsUnion_1) { auto ret = etk::IsUnion::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsUnion_2) { auto ret = etk::IsUnion::value; EXPECT_EQ(ret, true); } TEST(typeTrait, IsUnion_3) { auto ret = etk::IsUnion::value; EXPECT_EQ(ret, false); } TEST(typeTrait, IsUnion_4) { auto ret = etk::IsUnion::value; EXPECT_EQ(ret, false); } /* TEST_ERROR("plop1: " << (has_insertion_operator>::value)); bool val = has_insertion_operator>::value; TEST_ERROR("plop2: " << val); TEST_ERROR("plop3: " << (has_insertion_operator::value)); //etk::EnableIf>::value, uint32_t>::type plop = 55; etk::EnableIf::value, uint32_t>::type plop = 55; */ static uint32_t contructCount = 0; class PlopMove { public: PlopMove() { contructCount ++; } }; void hello(PlopMove _val) { contructCount += 1000; } TEST(typeMove, move_1) { contructCount = 0; PlopMove value; EXPECT_EQ(contructCount, 1); hello(etk::move(value)); EXPECT_EQ(contructCount, 1001); } static uint32_t swapMode = 0; class TestSwap1 { private: uint32_t m_value; public: TestSwap1(uint32_t _value) { m_value = _value; swapMode += m_value; } ~TestSwap1() { swapMode += m_value; } }; class TestSwap2 { private: uint32_t m_value; public: TestSwap2(uint32_t _value) { m_value = _value; swapMode += m_value; } ~TestSwap2() { swapMode += m_value; } void swap(TestSwap2& _obj) { swapMode += 1000000; uint32_t tmp = m_value; m_value = _obj.m_value; _obj.m_value = tmp; } }; TEST(typeTrait, swap_1) { bool ret = etk::Is_swap_MemberFunctionExists::value; EXPECT_EQ(ret, false); } TEST(typeTrait, swap_2) { bool ret = etk::Is_swap_MemberFunctionExists::value; EXPECT_EQ(ret, true); }