59#ifndef GUWRAPPERTESTS_HPP
60#define GUWRAPPERTESTS_HPP
64#define C_CONVERTIBLE_TEST_F(className) \
65 TEST2_F(testclassname(className), ConvertibleToC) { \
66 c_convertible_test(); \
69#define EQUALS_TEST_F(className, strctName) \
70 TEST2_F(testclassname(className), Equality) { \
71 equals_fake(strctName).return_val = true; \
72 const GU::className obj = initial(); \
73 const GU::className obj2 = empty(); \
74 ASSERT_EQ(obj, obj); \
75 ASSERT_EQ(equals_fake(strctName).call_count, 1); \
76 equals_reset(strctName) \
77 equals_fake(strctName).return_val = false; \
78 ASSERT_NE(obj, obj2); \
79 ASSERT_EQ(equals_fake(strctName).call_count, 1); \
80 equals_reset(strctName) \
81 equals_fake(strctName).return_val = true; \
82 const GU::className obj3 = initial(); \
83 const strctName obj4 = cempty(); \
84 const strctName obj5 = obj; \
85 ASSERT_EQ(obj3, obj5); \
86 ASSERT_EQ(equals_fake(strctName).call_count, 1); \
87 equals_reset(strctName) \
88 equals_fake(strctName).return_val = false; \
89 ASSERT_TRUE(obj3 != obj4); \
90 ASSERT_EQ(equals_fake(strctName).call_count, 1); \
93#define TO_C_TEST_F(className, strctName) \
94 TEST2_F(testclassname(className), TO_C) { \
95 const GU::className obj = initial(); \
96 const strctName converted = obj; \
97 equals(obj, converted); \
100#define WRAPPER_TEST_Fs(className, strctName) \
101 RO5_TEST_Fs(className) \
102 C_CONVERTIBLE_TEST_F(className) \
103 EQUALS_TEST_F(className, strctName) \
104 TO_C_TEST_F(className, strctName)
106#define GETTER_TEST_NAME_F(className, testName, resultType, call, get) \
107 TEST2_F(testclassname(className), testName) {\
108 const GU::resultType result = GU::resultType(call##_result); \
109 call##_fake.return_val = result; \
110 equals(initial().get, result); \
111 ASSERT_EQ(call##_fake.call_count, 1); \
115#define GETTER_TEST_F(className, resultType, call, get) \
116 GETTER_TEST_NAME_F(className, resultType, resultType, call, get)
118#define GETTER_IM_TEST_NAME_F(className, testName, resultType, call, imType, imCall, get) \
119 TEST2_F(testclassname(className), testName) {\
120 const GU::imType imResult = GU::imType(imCall##_result); \
121 imCall##_fake.return_val = imResult; \
122 const GU::resultType result = GU::resultType(call##_result); \
123 call##_fake.return_val = result; \
124 equals(initial().get, result); \
125 ASSERT_EQ(call##_fake.call_count, 1); \
130#define GETTER_IM_TEST_F(className, resultType, call, imType, imCall, get) \
131 GETTER_IM_TEST_NAME_F(className, resultType, resultType, call, imType, imCall, get)
133#define GETTER_BOOL_TEST_NAME_F(className, testName, resultType, call, get) \
134 TEST2_F(testclassname(className), testName) {\
135 call##_fake.custom_fake = call##_custom_fake_true; \
136 const GU::Optional##resultType result = GU::Optional##resultType(true, call##_custom_fake_result); \
137 const GU::Optional##resultType temp = initial().get; \
138 ASSERT_TRUE(temp.has_value()); \
139 equals(temp.value(), result.value()); \
140 ASSERT_EQ(call##_fake.call_count, 1); \
142 call##_fake.custom_fake = call##_custom_fake_false; \
143 const GU::Optional##resultType temp2 = initial().get; \
144 ASSERT_FALSE(temp2.has_value()); \
145 ASSERT_EQ(call##_fake.call_count, 1); \
149#define GETTER_BOOL_TEST_F(className, resultType, call, get) \
150 GETTER_BOOL_TEST_NAME_F(className, resultType##Bool, resultType, call, get)
152#define GETTER_BOOL_IM_TEST_NAME_F(className, testName, resultType, failCall, resultCall, get) \
153 TEST2_F(testclassname(className), testName) {\
154 failCall##_fake.custom_fake = failCall##_custom_fake_true; \
155 resultCall##_fake.return_val = resultCall##_result; \
156 const GU::Optional##resultType result = GU::Optional##resultType(true, resultCall##_result); \
157 const GU::Optional##resultType temp = initial().get; \
158 ASSERT_TRUE(temp.has_value()); \
159 equals(temp.value(), result.value()); \
160 ASSERT_EQ(failCall##_fake.call_count, 1); \
161 ASSERT_EQ(resultCall##_fake.call_count, 1); \
162 failCall##_reset(); \
163 resultCall##_reset(); \
164 failCall##_fake.custom_fake = failCall##_custom_fake_false; \
165 const GU::Optional##resultType temp2 = initial().get; \
166 ASSERT_FALSE(temp2.has_value()); \
167 ASSERT_EQ(failCall##_fake.call_count, 1); \
168 ASSERT_EQ(resultCall##_fake.call_count, 1); \
169 failCall##_reset(); \
170 resultCall##_reset(); \
173#define GETTER_BOOL_IM_TEST_F(className, resultType, failCall, resultCall, get) \
174 GETTER_BOOL_IM_TEST_NAME_F(className, resultType##Bool, resultType, failCall, resultCall, get)
176#if __cplusplus >= 201703L
177#define GETTER_OPT_TEST_NAME_F(className, testName, resultType, call, get) \
178 TEST2_F(testclassname(className), testName) {\
179 call##_fake.custom_fake = call##_custom_fake_true; \
180 const GU::resultType result = GU::resultType(call##_custom_fake_result); \
181 const std::optional<GU::resultType> out = initial().get; \
182 if (out.has_value()) \
184 equals(out.value(), result); \
185 ASSERT_EQ(call##_fake.call_count, 1); \
188 FAIL() << "Result is nullopt from initial().get"; \
190 call##_fake.custom_fake = call##_custom_fake_false; \
191 const std::optional<GU::resultType> out2 = initial().get; \
192 ASSERT_FALSE(out2.has_value()); \
195#define GETTER_OPT_TEST_F(className, resultType, call, get) \
196 GETTER_OPT_TEST_NAME_F(className, resultType, resultType, call, get)
198#define GETTER_OPT_IM_TEST_NAME_F(className, testName, resultType, failCall, resultCall, get) \
199 TEST2_F(testclassname(className), testName) { \
200 failCall##_fake.custom_fake = failCall##_custom_fake_true; \
201 resultCall##_fake.return_val = resultCall##_result; \
202 const GU::resultType result = GU::resultType(resultCall##_result); \
203 const std::optional<GU::resultType> out = initial().get; \
204 if (out.has_value()) \
206 equals(out.value(), result); \
207 ASSERT_EQ(failCall##_fake.call_count, 1); \
208 ASSERT_EQ(resultCall##_fake.call_count, 1); \
210 FAIL() << "Result is nullopt from initial().get"; \
212 failCall##_reset(); \
213 resultCall##_reset(); \
214 failCall##_fake.custom_fake = failCall##_custom_fake_false; \
215 const std::optional<GU::resultType> out2 = initial().get; \
216 ASSERT_FALSE(out2.has_value()); \
219#define GETTER_OPT_IM_TEST_F(className, resultType, failCall, resultCall, get) \
220 GETTER_OPT_IM_TEST_NAME_F(className, resultType, resultType, failCall, resultCall, get)
222#define GETTER_OPT_TEST_NAME_F(className, testName, resultType, call, get)
223#define GETTER_OPT_TEST_F(className, resultType, call, get)
224#define GETTER_OPT_IM_TEST_NAME_F(className, testName, resultType, failCall, resultCall, get)
225#define GETTER_OPT_IM_TEST_F(className, resultType, failCall, resultCall, get)
230 template <
typename Class,
typename Strct>
249 Class obj4 = std::move(obj);
252 Class obj5 = Class();
253 obj5 = std::move(temp);
256 Strct * obj6 = &obj3;
258 this->
equals(obj3, *obj6);
void equals(const GU::CameraCoordinate lhs, const GU::CameraCoordinate rhs)
virtual void cchange(Strct &)=0
void c_convertible_test()