Covellite++  Version: 2.3.0 Revision: ??? Platform: x64 Build: 23:13 04.01.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
Common_test.hpp
1
2#pragma once
3
4// ************************************************************************** //
5TEST_F(Common_test, /*DISABLED_*/Test_StructSizeAlign16Bytes)
6{
7 EXPECT_EQ(0, sizeof(::Camera) % 16);
8 EXPECT_EQ(0, sizeof(::Object) % 16);
9}
10
11// ************************************************************************** //
12TEST_F(Common_test, /*DISABLED_*/Test_Destructor)
13{
14 EXPECT_TRUE(::std::has_virtual_destructor<Tested_t>::value);
15 EXPECT_TRUE(::std::is_nothrow_destructible<Tested_t>::value);
16}
17
18// ************************************************************************** //
19TEST_F(Common_test, /*DISABLED_*/Test_RegisterIntoFactory)
20{
21 using namespace ::alicorn::modules::patterns;
22
23 const Data_t oData;
24 const ::covellite::api::renderer::SettingsData & Data = oData;
25
26 auto pExample = factory::make_unique<ITested_t>(ImplClassName, Data);
27 EXPECT_NO_THROW(dynamic_cast<Tested_t &>(*pExample));
28}
29
30// ************************************************************************** //
31TEST_F(Common_test, /*DISABLED_*/Test_State_AlphaTest)
32{
33 Tested_t Example{ Data_t{} };
34 ITested_t & IExample = Example;
35
36 auto itCreator = IExample.GetCreators().find(uT("State"));
37 ASSERT_NE(IExample.GetCreators().end(), itCreator);
38
39 {
40 const auto pState = Component_t::Make(
41 {
42 { uT("kind"), uT("AlphaTest") },
43 });
44
45 EXPECT_EQ(nullptr, itCreator->second(pState));
46 }
47
48 {
49 const auto Value = 1904271913.0f;
50
51 const auto pState = Component_t::Make(
52 {
53 { uT("kind"), uT("AlphaTest") },
54 { uT("discard"), Value },
55 });
56
57 EXPECT_EQ(nullptr, itCreator->second(pState));
58 }
59}
60
61// ************************************************************************** //
62TEST_F(Common_test, /*DISABLED_*/Test_Transform_UnknownKind)
63{
64 const Tested_t oExample{ Data_t{} };
65 const ITested_t & IExample = oExample;
66
67 auto itCreator = IExample.GetCreators().find(uT("Transform"));
68 ASSERT_NE(IExample.GetCreators().end(), itCreator);
69
70 const auto pComponent = Component_t::Make(
71 {
72 { uT("kind"), uT("Unknow1908061947") },
73 });
74
75 EXPECT_THROW(itCreator->second(pComponent), ::std::exception);
76}
77
78// ************************************************************************** //
79TEST_F(Common_test, /*DISABLED_*/Test_Buffer_Constant_User_EmptyMapper)
80{
81 using BufferMapper_t = ::covellite::api::cbBufferMap_t<void>;
82
83 const Tested_t oExample{ Data_t{} };
84 const ITested_t & IExample = oExample;
85
86 auto itCreator = IExample.GetCreators().find(uT("Buffer"));
87 ASSERT_NE(IExample.GetCreators().end(), itCreator);
88
89 // Тип буфера выводится из переданного mapper'a
90 //EXPECT_THROW(itCreator->second(Component_t::Make({ })), ::std::exception);
91
92 const auto pComponent1 = Component_t::Make(
93 {
94 { uT("mapper"), BufferMapper_t{ } },
95 });
96
97 EXPECT_THROW(itCreator->second(pComponent1), ::std::exception);
98
99 const auto pComponent2 = Component_t::Make(
100 {
101 { uT("mapper"), BufferMapper_t{ nullptr } },
102 });
103
104 EXPECT_THROW(itCreator->second(pComponent2), ::std::exception);
105}
106
107// ************************************************************************** //
108TEST_F(Common_test, /*DISABLED_*/Test_Buffer_Constant_User_EmptySize)
109{
110 using BufferMapper_t = ::covellite::api::cbBufferMap_t<void>;
111
112 const Tested_t oExample{ Data_t{} };
113 const ITested_t & IExample = oExample;
114
115 auto itCreator = IExample.GetCreators().find(uT("Buffer"));
116 ASSERT_NE(IExample.GetCreators().end(), itCreator);
117
118 const auto pComponent = Component_t::Make(
119 {
120 { uT("mapper"), BufferMapper_t{ [](void *) { return false; } } },
121 });
122
123 EXPECT_THROW(itCreator->second(pComponent), ::std::exception);
124}