mbed os with nrf51 internal bandgap enabled to read battery level
Dependents: BLE_file_test BLE_Blink ExternalEncoder
TESTS/mbed_functional/callback_big/main.cpp@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | #include "mbed.h" |
elessair | 0:f269e3021894 | 2 | #include "greentea-client/test_env.h" |
elessair | 0:f269e3021894 | 3 | #include "unity.h" |
elessair | 0:f269e3021894 | 4 | #include "utest.h" |
elessair | 0:f269e3021894 | 5 | |
elessair | 0:f269e3021894 | 6 | using namespace utest::v1; |
elessair | 0:f269e3021894 | 7 | |
elessair | 0:f269e3021894 | 8 | |
elessair | 0:f269e3021894 | 9 | // static functions |
elessair | 0:f269e3021894 | 10 | template <typename T> |
elessair | 0:f269e3021894 | 11 | T static_func0() { return 0; } |
elessair | 0:f269e3021894 | 12 | template <typename T> |
elessair | 0:f269e3021894 | 13 | T static_func1(T a0) { return 0 | a0; } |
elessair | 0:f269e3021894 | 14 | template <typename T> |
elessair | 0:f269e3021894 | 15 | T static_func2(T a0, T a1) { return 0 | a0 | a1; } |
elessair | 0:f269e3021894 | 16 | template <typename T> |
elessair | 0:f269e3021894 | 17 | T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 18 | template <typename T> |
elessair | 0:f269e3021894 | 19 | T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 20 | template <typename T> |
elessair | 0:f269e3021894 | 21 | T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 22 | |
elessair | 0:f269e3021894 | 23 | // class functions |
elessair | 0:f269e3021894 | 24 | template <typename T> |
elessair | 0:f269e3021894 | 25 | struct Thing { |
elessair | 0:f269e3021894 | 26 | T t; |
elessair | 0:f269e3021894 | 27 | Thing() : t(0x80) {} |
elessair | 0:f269e3021894 | 28 | |
elessair | 0:f269e3021894 | 29 | T member_func0() { return t; } |
elessair | 0:f269e3021894 | 30 | T member_func1(T a0) { return t | a0; } |
elessair | 0:f269e3021894 | 31 | T member_func2(T a0, T a1) { return t | a0 | a1; } |
elessair | 0:f269e3021894 | 32 | T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 33 | T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 34 | T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 35 | |
elessair | 0:f269e3021894 | 36 | T const_member_func0() const { return t; } |
elessair | 0:f269e3021894 | 37 | T const_member_func1(T a0) const { return t | a0; } |
elessair | 0:f269e3021894 | 38 | T const_member_func2(T a0, T a1) const { return t | a0 | a1; } |
elessair | 0:f269e3021894 | 39 | T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 40 | T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 41 | T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 42 | |
elessair | 0:f269e3021894 | 43 | T volatile_member_func0() volatile { return t; } |
elessair | 0:f269e3021894 | 44 | T volatile_member_func1(T a0) volatile { return t | a0; } |
elessair | 0:f269e3021894 | 45 | T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; } |
elessair | 0:f269e3021894 | 46 | T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 47 | T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 48 | T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 49 | |
elessair | 0:f269e3021894 | 50 | T const_volatile_member_func0() const volatile { return t; } |
elessair | 0:f269e3021894 | 51 | T const_volatile_member_func1(T a0) const volatile { return t | a0; } |
elessair | 0:f269e3021894 | 52 | T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; } |
elessair | 0:f269e3021894 | 53 | T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 54 | T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 55 | T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 56 | }; |
elessair | 0:f269e3021894 | 57 | |
elessair | 0:f269e3021894 | 58 | // bound functions |
elessair | 0:f269e3021894 | 59 | template <typename T> |
elessair | 0:f269e3021894 | 60 | T bound_func0(Thing<T> *t) { return t->t; } |
elessair | 0:f269e3021894 | 61 | template <typename T> |
elessair | 0:f269e3021894 | 62 | T bound_func1(Thing<T> *t, T a0) { return t->t | a0; } |
elessair | 0:f269e3021894 | 63 | template <typename T> |
elessair | 0:f269e3021894 | 64 | T bound_func2(Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; } |
elessair | 0:f269e3021894 | 65 | template <typename T> |
elessair | 0:f269e3021894 | 66 | T bound_func3(Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 67 | template <typename T> |
elessair | 0:f269e3021894 | 68 | T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 69 | template <typename T> |
elessair | 0:f269e3021894 | 70 | T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 71 | |
elessair | 0:f269e3021894 | 72 | // const bound functions |
elessair | 0:f269e3021894 | 73 | template <typename T> |
elessair | 0:f269e3021894 | 74 | T const_func0(const Thing<T> *t) { return t->t; } |
elessair | 0:f269e3021894 | 75 | template <typename T> |
elessair | 0:f269e3021894 | 76 | T const_func1(const Thing<T> *t, T a0) { return t->t | a0; } |
elessair | 0:f269e3021894 | 77 | template <typename T> |
elessair | 0:f269e3021894 | 78 | T const_func2(const Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; } |
elessair | 0:f269e3021894 | 79 | template <typename T> |
elessair | 0:f269e3021894 | 80 | T const_func3(const Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 81 | template <typename T> |
elessair | 0:f269e3021894 | 82 | T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 83 | template <typename T> |
elessair | 0:f269e3021894 | 84 | T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 85 | |
elessair | 0:f269e3021894 | 86 | // volatile bound functions |
elessair | 0:f269e3021894 | 87 | template <typename T> |
elessair | 0:f269e3021894 | 88 | T volatile_func0(volatile Thing<T> *t) { return t->t; } |
elessair | 0:f269e3021894 | 89 | template <typename T> |
elessair | 0:f269e3021894 | 90 | T volatile_func1(volatile Thing<T> *t, T a0) { return t->t | a0; } |
elessair | 0:f269e3021894 | 91 | template <typename T> |
elessair | 0:f269e3021894 | 92 | T volatile_func2(volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; } |
elessair | 0:f269e3021894 | 93 | template <typename T> |
elessair | 0:f269e3021894 | 94 | T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 95 | template <typename T> |
elessair | 0:f269e3021894 | 96 | T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 97 | template <typename T> |
elessair | 0:f269e3021894 | 98 | T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 99 | |
elessair | 0:f269e3021894 | 100 | // const volatile bound functions |
elessair | 0:f269e3021894 | 101 | template <typename T> |
elessair | 0:f269e3021894 | 102 | T const_volatile_func0(const volatile Thing<T> *t) { return t->t; } |
elessair | 0:f269e3021894 | 103 | template <typename T> |
elessair | 0:f269e3021894 | 104 | T const_volatile_func1(const volatile Thing<T> *t, T a0) { return t->t | a0; } |
elessair | 0:f269e3021894 | 105 | template <typename T> |
elessair | 0:f269e3021894 | 106 | T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; } |
elessair | 0:f269e3021894 | 107 | template <typename T> |
elessair | 0:f269e3021894 | 108 | T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } |
elessair | 0:f269e3021894 | 109 | template <typename T> |
elessair | 0:f269e3021894 | 110 | T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } |
elessair | 0:f269e3021894 | 111 | template <typename T> |
elessair | 0:f269e3021894 | 112 | T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } |
elessair | 0:f269e3021894 | 113 | |
elessair | 0:f269e3021894 | 114 | |
elessair | 0:f269e3021894 | 115 | // function call and result verification |
elessair | 0:f269e3021894 | 116 | template <typename T> |
elessair | 0:f269e3021894 | 117 | struct Verifier { |
elessair | 0:f269e3021894 | 118 | static void verify0(Callback<T()> func) { |
elessair | 0:f269e3021894 | 119 | T result = func(); |
elessair | 0:f269e3021894 | 120 | TEST_ASSERT_EQUAL(result, 0x00); |
elessair | 0:f269e3021894 | 121 | } |
elessair | 0:f269e3021894 | 122 | |
elessair | 0:f269e3021894 | 123 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 124 | static void verify0(O *obj, M method) { |
elessair | 0:f269e3021894 | 125 | Callback<T()> func(obj, method); |
elessair | 0:f269e3021894 | 126 | T result = func(); |
elessair | 0:f269e3021894 | 127 | TEST_ASSERT_EQUAL(result, 0x80); |
elessair | 0:f269e3021894 | 128 | } |
elessair | 0:f269e3021894 | 129 | |
elessair | 0:f269e3021894 | 130 | static void verify1(Callback<T(T)> func) { |
elessair | 0:f269e3021894 | 131 | T result = func((1 << 0)); |
elessair | 0:f269e3021894 | 132 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); |
elessair | 0:f269e3021894 | 133 | } |
elessair | 0:f269e3021894 | 134 | |
elessair | 0:f269e3021894 | 135 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 136 | static void verify1(O *obj, M method) { |
elessair | 0:f269e3021894 | 137 | Callback<T(T)> func(obj, method); |
elessair | 0:f269e3021894 | 138 | T result = func((1 << 0)); |
elessair | 0:f269e3021894 | 139 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); |
elessair | 0:f269e3021894 | 140 | } |
elessair | 0:f269e3021894 | 141 | |
elessair | 0:f269e3021894 | 142 | static void verify2(Callback<T(T, T)> func) { |
elessair | 0:f269e3021894 | 143 | T result = func((1 << 0), (1 << 1)); |
elessair | 0:f269e3021894 | 144 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); |
elessair | 0:f269e3021894 | 145 | } |
elessair | 0:f269e3021894 | 146 | |
elessair | 0:f269e3021894 | 147 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 148 | static void verify2(O *obj, M method) { |
elessair | 0:f269e3021894 | 149 | Callback<T(T, T)> func(obj, method); |
elessair | 0:f269e3021894 | 150 | T result = func((1 << 0), (1 << 1)); |
elessair | 0:f269e3021894 | 151 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); |
elessair | 0:f269e3021894 | 152 | } |
elessair | 0:f269e3021894 | 153 | |
elessair | 0:f269e3021894 | 154 | static void verify3(Callback<T(T, T, T)> func) { |
elessair | 0:f269e3021894 | 155 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
elessair | 0:f269e3021894 | 156 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); |
elessair | 0:f269e3021894 | 157 | } |
elessair | 0:f269e3021894 | 158 | |
elessair | 0:f269e3021894 | 159 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 160 | static void verify3(O *obj, M method) { |
elessair | 0:f269e3021894 | 161 | Callback<T(T, T, T)> func(obj, method); |
elessair | 0:f269e3021894 | 162 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
elessair | 0:f269e3021894 | 163 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); |
elessair | 0:f269e3021894 | 164 | } |
elessair | 0:f269e3021894 | 165 | |
elessair | 0:f269e3021894 | 166 | static void verify4(Callback<T(T, T, T, T)> func) { |
elessair | 0:f269e3021894 | 167 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
elessair | 0:f269e3021894 | 168 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
elessair | 0:f269e3021894 | 169 | } |
elessair | 0:f269e3021894 | 170 | |
elessair | 0:f269e3021894 | 171 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 172 | static void verify4(O *obj, M method) { |
elessair | 0:f269e3021894 | 173 | Callback<T(T, T, T, T)> func(obj, method); |
elessair | 0:f269e3021894 | 174 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
elessair | 0:f269e3021894 | 175 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
elessair | 0:f269e3021894 | 176 | } |
elessair | 0:f269e3021894 | 177 | |
elessair | 0:f269e3021894 | 178 | static void verify5(Callback<T(T, T, T, T, T)> func) { |
elessair | 0:f269e3021894 | 179 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
elessair | 0:f269e3021894 | 180 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
elessair | 0:f269e3021894 | 181 | } |
elessair | 0:f269e3021894 | 182 | |
elessair | 0:f269e3021894 | 183 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 184 | static void verify5(O *obj, M method) { |
elessair | 0:f269e3021894 | 185 | Callback<T(T, T, T, T, T)> func(obj, method); |
elessair | 0:f269e3021894 | 186 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
elessair | 0:f269e3021894 | 187 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
elessair | 0:f269e3021894 | 188 | } |
elessair | 0:f269e3021894 | 189 | }; |
elessair | 0:f269e3021894 | 190 | |
elessair | 0:f269e3021894 | 191 | |
elessair | 0:f269e3021894 | 192 | // test dispatch |
elessair | 0:f269e3021894 | 193 | template <typename T> |
elessair | 0:f269e3021894 | 194 | void test_dispatch0() { |
elessair | 0:f269e3021894 | 195 | Thing<T> thing; |
elessair | 0:f269e3021894 | 196 | Verifier<T>::verify0(static_func0<T>); |
elessair | 0:f269e3021894 | 197 | Verifier<T>::verify0(&thing, &Thing<T>::member_func0); |
elessair | 0:f269e3021894 | 198 | Verifier<T>::verify0((const Thing<T>*)&thing, &Thing<T>::const_member_func0); |
elessair | 0:f269e3021894 | 199 | Verifier<T>::verify0((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func0); |
elessair | 0:f269e3021894 | 200 | Verifier<T>::verify0((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func0); |
elessair | 0:f269e3021894 | 201 | Verifier<T>::verify0(&bound_func0<T>, &thing); |
elessair | 0:f269e3021894 | 202 | Verifier<T>::verify0(&const_func0<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 203 | Verifier<T>::verify0(&volatile_func0<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 204 | Verifier<T>::verify0(&const_volatile_func0<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 205 | Verifier<T>::verify0(callback(static_func0<T>)); |
elessair | 0:f269e3021894 | 206 | |
elessair | 0:f269e3021894 | 207 | Callback<T()> cb(static_func0); |
elessair | 0:f269e3021894 | 208 | Verifier<T>::verify0(cb); |
elessair | 0:f269e3021894 | 209 | cb = static_func0; |
elessair | 0:f269e3021894 | 210 | Verifier<T>::verify0(cb); |
elessair | 0:f269e3021894 | 211 | cb.attach(&bound_func0<T>, &thing); |
elessair | 0:f269e3021894 | 212 | Verifier<T>::verify0(&cb, &Callback<T()>::call); |
elessair | 0:f269e3021894 | 213 | Verifier<T>::verify0(&Callback<T()>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 214 | } |
elessair | 0:f269e3021894 | 215 | |
elessair | 0:f269e3021894 | 216 | template <typename T> |
elessair | 0:f269e3021894 | 217 | void test_dispatch1() { |
elessair | 0:f269e3021894 | 218 | Thing<T> thing; |
elessair | 0:f269e3021894 | 219 | Verifier<T>::verify1(static_func1<T>); |
elessair | 0:f269e3021894 | 220 | Verifier<T>::verify1(&thing, &Thing<T>::member_func1); |
elessair | 0:f269e3021894 | 221 | Verifier<T>::verify1((const Thing<T>*)&thing, &Thing<T>::const_member_func1); |
elessair | 0:f269e3021894 | 222 | Verifier<T>::verify1((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func1); |
elessair | 0:f269e3021894 | 223 | Verifier<T>::verify1((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func1); |
elessair | 0:f269e3021894 | 224 | Verifier<T>::verify1(&bound_func1<T>, &thing); |
elessair | 0:f269e3021894 | 225 | Verifier<T>::verify1(&const_func1<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 226 | Verifier<T>::verify1(&volatile_func1<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 227 | Verifier<T>::verify1(&const_volatile_func1<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 228 | Verifier<T>::verify1(callback(static_func1<T>)); |
elessair | 0:f269e3021894 | 229 | |
elessair | 0:f269e3021894 | 230 | Callback<T(T)> cb(static_func1); |
elessair | 0:f269e3021894 | 231 | Verifier<T>::verify1(cb); |
elessair | 0:f269e3021894 | 232 | cb = static_func1; |
elessair | 0:f269e3021894 | 233 | Verifier<T>::verify1(cb); |
elessair | 0:f269e3021894 | 234 | cb.attach(&bound_func1<T>, &thing); |
elessair | 0:f269e3021894 | 235 | Verifier<T>::verify1(&cb, &Callback<T(T)>::call); |
elessair | 0:f269e3021894 | 236 | Verifier<T>::verify1(&Callback<T(T)>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 237 | } |
elessair | 0:f269e3021894 | 238 | |
elessair | 0:f269e3021894 | 239 | template <typename T> |
elessair | 0:f269e3021894 | 240 | void test_dispatch2() { |
elessair | 0:f269e3021894 | 241 | Thing<T> thing; |
elessair | 0:f269e3021894 | 242 | Verifier<T>::verify2(static_func2<T>); |
elessair | 0:f269e3021894 | 243 | Verifier<T>::verify2(&thing, &Thing<T>::member_func2); |
elessair | 0:f269e3021894 | 244 | Verifier<T>::verify2((const Thing<T>*)&thing, &Thing<T>::const_member_func2); |
elessair | 0:f269e3021894 | 245 | Verifier<T>::verify2((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func2); |
elessair | 0:f269e3021894 | 246 | Verifier<T>::verify2((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func2); |
elessair | 0:f269e3021894 | 247 | Verifier<T>::verify2(&bound_func2<T>, &thing); |
elessair | 0:f269e3021894 | 248 | Verifier<T>::verify2(&const_func2<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 249 | Verifier<T>::verify2(&volatile_func2<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 250 | Verifier<T>::verify2(&const_volatile_func2<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 251 | Verifier<T>::verify2(callback(static_func2<T>)); |
elessair | 0:f269e3021894 | 252 | |
elessair | 0:f269e3021894 | 253 | Callback<T(T, T)> cb(static_func2); |
elessair | 0:f269e3021894 | 254 | Verifier<T>::verify2(cb); |
elessair | 0:f269e3021894 | 255 | cb = static_func2; |
elessair | 0:f269e3021894 | 256 | Verifier<T>::verify2(cb); |
elessair | 0:f269e3021894 | 257 | cb.attach(&bound_func2<T>, &thing); |
elessair | 0:f269e3021894 | 258 | Verifier<T>::verify2(&cb, &Callback<T(T, T)>::call); |
elessair | 0:f269e3021894 | 259 | Verifier<T>::verify2(&Callback<T(T, T)>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 260 | } |
elessair | 0:f269e3021894 | 261 | |
elessair | 0:f269e3021894 | 262 | template <typename T> |
elessair | 0:f269e3021894 | 263 | void test_dispatch3() { |
elessair | 0:f269e3021894 | 264 | Thing<T> thing; |
elessair | 0:f269e3021894 | 265 | Verifier<T>::verify3(static_func3<T>); |
elessair | 0:f269e3021894 | 266 | Verifier<T>::verify3(&thing, &Thing<T>::member_func3); |
elessair | 0:f269e3021894 | 267 | Verifier<T>::verify3((const Thing<T>*)&thing, &Thing<T>::const_member_func3); |
elessair | 0:f269e3021894 | 268 | Verifier<T>::verify3((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func3); |
elessair | 0:f269e3021894 | 269 | Verifier<T>::verify3((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func3); |
elessair | 0:f269e3021894 | 270 | Verifier<T>::verify3(&bound_func3<T>, &thing); |
elessair | 0:f269e3021894 | 271 | Verifier<T>::verify3(&const_func3<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 272 | Verifier<T>::verify3(&volatile_func3<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 273 | Verifier<T>::verify3(&const_volatile_func3<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 274 | Verifier<T>::verify3(callback(static_func3<T>)); |
elessair | 0:f269e3021894 | 275 | |
elessair | 0:f269e3021894 | 276 | Callback<T(T, T, T)> cb(static_func3); |
elessair | 0:f269e3021894 | 277 | Verifier<T>::verify3(cb); |
elessair | 0:f269e3021894 | 278 | cb = static_func3; |
elessair | 0:f269e3021894 | 279 | Verifier<T>::verify3(cb); |
elessair | 0:f269e3021894 | 280 | cb.attach(&bound_func3<T>, &thing); |
elessair | 0:f269e3021894 | 281 | Verifier<T>::verify3(&cb, &Callback<T(T, T, T)>::call); |
elessair | 0:f269e3021894 | 282 | Verifier<T>::verify3(&Callback<T(T, T, T)>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 283 | } |
elessair | 0:f269e3021894 | 284 | |
elessair | 0:f269e3021894 | 285 | template <typename T> |
elessair | 0:f269e3021894 | 286 | void test_dispatch4() { |
elessair | 0:f269e3021894 | 287 | Thing<T> thing; |
elessair | 0:f269e3021894 | 288 | Verifier<T>::verify4(static_func4<T>); |
elessair | 0:f269e3021894 | 289 | Verifier<T>::verify4(&thing, &Thing<T>::member_func4); |
elessair | 0:f269e3021894 | 290 | Verifier<T>::verify4((const Thing<T>*)&thing, &Thing<T>::const_member_func4); |
elessair | 0:f269e3021894 | 291 | Verifier<T>::verify4((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func4); |
elessair | 0:f269e3021894 | 292 | Verifier<T>::verify4((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func4); |
elessair | 0:f269e3021894 | 293 | Verifier<T>::verify4(&bound_func4<T>, &thing); |
elessair | 0:f269e3021894 | 294 | Verifier<T>::verify4(&const_func4<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 295 | Verifier<T>::verify4(&volatile_func4<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 296 | Verifier<T>::verify4(&const_volatile_func4<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 297 | Verifier<T>::verify4(callback(static_func4<T>)); |
elessair | 0:f269e3021894 | 298 | |
elessair | 0:f269e3021894 | 299 | Callback<T(T, T, T, T)> cb(static_func4); |
elessair | 0:f269e3021894 | 300 | Verifier<T>::verify4(cb); |
elessair | 0:f269e3021894 | 301 | cb = static_func4; |
elessair | 0:f269e3021894 | 302 | Verifier<T>::verify4(cb); |
elessair | 0:f269e3021894 | 303 | cb.attach(&bound_func4<T>, &thing); |
elessair | 0:f269e3021894 | 304 | Verifier<T>::verify4(&cb, &Callback<T(T, T, T, T)>::call); |
elessair | 0:f269e3021894 | 305 | Verifier<T>::verify4(&Callback<T(T, T, T, T)>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 306 | } |
elessair | 0:f269e3021894 | 307 | |
elessair | 0:f269e3021894 | 308 | template <typename T> |
elessair | 0:f269e3021894 | 309 | void test_dispatch5() { |
elessair | 0:f269e3021894 | 310 | Thing<T> thing; |
elessair | 0:f269e3021894 | 311 | Verifier<T>::verify5(static_func5<T>); |
elessair | 0:f269e3021894 | 312 | Verifier<T>::verify5(&thing, &Thing<T>::member_func5); |
elessair | 0:f269e3021894 | 313 | Verifier<T>::verify5((const Thing<T>*)&thing, &Thing<T>::const_member_func5); |
elessair | 0:f269e3021894 | 314 | Verifier<T>::verify5((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func5); |
elessair | 0:f269e3021894 | 315 | Verifier<T>::verify5((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func5); |
elessair | 0:f269e3021894 | 316 | Verifier<T>::verify5(&bound_func5<T>, &thing); |
elessair | 0:f269e3021894 | 317 | Verifier<T>::verify5(&const_func5<T>, (const Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 318 | Verifier<T>::verify5(&volatile_func5<T>, (volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 319 | Verifier<T>::verify5(&const_volatile_func5<T>, (const volatile Thing<T>*)&thing); |
elessair | 0:f269e3021894 | 320 | Verifier<T>::verify5(callback(static_func5<T>)); |
elessair | 0:f269e3021894 | 321 | |
elessair | 0:f269e3021894 | 322 | Callback<T(T, T, T, T, T)> cb(static_func5); |
elessair | 0:f269e3021894 | 323 | Verifier<T>::verify5(cb); |
elessair | 0:f269e3021894 | 324 | cb = static_func5; |
elessair | 0:f269e3021894 | 325 | Verifier<T>::verify5(cb); |
elessair | 0:f269e3021894 | 326 | cb.attach(&bound_func5<T>, &thing); |
elessair | 0:f269e3021894 | 327 | Verifier<T>::verify5(&cb, &Callback<T(T, T, T, T, T)>::call); |
elessair | 0:f269e3021894 | 328 | Verifier<T>::verify5(&Callback<T(T, T, T, T, T)>::thunk, (void*)&cb); |
elessair | 0:f269e3021894 | 329 | } |
elessair | 0:f269e3021894 | 330 | |
elessair | 0:f269e3021894 | 331 | |
elessair | 0:f269e3021894 | 332 | // Test setup |
elessair | 0:f269e3021894 | 333 | utest::v1::status_t test_setup(const size_t number_of_cases) { |
elessair | 0:f269e3021894 | 334 | GREENTEA_SETUP(10, "default_auto"); |
elessair | 0:f269e3021894 | 335 | return verbose_test_setup_handler(number_of_cases); |
elessair | 0:f269e3021894 | 336 | } |
elessair | 0:f269e3021894 | 337 | |
elessair | 0:f269e3021894 | 338 | Case cases[] = { |
elessair | 0:f269e3021894 | 339 | Case("Testing callbacks with 0 uint64s", test_dispatch0<uint64_t>), |
elessair | 0:f269e3021894 | 340 | Case("Testing callbacks with 1 uint64s", test_dispatch1<uint64_t>), |
elessair | 0:f269e3021894 | 341 | Case("Testing callbacks with 2 uint64s", test_dispatch2<uint64_t>), |
elessair | 0:f269e3021894 | 342 | Case("Testing callbacks with 3 uint64s", test_dispatch3<uint64_t>), |
elessair | 0:f269e3021894 | 343 | Case("Testing callbacks with 4 uint64s", test_dispatch4<uint64_t>), |
elessair | 0:f269e3021894 | 344 | Case("Testing callbacks with 5 uint64s", test_dispatch5<uint64_t>), |
elessair | 0:f269e3021894 | 345 | }; |
elessair | 0:f269e3021894 | 346 | |
elessair | 0:f269e3021894 | 347 | Specification specification(test_setup, cases); |
elessair | 0:f269e3021894 | 348 | |
elessair | 0:f269e3021894 | 349 | int main() { |
elessair | 0:f269e3021894 | 350 | return !Harness::run(specification); |
elessair | 0:f269e3021894 | 351 | } |