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