Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
main.cpp
00001 #include "mbed.h" 00002 #include "greentea-client/test_env.h" 00003 #include "unity.h" 00004 #include "utest.h" 00005 00006 using namespace utest::v1; 00007 00008 00009 // static functions 00010 template <typename T> 00011 T static_func0() 00012 { return 0; } 00013 template <typename T> 00014 T static_func1(T a0) 00015 { return 0 | a0; } 00016 template <typename T> 00017 T static_func2(T a0, T a1) 00018 { return 0 | a0 | a1; } 00019 template <typename T> 00020 T static_func3(T a0, T a1, T a2) 00021 { return 0 | a0 | a1 | a2; } 00022 template <typename T> 00023 T static_func4(T a0, T a1, T a2, T a3) 00024 { return 0 | a0 | a1 | a2 | a3; } 00025 template <typename T> 00026 T static_func5(T a0, T a1, T a2, T a3, T a4) 00027 { return 0 | a0 | a1 | a2 | a3 | a4; } 00028 00029 // class functions 00030 template <typename T> 00031 struct Thing { 00032 T t; 00033 Thing() : t(0x80) {} 00034 00035 T member_func0() 00036 { return t; } 00037 T member_func1(T a0) 00038 { return t | a0; } 00039 T member_func2(T a0, T a1) 00040 { return t | a0 | a1; } 00041 T member_func3(T a0, T a1, T a2) 00042 { return t | a0 | a1 | a2; } 00043 T member_func4(T a0, T a1, T a2, T a3) 00044 { return t | a0 | a1 | a2 | a3; } 00045 T member_func5(T a0, T a1, T a2, T a3, T a4) 00046 { return t | a0 | a1 | a2 | a3 | a4; } 00047 00048 T const_member_func0() const 00049 { return t; } 00050 T const_member_func1(T a0) const 00051 { return t | a0; } 00052 T const_member_func2(T a0, T a1) const 00053 { return t | a0 | a1; } 00054 T const_member_func3(T a0, T a1, T a2) const 00055 { return t | a0 | a1 | a2; } 00056 T const_member_func4(T a0, T a1, T a2, T a3) const 00057 { return t | a0 | a1 | a2 | a3; } 00058 T const_member_func5(T a0, T a1, T a2, T a3, T a4) const 00059 { return t | a0 | a1 | a2 | a3 | a4; } 00060 00061 T volatile_member_func0() volatile 00062 { return t; } 00063 T volatile_member_func1(T a0) volatile 00064 { return t | a0; } 00065 T volatile_member_func2(T a0, T a1) volatile 00066 { return t | a0 | a1; } 00067 T volatile_member_func3(T a0, T a1, T a2) volatile 00068 { return t | a0 | a1 | a2; } 00069 T volatile_member_func4(T a0, T a1, T a2, T a3) volatile 00070 { return t | a0 | a1 | a2 | a3; } 00071 T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile 00072 { return t | a0 | a1 | a2 | a3 | a4; } 00073 00074 T const_volatile_member_func0() const volatile 00075 { return t; } 00076 T const_volatile_member_func1(T a0) const volatile 00077 { return t | a0; } 00078 T const_volatile_member_func2(T a0, T a1) const volatile 00079 { return t | a0 | a1; } 00080 T const_volatile_member_func3(T a0, T a1, T a2) const volatile 00081 { return t | a0 | a1 | a2; } 00082 T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile 00083 { return t | a0 | a1 | a2 | a3; } 00084 T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile 00085 { return t | a0 | a1 | a2 | a3 | a4; } 00086 }; 00087 00088 // bound functions 00089 template <typename T> 00090 T bound_func0(Thing<T> *t) 00091 { return t->t; } 00092 template <typename T> 00093 T bound_func1(Thing<T> *t, T a0) 00094 { return t->t | a0; } 00095 template <typename T> 00096 T bound_func2(Thing<T> *t, T a0, T a1) 00097 { return t->t | a0 | a1; } 00098 template <typename T> 00099 T bound_func3(Thing<T> *t, T a0, T a1, T a2) 00100 { return t->t | a0 | a1 | a2; } 00101 template <typename T> 00102 T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) 00103 { return t->t | a0 | a1 | a2 | a3; } 00104 template <typename T> 00105 T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) 00106 { return t->t | a0 | a1 | a2 | a3 | a4; } 00107 template <typename T> 00108 T const_bound_func0(const Thing<T> *t) 00109 { return t->t; } 00110 template <typename T> 00111 T const_bound_func1(const Thing<T> *t, T a0) 00112 { return t->t | a0; } 00113 template <typename T> 00114 T const_bound_func2(const Thing<T> *t, T a0, T a1) 00115 { return t->t | a0 | a1; } 00116 template <typename T> 00117 T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2) 00118 { return t->t | a0 | a1 | a2; } 00119 template <typename T> 00120 T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) 00121 { return t->t | a0 | a1 | a2 | a3; } 00122 template <typename T> 00123 T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) 00124 { return t->t | a0 | a1 | a2 | a3 | a4; } 00125 template <typename T> 00126 T volatile_bound_func0(volatile Thing<T> *t) 00127 { return t->t; } 00128 template <typename T> 00129 T volatile_bound_func1(volatile Thing<T> *t, T a0) 00130 { return t->t | a0; } 00131 template <typename T> 00132 T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1) 00133 { return t->t | a0 | a1; } 00134 template <typename T> 00135 T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2) 00136 { return t->t | a0 | a1 | a2; } 00137 template <typename T> 00138 T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) 00139 { return t->t | a0 | a1 | a2 | a3; } 00140 template <typename T> 00141 T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) 00142 { return t->t | a0 | a1 | a2 | a3 | a4; } 00143 template <typename T> 00144 T const_volatile_bound_func0(const volatile Thing<T> *t) 00145 { return t->t; } 00146 template <typename T> 00147 T const_volatile_bound_func1(const volatile Thing<T> *t, T a0) 00148 { return t->t | a0; } 00149 template <typename T> 00150 T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1) 00151 { return t->t | a0 | a1; } 00152 template <typename T> 00153 T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2) 00154 { return t->t | a0 | a1 | a2; } 00155 template <typename T> 00156 T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) 00157 { return t->t | a0 | a1 | a2 | a3; } 00158 template <typename T> 00159 T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) 00160 { return t->t | a0 | a1 | a2 | a3 | a4; } 00161 00162 // void functions 00163 template <typename T> 00164 T void_func0(void *t) 00165 { return static_cast<Thing<T>*>(t)->t; } 00166 template <typename T> 00167 T void_func1(void *t, T a0) 00168 { return static_cast<Thing<T>*>(t)->t | a0; } 00169 template <typename T> 00170 T void_func2(void *t, T a0, T a1) 00171 { return static_cast<Thing<T>*>(t)->t | a0 | a1; } 00172 template <typename T> 00173 T void_func3(void *t, T a0, T a1, T a2) 00174 { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; } 00175 template <typename T> 00176 T void_func4(void *t, T a0, T a1, T a2, T a3) 00177 { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } 00178 template <typename T> 00179 T void_func5(void *t, T a0, T a1, T a2, T a3, T a4) 00180 { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } 00181 template <typename T> 00182 T const_void_func0(const void *t) 00183 { return static_cast<const Thing<T>*>(t)->t; } 00184 template <typename T> 00185 T const_void_func1(const void *t, T a0) 00186 { return static_cast<const Thing<T>*>(t)->t | a0; } 00187 template <typename T> 00188 T const_void_func2(const void *t, T a0, T a1) 00189 { return static_cast<const Thing<T>*>(t)->t | a0 | a1; } 00190 template <typename T> 00191 T const_void_func3(const void *t, T a0, T a1, T a2) 00192 { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; } 00193 template <typename T> 00194 T const_void_func4(const void *t, T a0, T a1, T a2, T a3) 00195 { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } 00196 template <typename T> 00197 T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4) 00198 { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } 00199 template <typename T> 00200 T volatile_void_func0(volatile void *t) 00201 { return static_cast<volatile Thing<T>*>(t)->t; } 00202 template <typename T> 00203 T volatile_void_func1(volatile void *t, T a0) 00204 { return static_cast<volatile Thing<T>*>(t)->t | a0; } 00205 template <typename T> 00206 T volatile_void_func2(volatile void *t, T a0, T a1) 00207 { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; } 00208 template <typename T> 00209 T volatile_void_func3(volatile void *t, T a0, T a1, T a2) 00210 { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; } 00211 template <typename T> 00212 T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3) 00213 { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } 00214 template <typename T> 00215 T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4) 00216 { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } 00217 template <typename T> 00218 T const_volatile_void_func0(const volatile void *t) 00219 { return static_cast<const volatile Thing<T>*>(t)->t; } 00220 template <typename T> 00221 T const_volatile_void_func1(const volatile void *t, T a0) 00222 { return static_cast<const volatile Thing<T>*>(t)->t | a0; } 00223 template <typename T> 00224 T const_volatile_void_func2(const volatile void *t, T a0, T a1) 00225 { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; } 00226 template <typename T> 00227 T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2) 00228 { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; } 00229 template <typename T> 00230 T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3) 00231 { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } 00232 template <typename T> 00233 T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4) 00234 { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } 00235 00236 // Inheriting class 00237 template <typename T> 00238 class Thing2 : public Thing<T> { 00239 }; 00240 00241 00242 // function call and result verification 00243 template <typename T> 00244 struct Verifier { 00245 static void verify0(Callback<T()> func) { 00246 T result = func(); 00247 TEST_ASSERT_EQUAL(result, 0x00); 00248 } 00249 00250 template <typename O, typename M> 00251 static void verify0(O *obj, M method) { 00252 Callback<T()> func(obj, method); 00253 T result = func(); 00254 TEST_ASSERT_EQUAL(result, 0x80); 00255 } 00256 00257 static void verify1(Callback<T(T)> func) { 00258 T result = func((1 << 0)); 00259 TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); 00260 } 00261 00262 template <typename O, typename M> 00263 static void verify1(O *obj, M method) { 00264 Callback<T(T)> func(obj, method); 00265 T result = func((1 << 0)); 00266 TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); 00267 } 00268 00269 static void verify2(Callback<T(T, T)> func) { 00270 T result = func((1 << 0), (1 << 1)); 00271 TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); 00272 } 00273 00274 template <typename O, typename M> 00275 static void verify2(O *obj, M method) { 00276 Callback<T(T, T)> func(obj, method); 00277 T result = func((1 << 0), (1 << 1)); 00278 TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); 00279 } 00280 00281 static void verify3(Callback<T(T, T, T)> func) { 00282 T result = func((1 << 0), (1 << 1), (1 << 2)); 00283 TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); 00284 } 00285 00286 template <typename O, typename M> 00287 static void verify3(O *obj, M method) { 00288 Callback<T(T, T, T)> func(obj, method); 00289 T result = func((1 << 0), (1 << 1), (1 << 2)); 00290 TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); 00291 } 00292 00293 static void verify4(Callback<T(T, T, T, T)> func) { 00294 T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); 00295 TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); 00296 } 00297 00298 template <typename O, typename M> 00299 static void verify4(O *obj, M method) { 00300 Callback<T(T, T, T, T)> func(obj, method); 00301 T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); 00302 TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); 00303 } 00304 00305 static void verify5(Callback<T(T, T, T, T, T)> func) { 00306 T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); 00307 TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); 00308 } 00309 00310 template <typename O, typename M> 00311 static void verify5(O *obj, M method) { 00312 Callback<T(T, T, T, T, T)> func(obj, method); 00313 T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); 00314 TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); 00315 } 00316 }; 00317 00318 00319 // test dispatch 00320 template <typename T> 00321 void test_dispatch0() { 00322 Thing<T> thing; 00323 Thing2<T> thing2; 00324 Verifier<T>::verify0(static_func0<T>); 00325 Verifier<T>::verify0(&thing, &Thing<T>::member_func0); 00326 Verifier<T>::verify0((const Thing<T>*)&thing, &Thing<T>::const_member_func0); 00327 Verifier<T>::verify0((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func0); 00328 Verifier<T>::verify0((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func0); 00329 Verifier<T>::verify0(&thing2, &Thing2<T>::member_func0); 00330 Verifier<T>::verify0(&bound_func0<T>, &thing); 00331 Verifier<T>::verify0(&const_bound_func0<T>, (const Thing<T>*)&thing); 00332 Verifier<T>::verify0(&volatile_bound_func0<T>, (volatile Thing<T>*)&thing); 00333 Verifier<T>::verify0(&const_volatile_bound_func0<T>, (const volatile Thing<T>*)&thing); 00334 Verifier<T>::verify0(&bound_func0<T>, &thing2); 00335 Verifier<T>::verify0(&void_func0<T>, &thing); 00336 Verifier<T>::verify0(&const_void_func0<T>, (const Thing<T>*)&thing); 00337 Verifier<T>::verify0(&volatile_void_func0<T>, (volatile Thing<T>*)&thing); 00338 Verifier<T>::verify0(&const_volatile_void_func0<T>, (const volatile Thing<T>*)&thing); 00339 Verifier<T>::verify0(callback(static_func0<T>)); 00340 00341 Callback<T()> cb(static_func0); 00342 Verifier<T>::verify0(cb); 00343 cb = static_func0; 00344 Verifier<T>::verify0(cb); 00345 cb.attach(&bound_func0<T>, &thing); 00346 Verifier<T>::verify0(&cb, &Callback<T()>::call); 00347 Verifier<T>::verify0(&Callback<T()>::thunk, (void*)&cb); 00348 } 00349 00350 template <typename T> 00351 void test_dispatch1() { 00352 Thing<T> thing; 00353 Thing2<T> thing2; 00354 Verifier<T>::verify1(static_func1<T>); 00355 Verifier<T>::verify1(&thing, &Thing<T>::member_func1); 00356 Verifier<T>::verify1((const Thing<T>*)&thing, &Thing<T>::const_member_func1); 00357 Verifier<T>::verify1((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func1); 00358 Verifier<T>::verify1((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func1); 00359 Verifier<T>::verify1(&thing2, &Thing2<T>::member_func1); 00360 Verifier<T>::verify1(&bound_func1<T>, &thing); 00361 Verifier<T>::verify1(&const_bound_func1<T>, (const Thing<T>*)&thing); 00362 Verifier<T>::verify1(&volatile_bound_func1<T>, (volatile Thing<T>*)&thing); 00363 Verifier<T>::verify1(&const_volatile_bound_func1<T>, (const volatile Thing<T>*)&thing); 00364 Verifier<T>::verify1(&bound_func1<T>, &thing2); 00365 Verifier<T>::verify1(&void_func1<T>, &thing); 00366 Verifier<T>::verify1(&const_void_func1<T>, (const Thing<T>*)&thing); 00367 Verifier<T>::verify1(&volatile_void_func1<T>, (volatile Thing<T>*)&thing); 00368 Verifier<T>::verify1(&const_volatile_void_func1<T>, (const volatile Thing<T>*)&thing); 00369 Verifier<T>::verify1(callback(static_func1<T>)); 00370 00371 Callback<T(T)> cb(static_func1); 00372 Verifier<T>::verify1(cb); 00373 cb = static_func1; 00374 Verifier<T>::verify1(cb); 00375 cb.attach(&bound_func1<T>, &thing); 00376 Verifier<T>::verify1(&cb, &Callback<T(T)>::call); 00377 Verifier<T>::verify1(&Callback<T(T)>::thunk, (void*)&cb); 00378 } 00379 00380 template <typename T> 00381 void test_dispatch2() { 00382 Thing<T> thing; 00383 Thing2<T> thing2; 00384 Verifier<T>::verify2(static_func2<T>); 00385 Verifier<T>::verify2(&thing, &Thing<T>::member_func2); 00386 Verifier<T>::verify2((const Thing<T>*)&thing, &Thing<T>::const_member_func2); 00387 Verifier<T>::verify2((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func2); 00388 Verifier<T>::verify2((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func2); 00389 Verifier<T>::verify2(&thing2, &Thing2<T>::member_func2); 00390 Verifier<T>::verify2(&bound_func2<T>, &thing); 00391 Verifier<T>::verify2(&const_bound_func2<T>, (const Thing<T>*)&thing); 00392 Verifier<T>::verify2(&volatile_bound_func2<T>, (volatile Thing<T>*)&thing); 00393 Verifier<T>::verify2(&const_volatile_bound_func2<T>, (const volatile Thing<T>*)&thing); 00394 Verifier<T>::verify2(&bound_func2<T>, &thing2); 00395 Verifier<T>::verify2(&void_func2<T>, &thing); 00396 Verifier<T>::verify2(&const_void_func2<T>, (const Thing<T>*)&thing); 00397 Verifier<T>::verify2(&volatile_void_func2<T>, (volatile Thing<T>*)&thing); 00398 Verifier<T>::verify2(&const_volatile_void_func2<T>, (const volatile Thing<T>*)&thing); 00399 Verifier<T>::verify2(callback(static_func2<T>)); 00400 00401 Callback<T(T, T)> cb(static_func2); 00402 Verifier<T>::verify2(cb); 00403 cb = static_func2; 00404 Verifier<T>::verify2(cb); 00405 cb.attach(&bound_func2<T>, &thing); 00406 Verifier<T>::verify2(&cb, &Callback<T(T, T)>::call); 00407 Verifier<T>::verify2(&Callback<T(T, T)>::thunk, (void*)&cb); 00408 } 00409 00410 template <typename T> 00411 void test_dispatch3() { 00412 Thing<T> thing; 00413 Thing2<T> thing2; 00414 Verifier<T>::verify3(static_func3<T>); 00415 Verifier<T>::verify3(&thing, &Thing<T>::member_func3); 00416 Verifier<T>::verify3((const Thing<T>*)&thing, &Thing<T>::const_member_func3); 00417 Verifier<T>::verify3((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func3); 00418 Verifier<T>::verify3((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func3); 00419 Verifier<T>::verify3(&thing2, &Thing2<T>::member_func3); 00420 Verifier<T>::verify3(&bound_func3<T>, &thing); 00421 Verifier<T>::verify3(&const_bound_func3<T>, (const Thing<T>*)&thing); 00422 Verifier<T>::verify3(&volatile_bound_func3<T>, (volatile Thing<T>*)&thing); 00423 Verifier<T>::verify3(&const_volatile_bound_func3<T>, (const volatile Thing<T>*)&thing); 00424 Verifier<T>::verify3(&bound_func3<T>, &thing2); 00425 Verifier<T>::verify3(&void_func3<T>, &thing); 00426 Verifier<T>::verify3(&const_void_func3<T>, (const Thing<T>*)&thing); 00427 Verifier<T>::verify3(&volatile_void_func3<T>, (volatile Thing<T>*)&thing); 00428 Verifier<T>::verify3(&const_volatile_void_func3<T>, (const volatile Thing<T>*)&thing); 00429 Verifier<T>::verify3(callback(static_func3<T>)); 00430 00431 Callback<T(T, T, T)> cb(static_func3); 00432 Verifier<T>::verify3(cb); 00433 cb = static_func3; 00434 Verifier<T>::verify3(cb); 00435 cb.attach(&bound_func3<T>, &thing); 00436 Verifier<T>::verify3(&cb, &Callback<T(T, T, T)>::call); 00437 Verifier<T>::verify3(&Callback<T(T, T, T)>::thunk, (void*)&cb); 00438 } 00439 00440 template <typename T> 00441 void test_dispatch4() { 00442 Thing<T> thing; 00443 Thing2<T> thing2; 00444 Verifier<T>::verify4(static_func4<T>); 00445 Verifier<T>::verify4(&thing, &Thing<T>::member_func4); 00446 Verifier<T>::verify4((const Thing<T>*)&thing, &Thing<T>::const_member_func4); 00447 Verifier<T>::verify4((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func4); 00448 Verifier<T>::verify4((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func4); 00449 Verifier<T>::verify4(&thing2, &Thing2<T>::member_func4); 00450 Verifier<T>::verify4(&bound_func4<T>, &thing); 00451 Verifier<T>::verify4(&const_bound_func4<T>, (const Thing<T>*)&thing); 00452 Verifier<T>::verify4(&volatile_bound_func4<T>, (volatile Thing<T>*)&thing); 00453 Verifier<T>::verify4(&const_volatile_bound_func4<T>, (const volatile Thing<T>*)&thing); 00454 Verifier<T>::verify4(&bound_func4<T>, &thing2); 00455 Verifier<T>::verify4(&void_func4<T>, &thing); 00456 Verifier<T>::verify4(&const_void_func4<T>, (const Thing<T>*)&thing); 00457 Verifier<T>::verify4(&volatile_void_func4<T>, (volatile Thing<T>*)&thing); 00458 Verifier<T>::verify4(&const_volatile_void_func4<T>, (const volatile Thing<T>*)&thing); 00459 Verifier<T>::verify4(callback(static_func4<T>)); 00460 00461 Callback<T(T, T, T, T)> cb(static_func4); 00462 Verifier<T>::verify4(cb); 00463 cb = static_func4; 00464 Verifier<T>::verify4(cb); 00465 cb.attach(&bound_func4<T>, &thing); 00466 Verifier<T>::verify4(&cb, &Callback<T(T, T, T, T)>::call); 00467 Verifier<T>::verify4(&Callback<T(T, T, T, T)>::thunk, (void*)&cb); 00468 } 00469 00470 template <typename T> 00471 void test_dispatch5() { 00472 Thing<T> thing; 00473 Thing2<T> thing2; 00474 Verifier<T>::verify5(static_func5<T>); 00475 Verifier<T>::verify5(&thing, &Thing<T>::member_func5); 00476 Verifier<T>::verify5((const Thing<T>*)&thing, &Thing<T>::const_member_func5); 00477 Verifier<T>::verify5((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func5); 00478 Verifier<T>::verify5((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func5); 00479 Verifier<T>::verify5(&thing2, &Thing2<T>::member_func5); 00480 Verifier<T>::verify5(&bound_func5<T>, &thing); 00481 Verifier<T>::verify5(&const_bound_func5<T>, (const Thing<T>*)&thing); 00482 Verifier<T>::verify5(&volatile_bound_func5<T>, (volatile Thing<T>*)&thing); 00483 Verifier<T>::verify5(&const_volatile_bound_func5<T>, (const volatile Thing<T>*)&thing); 00484 Verifier<T>::verify5(&bound_func5<T>, &thing2); 00485 Verifier<T>::verify5(&void_func5<T>, &thing); 00486 Verifier<T>::verify5(&const_void_func5<T>, (const Thing<T>*)&thing); 00487 Verifier<T>::verify5(&volatile_void_func5<T>, (volatile Thing<T>*)&thing); 00488 Verifier<T>::verify5(&const_volatile_void_func5<T>, (const volatile Thing<T>*)&thing); 00489 Verifier<T>::verify5(callback(static_func5<T>)); 00490 00491 Callback<T(T, T, T, T, T)> cb(static_func5); 00492 Verifier<T>::verify5(cb); 00493 cb = static_func5; 00494 Verifier<T>::verify5(cb); 00495 cb.attach(&bound_func5<T>, &thing); 00496 Verifier<T>::verify5(&cb, &Callback<T(T, T, T, T, T)>::call); 00497 Verifier<T>::verify5(&Callback<T(T, T, T, T, T)>::thunk, (void*)&cb); 00498 } 00499 00500 00501 // Test setup 00502 utest::v1::status_t test_setup(const size_t number_of_cases) { 00503 GREENTEA_SETUP(10, "default_auto"); 00504 return verbose_test_setup_handler(number_of_cases); 00505 } 00506 00507 Case cases[] = { 00508 Case("Testing callbacks with 0 ints", test_dispatch0<int>), 00509 Case("Testing callbacks with 1 ints", test_dispatch1<int>), 00510 Case("Testing callbacks with 2 ints", test_dispatch2<int>), 00511 Case("Testing callbacks with 3 ints", test_dispatch3<int>), 00512 Case("Testing callbacks with 4 ints", test_dispatch4<int>), 00513 Case("Testing callbacks with 5 ints", test_dispatch5<int>), 00514 }; 00515 00516 Specification specification(test_setup, cases); 00517 00518 int main() { 00519 return !Harness::run(specification); 00520 }
Generated on Tue Jul 12 2022 11:02:45 by
