Preliminary main mbed library for nexpaq development
TESTS/mbed_functional/functionpointer/main.cpp@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
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() |
nexpaq | 0:6c56fb4bc5f0 | 12 | { return 0; } |
nexpaq | 0:6c56fb4bc5f0 | 13 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 14 | T static_func1(T a0) |
nexpaq | 0:6c56fb4bc5f0 | 15 | { return 0 | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 16 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 17 | T static_func2(T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 18 | { return 0 | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 19 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 20 | T static_func3(T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 21 | { return 0 | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 22 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 23 | T static_func4(T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 24 | { return 0 | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 25 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 26 | T static_func5(T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 27 | { return 0 | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 28 | |
nexpaq | 0:6c56fb4bc5f0 | 29 | // class functions |
nexpaq | 0:6c56fb4bc5f0 | 30 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 31 | struct Thing { |
nexpaq | 0:6c56fb4bc5f0 | 32 | T t; |
nexpaq | 0:6c56fb4bc5f0 | 33 | Thing() : t(0x80) {} |
nexpaq | 0:6c56fb4bc5f0 | 34 | |
nexpaq | 0:6c56fb4bc5f0 | 35 | T member_func0() |
nexpaq | 0:6c56fb4bc5f0 | 36 | { return t; } |
nexpaq | 0:6c56fb4bc5f0 | 37 | T member_func1(T a0) |
nexpaq | 0:6c56fb4bc5f0 | 38 | { return t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 39 | T member_func2(T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 40 | { return t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 41 | T member_func3(T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 42 | { return t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 43 | T member_func4(T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 44 | { return t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 45 | T member_func5(T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 46 | { return t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 47 | |
nexpaq | 0:6c56fb4bc5f0 | 48 | T const_member_func0() const |
nexpaq | 0:6c56fb4bc5f0 | 49 | { return t; } |
nexpaq | 0:6c56fb4bc5f0 | 50 | T const_member_func1(T a0) const |
nexpaq | 0:6c56fb4bc5f0 | 51 | { return t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 52 | T const_member_func2(T a0, T a1) const |
nexpaq | 0:6c56fb4bc5f0 | 53 | { return t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 54 | T const_member_func3(T a0, T a1, T a2) const |
nexpaq | 0:6c56fb4bc5f0 | 55 | { return t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 56 | T const_member_func4(T a0, T a1, T a2, T a3) const |
nexpaq | 0:6c56fb4bc5f0 | 57 | { return t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 58 | T const_member_func5(T a0, T a1, T a2, T a3, T a4) const |
nexpaq | 0:6c56fb4bc5f0 | 59 | { return t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 60 | |
nexpaq | 0:6c56fb4bc5f0 | 61 | T volatile_member_func0() volatile |
nexpaq | 0:6c56fb4bc5f0 | 62 | { return t; } |
nexpaq | 0:6c56fb4bc5f0 | 63 | T volatile_member_func1(T a0) volatile |
nexpaq | 0:6c56fb4bc5f0 | 64 | { return t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 65 | T volatile_member_func2(T a0, T a1) volatile |
nexpaq | 0:6c56fb4bc5f0 | 66 | { return t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 67 | T volatile_member_func3(T a0, T a1, T a2) volatile |
nexpaq | 0:6c56fb4bc5f0 | 68 | { return t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 69 | T volatile_member_func4(T a0, T a1, T a2, T a3) volatile |
nexpaq | 0:6c56fb4bc5f0 | 70 | { return t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 71 | T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile |
nexpaq | 0:6c56fb4bc5f0 | 72 | { return t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 73 | |
nexpaq | 0:6c56fb4bc5f0 | 74 | T const_volatile_member_func0() const volatile |
nexpaq | 0:6c56fb4bc5f0 | 75 | { return t; } |
nexpaq | 0:6c56fb4bc5f0 | 76 | T const_volatile_member_func1(T a0) const volatile |
nexpaq | 0:6c56fb4bc5f0 | 77 | { return t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 78 | T const_volatile_member_func2(T a0, T a1) const volatile |
nexpaq | 0:6c56fb4bc5f0 | 79 | { return t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 80 | T const_volatile_member_func3(T a0, T a1, T a2) const volatile |
nexpaq | 0:6c56fb4bc5f0 | 81 | { return t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 82 | T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile |
nexpaq | 0:6c56fb4bc5f0 | 83 | { return t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 84 | T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile |
nexpaq | 0:6c56fb4bc5f0 | 85 | { return t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 86 | }; |
nexpaq | 0:6c56fb4bc5f0 | 87 | |
nexpaq | 0:6c56fb4bc5f0 | 88 | // bound functions |
nexpaq | 0:6c56fb4bc5f0 | 89 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 90 | T bound_func0(Thing<T> *t) |
nexpaq | 0:6c56fb4bc5f0 | 91 | { return t->t; } |
nexpaq | 0:6c56fb4bc5f0 | 92 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 93 | T bound_func1(Thing<T> *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 94 | { return t->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 95 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 96 | T bound_func2(Thing<T> *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 97 | { return t->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 98 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 99 | T bound_func3(Thing<T> *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 100 | { return t->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 101 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 102 | T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 103 | { return t->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 104 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 105 | T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 106 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 107 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 108 | T const_bound_func0(const Thing<T> *t) |
nexpaq | 0:6c56fb4bc5f0 | 109 | { return t->t; } |
nexpaq | 0:6c56fb4bc5f0 | 110 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 111 | T const_bound_func1(const Thing<T> *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 112 | { return t->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 113 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 114 | T const_bound_func2(const Thing<T> *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 115 | { return t->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 116 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 117 | T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 118 | { return t->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 119 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 120 | T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 121 | { return t->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 122 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 123 | T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 124 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 125 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 126 | T volatile_bound_func0(volatile Thing<T> *t) |
nexpaq | 0:6c56fb4bc5f0 | 127 | { return t->t; } |
nexpaq | 0:6c56fb4bc5f0 | 128 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 129 | T volatile_bound_func1(volatile Thing<T> *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 130 | { return t->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 131 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 132 | T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 133 | { return t->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 134 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 135 | T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 136 | { return t->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 137 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 138 | T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 139 | { return t->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 140 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 141 | T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 142 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 143 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 144 | T const_volatile_bound_func0(const volatile Thing<T> *t) |
nexpaq | 0:6c56fb4bc5f0 | 145 | { return t->t; } |
nexpaq | 0:6c56fb4bc5f0 | 146 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 147 | T const_volatile_bound_func1(const volatile Thing<T> *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 148 | { return t->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 149 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 150 | T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 151 | { return t->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 152 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 153 | T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 154 | { return t->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 155 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 156 | T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 157 | { return t->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 158 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 159 | T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 160 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 161 | |
nexpaq | 0:6c56fb4bc5f0 | 162 | // void functions |
nexpaq | 0:6c56fb4bc5f0 | 163 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 164 | T void_func0(void *t) |
nexpaq | 0:6c56fb4bc5f0 | 165 | { return static_cast<Thing<T>*>(t)->t; } |
nexpaq | 0:6c56fb4bc5f0 | 166 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 167 | T void_func1(void *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 168 | { return static_cast<Thing<T>*>(t)->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 169 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 170 | T void_func2(void *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 171 | { return static_cast<Thing<T>*>(t)->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 172 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 173 | T void_func3(void *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 174 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 175 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 176 | T void_func4(void *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 177 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 178 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 179 | T void_func5(void *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 180 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 181 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 182 | T const_void_func0(const void *t) |
nexpaq | 0:6c56fb4bc5f0 | 183 | { return static_cast<const Thing<T>*>(t)->t; } |
nexpaq | 0:6c56fb4bc5f0 | 184 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 185 | T const_void_func1(const void *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 186 | { return static_cast<const Thing<T>*>(t)->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 187 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 188 | T const_void_func2(const void *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 189 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 190 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 191 | T const_void_func3(const void *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 192 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 193 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 194 | T const_void_func4(const void *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 195 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 196 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 197 | T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 198 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 199 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 200 | T volatile_void_func0(volatile void *t) |
nexpaq | 0:6c56fb4bc5f0 | 201 | { return static_cast<volatile Thing<T>*>(t)->t; } |
nexpaq | 0:6c56fb4bc5f0 | 202 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 203 | T volatile_void_func1(volatile void *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 204 | { return static_cast<volatile Thing<T>*>(t)->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 205 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 206 | T volatile_void_func2(volatile void *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 207 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 208 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 209 | T volatile_void_func3(volatile void *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 210 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 211 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 212 | T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 213 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 214 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 215 | T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 216 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 217 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 218 | T const_volatile_void_func0(const volatile void *t) |
nexpaq | 0:6c56fb4bc5f0 | 219 | { return static_cast<const volatile Thing<T>*>(t)->t; } |
nexpaq | 0:6c56fb4bc5f0 | 220 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 221 | T const_volatile_void_func1(const volatile void *t, T a0) |
nexpaq | 0:6c56fb4bc5f0 | 222 | { return static_cast<const volatile Thing<T>*>(t)->t | a0; } |
nexpaq | 0:6c56fb4bc5f0 | 223 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 224 | T const_volatile_void_func2(const volatile void *t, T a0, T a1) |
nexpaq | 0:6c56fb4bc5f0 | 225 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; } |
nexpaq | 0:6c56fb4bc5f0 | 226 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 227 | T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2) |
nexpaq | 0:6c56fb4bc5f0 | 228 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; } |
nexpaq | 0:6c56fb4bc5f0 | 229 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 230 | T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3) |
nexpaq | 0:6c56fb4bc5f0 | 231 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
nexpaq | 0:6c56fb4bc5f0 | 232 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 233 | T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4) |
nexpaq | 0:6c56fb4bc5f0 | 234 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
nexpaq | 0:6c56fb4bc5f0 | 235 | |
nexpaq | 0:6c56fb4bc5f0 | 236 | |
nexpaq | 0:6c56fb4bc5f0 | 237 | // function call and result verification |
nexpaq | 0:6c56fb4bc5f0 | 238 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 239 | struct Verifier { |
nexpaq | 0:6c56fb4bc5f0 | 240 | static void verify0(Callback<T()> func) { |
nexpaq | 0:6c56fb4bc5f0 | 241 | T result = func(); |
nexpaq | 0:6c56fb4bc5f0 | 242 | TEST_ASSERT_EQUAL(result, 0x00); |
nexpaq | 0:6c56fb4bc5f0 | 243 | } |
nexpaq | 0:6c56fb4bc5f0 | 244 | |
nexpaq | 0:6c56fb4bc5f0 | 245 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 246 | static void verify0(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 247 | Callback<T()> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 248 | T result = func(); |
nexpaq | 0:6c56fb4bc5f0 | 249 | TEST_ASSERT_EQUAL(result, 0x80); |
nexpaq | 0:6c56fb4bc5f0 | 250 | } |
nexpaq | 0:6c56fb4bc5f0 | 251 | |
nexpaq | 0:6c56fb4bc5f0 | 252 | static void verify1(Callback<T(T)> func) { |
nexpaq | 0:6c56fb4bc5f0 | 253 | T result = func((1 << 0)); |
nexpaq | 0:6c56fb4bc5f0 | 254 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); |
nexpaq | 0:6c56fb4bc5f0 | 255 | } |
nexpaq | 0:6c56fb4bc5f0 | 256 | |
nexpaq | 0:6c56fb4bc5f0 | 257 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 258 | static void verify1(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 259 | Callback<T(T)> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 260 | T result = func((1 << 0)); |
nexpaq | 0:6c56fb4bc5f0 | 261 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); |
nexpaq | 0:6c56fb4bc5f0 | 262 | } |
nexpaq | 0:6c56fb4bc5f0 | 263 | |
nexpaq | 0:6c56fb4bc5f0 | 264 | static void verify2(Callback<T(T, T)> func) { |
nexpaq | 0:6c56fb4bc5f0 | 265 | T result = func((1 << 0), (1 << 1)); |
nexpaq | 0:6c56fb4bc5f0 | 266 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); |
nexpaq | 0:6c56fb4bc5f0 | 267 | } |
nexpaq | 0:6c56fb4bc5f0 | 268 | |
nexpaq | 0:6c56fb4bc5f0 | 269 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 270 | static void verify2(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 271 | Callback<T(T, T)> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 272 | T result = func((1 << 0), (1 << 1)); |
nexpaq | 0:6c56fb4bc5f0 | 273 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); |
nexpaq | 0:6c56fb4bc5f0 | 274 | } |
nexpaq | 0:6c56fb4bc5f0 | 275 | |
nexpaq | 0:6c56fb4bc5f0 | 276 | static void verify3(Callback<T(T, T, T)> func) { |
nexpaq | 0:6c56fb4bc5f0 | 277 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
nexpaq | 0:6c56fb4bc5f0 | 278 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); |
nexpaq | 0:6c56fb4bc5f0 | 279 | } |
nexpaq | 0:6c56fb4bc5f0 | 280 | |
nexpaq | 0:6c56fb4bc5f0 | 281 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 282 | static void verify3(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 283 | Callback<T(T, T, T)> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 284 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
nexpaq | 0:6c56fb4bc5f0 | 285 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); |
nexpaq | 0:6c56fb4bc5f0 | 286 | } |
nexpaq | 0:6c56fb4bc5f0 | 287 | |
nexpaq | 0:6c56fb4bc5f0 | 288 | static void verify4(Callback<T(T, T, T, T)> func) { |
nexpaq | 0:6c56fb4bc5f0 | 289 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
nexpaq | 0:6c56fb4bc5f0 | 290 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
nexpaq | 0:6c56fb4bc5f0 | 291 | } |
nexpaq | 0:6c56fb4bc5f0 | 292 | |
nexpaq | 0:6c56fb4bc5f0 | 293 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 294 | static void verify4(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 295 | Callback<T(T, T, T, T)> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 296 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
nexpaq | 0:6c56fb4bc5f0 | 297 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
nexpaq | 0:6c56fb4bc5f0 | 298 | } |
nexpaq | 0:6c56fb4bc5f0 | 299 | |
nexpaq | 0:6c56fb4bc5f0 | 300 | static void verify5(Callback<T(T, T, T, T, T)> func) { |
nexpaq | 0:6c56fb4bc5f0 | 301 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
nexpaq | 0:6c56fb4bc5f0 | 302 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
nexpaq | 0:6c56fb4bc5f0 | 303 | } |
nexpaq | 0:6c56fb4bc5f0 | 304 | |
nexpaq | 0:6c56fb4bc5f0 | 305 | template <typename O, typename M> |
nexpaq | 0:6c56fb4bc5f0 | 306 | static void verify5(O *obj, M method) { |
nexpaq | 0:6c56fb4bc5f0 | 307 | Callback<T(T, T, T, T, T)> func(obj, method); |
nexpaq | 0:6c56fb4bc5f0 | 308 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
nexpaq | 0:6c56fb4bc5f0 | 309 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
nexpaq | 0:6c56fb4bc5f0 | 310 | } |
nexpaq | 0:6c56fb4bc5f0 | 311 | }; |
nexpaq | 0:6c56fb4bc5f0 | 312 | |
nexpaq | 0:6c56fb4bc5f0 | 313 | |
nexpaq | 0:6c56fb4bc5f0 | 314 | // test dispatch |
nexpaq | 0:6c56fb4bc5f0 | 315 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 316 | void test_fparg1() { |
nexpaq | 0:6c56fb4bc5f0 | 317 | Thing<T> thing; |
nexpaq | 0:6c56fb4bc5f0 | 318 | FunctionPointerArg1<T,T> fp(static_func1<T>); |
nexpaq | 0:6c56fb4bc5f0 | 319 | Verifier<T>::verify1(fp); |
nexpaq | 0:6c56fb4bc5f0 | 320 | Verifier<T>::verify1(fp.get_function()); |
nexpaq | 0:6c56fb4bc5f0 | 321 | } |
nexpaq | 0:6c56fb4bc5f0 | 322 | |
nexpaq | 0:6c56fb4bc5f0 | 323 | template <typename T> |
nexpaq | 0:6c56fb4bc5f0 | 324 | void test_fparg0() { |
nexpaq | 0:6c56fb4bc5f0 | 325 | Thing<T> thing; |
nexpaq | 0:6c56fb4bc5f0 | 326 | FunctionPointerArg1<T,void> fp(static_func0<T>); |
nexpaq | 0:6c56fb4bc5f0 | 327 | Verifier<T>::verify0(fp); |
nexpaq | 0:6c56fb4bc5f0 | 328 | Verifier<T>::verify0(fp.get_function()); |
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 FunctionPointerArg1 compatibility", test_fparg1<int>), |
nexpaq | 0:6c56fb4bc5f0 | 340 | Case("Testing FunctionPointer compatibility", test_fparg0<int>), |
nexpaq | 0:6c56fb4bc5f0 | 341 | }; |
nexpaq | 0:6c56fb4bc5f0 | 342 | |
nexpaq | 0:6c56fb4bc5f0 | 343 | Specification specification(test_setup, cases); |
nexpaq | 0:6c56fb4bc5f0 | 344 | |
nexpaq | 0:6c56fb4bc5f0 | 345 | int main() { |
nexpaq | 0:6c56fb4bc5f0 | 346 | return !Harness::run(specification); |
nexpaq | 0:6c56fb4bc5f0 | 347 | } |