Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/TESTS/mbed_functional/callback/main.cpp@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | /* mbed Microcontroller Library |
marcozecchini | 0:9fca2b23d0ba | 2 | * Copyright (c) 2017 ARM Limited |
marcozecchini | 0:9fca2b23d0ba | 3 | * |
marcozecchini | 0:9fca2b23d0ba | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
marcozecchini | 0:9fca2b23d0ba | 5 | * you may not use this file except in compliance with the License. |
marcozecchini | 0:9fca2b23d0ba | 6 | * You may obtain a copy of the License at |
marcozecchini | 0:9fca2b23d0ba | 7 | * |
marcozecchini | 0:9fca2b23d0ba | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
marcozecchini | 0:9fca2b23d0ba | 9 | * |
marcozecchini | 0:9fca2b23d0ba | 10 | * Unless required by applicable law or agreed to in writing, software |
marcozecchini | 0:9fca2b23d0ba | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
marcozecchini | 0:9fca2b23d0ba | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
marcozecchini | 0:9fca2b23d0ba | 13 | * See the License for the specific language governing permissions and |
marcozecchini | 0:9fca2b23d0ba | 14 | * limitations under the License. |
marcozecchini | 0:9fca2b23d0ba | 15 | */ |
marcozecchini | 0:9fca2b23d0ba | 16 | #include "mbed.h" |
marcozecchini | 0:9fca2b23d0ba | 17 | #include "greentea-client/test_env.h" |
marcozecchini | 0:9fca2b23d0ba | 18 | #include "unity.h" |
marcozecchini | 0:9fca2b23d0ba | 19 | #include "utest.h" |
marcozecchini | 0:9fca2b23d0ba | 20 | |
marcozecchini | 0:9fca2b23d0ba | 21 | using namespace utest::v1; |
marcozecchini | 0:9fca2b23d0ba | 22 | |
marcozecchini | 0:9fca2b23d0ba | 23 | |
marcozecchini | 0:9fca2b23d0ba | 24 | // static functions |
marcozecchini | 0:9fca2b23d0ba | 25 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 26 | T static_func0() |
marcozecchini | 0:9fca2b23d0ba | 27 | { return 0; } |
marcozecchini | 0:9fca2b23d0ba | 28 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 29 | T static_func1(T a0) |
marcozecchini | 0:9fca2b23d0ba | 30 | { return 0 | a0; } |
marcozecchini | 0:9fca2b23d0ba | 31 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 32 | T static_func2(T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 33 | { return 0 | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 34 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 35 | T static_func3(T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 36 | { return 0 | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 37 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 38 | T static_func4(T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 39 | { return 0 | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 40 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 41 | T static_func5(T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 42 | { return 0 | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 43 | |
marcozecchini | 0:9fca2b23d0ba | 44 | // class functions |
marcozecchini | 0:9fca2b23d0ba | 45 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 46 | struct Thing { |
marcozecchini | 0:9fca2b23d0ba | 47 | T t; |
marcozecchini | 0:9fca2b23d0ba | 48 | Thing() : t(0x80) {} |
marcozecchini | 0:9fca2b23d0ba | 49 | |
marcozecchini | 0:9fca2b23d0ba | 50 | T member_func0() |
marcozecchini | 0:9fca2b23d0ba | 51 | { return t; } |
marcozecchini | 0:9fca2b23d0ba | 52 | T member_func1(T a0) |
marcozecchini | 0:9fca2b23d0ba | 53 | { return t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 54 | T member_func2(T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 55 | { return t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 56 | T member_func3(T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 57 | { return t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 58 | T member_func4(T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 59 | { return t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 60 | T member_func5(T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 61 | { return t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 62 | |
marcozecchini | 0:9fca2b23d0ba | 63 | T const_member_func0() const |
marcozecchini | 0:9fca2b23d0ba | 64 | { return t; } |
marcozecchini | 0:9fca2b23d0ba | 65 | T const_member_func1(T a0) const |
marcozecchini | 0:9fca2b23d0ba | 66 | { return t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 67 | T const_member_func2(T a0, T a1) const |
marcozecchini | 0:9fca2b23d0ba | 68 | { return t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 69 | T const_member_func3(T a0, T a1, T a2) const |
marcozecchini | 0:9fca2b23d0ba | 70 | { return t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 71 | T const_member_func4(T a0, T a1, T a2, T a3) const |
marcozecchini | 0:9fca2b23d0ba | 72 | { return t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 73 | T const_member_func5(T a0, T a1, T a2, T a3, T a4) const |
marcozecchini | 0:9fca2b23d0ba | 74 | { return t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 75 | |
marcozecchini | 0:9fca2b23d0ba | 76 | T volatile_member_func0() volatile |
marcozecchini | 0:9fca2b23d0ba | 77 | { return t; } |
marcozecchini | 0:9fca2b23d0ba | 78 | T volatile_member_func1(T a0) volatile |
marcozecchini | 0:9fca2b23d0ba | 79 | { return t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 80 | T volatile_member_func2(T a0, T a1) volatile |
marcozecchini | 0:9fca2b23d0ba | 81 | { return t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 82 | T volatile_member_func3(T a0, T a1, T a2) volatile |
marcozecchini | 0:9fca2b23d0ba | 83 | { return t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 84 | T volatile_member_func4(T a0, T a1, T a2, T a3) volatile |
marcozecchini | 0:9fca2b23d0ba | 85 | { return t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 86 | T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile |
marcozecchini | 0:9fca2b23d0ba | 87 | { return t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 88 | |
marcozecchini | 0:9fca2b23d0ba | 89 | T const_volatile_member_func0() const volatile |
marcozecchini | 0:9fca2b23d0ba | 90 | { return t; } |
marcozecchini | 0:9fca2b23d0ba | 91 | T const_volatile_member_func1(T a0) const volatile |
marcozecchini | 0:9fca2b23d0ba | 92 | { return t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 93 | T const_volatile_member_func2(T a0, T a1) const volatile |
marcozecchini | 0:9fca2b23d0ba | 94 | { return t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 95 | T const_volatile_member_func3(T a0, T a1, T a2) const volatile |
marcozecchini | 0:9fca2b23d0ba | 96 | { return t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 97 | T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile |
marcozecchini | 0:9fca2b23d0ba | 98 | { return t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 99 | T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile |
marcozecchini | 0:9fca2b23d0ba | 100 | { return t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 101 | }; |
marcozecchini | 0:9fca2b23d0ba | 102 | |
marcozecchini | 0:9fca2b23d0ba | 103 | // bound functions |
marcozecchini | 0:9fca2b23d0ba | 104 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 105 | T bound_func0(Thing<T> *t) |
marcozecchini | 0:9fca2b23d0ba | 106 | { return t->t; } |
marcozecchini | 0:9fca2b23d0ba | 107 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 108 | T bound_func1(Thing<T> *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 109 | { return t->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 110 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 111 | T bound_func2(Thing<T> *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 112 | { return t->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 113 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 114 | T bound_func3(Thing<T> *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 115 | { return t->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 116 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 117 | T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 118 | { return t->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 119 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 120 | T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 121 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 122 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 123 | T const_bound_func0(const Thing<T> *t) |
marcozecchini | 0:9fca2b23d0ba | 124 | { return t->t; } |
marcozecchini | 0:9fca2b23d0ba | 125 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 126 | T const_bound_func1(const Thing<T> *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 127 | { return t->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 128 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 129 | T const_bound_func2(const Thing<T> *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 130 | { return t->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 131 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 132 | T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 133 | { return t->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 134 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 135 | T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 136 | { return t->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 137 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 138 | T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 139 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 140 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 141 | T volatile_bound_func0(volatile Thing<T> *t) |
marcozecchini | 0:9fca2b23d0ba | 142 | { return t->t; } |
marcozecchini | 0:9fca2b23d0ba | 143 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 144 | T volatile_bound_func1(volatile Thing<T> *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 145 | { return t->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 146 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 147 | T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 148 | { return t->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 149 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 150 | T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 151 | { return t->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 152 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 153 | T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 154 | { return t->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 155 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 156 | T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 157 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 158 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 159 | T const_volatile_bound_func0(const volatile Thing<T> *t) |
marcozecchini | 0:9fca2b23d0ba | 160 | { return t->t; } |
marcozecchini | 0:9fca2b23d0ba | 161 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 162 | T const_volatile_bound_func1(const volatile Thing<T> *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 163 | { return t->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 164 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 165 | T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 166 | { return t->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 167 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 168 | T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 169 | { return t->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 170 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 171 | T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 172 | { return t->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 173 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 174 | T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 175 | { return t->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 176 | |
marcozecchini | 0:9fca2b23d0ba | 177 | // void functions |
marcozecchini | 0:9fca2b23d0ba | 178 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 179 | T void_func0(void *t) |
marcozecchini | 0:9fca2b23d0ba | 180 | { return static_cast<Thing<T>*>(t)->t; } |
marcozecchini | 0:9fca2b23d0ba | 181 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 182 | T void_func1(void *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 183 | { return static_cast<Thing<T>*>(t)->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 184 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 185 | T void_func2(void *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 186 | { return static_cast<Thing<T>*>(t)->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 187 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 188 | T void_func3(void *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 189 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 190 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 191 | T void_func4(void *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 192 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 193 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 194 | T void_func5(void *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 195 | { return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 196 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 197 | T const_void_func0(const void *t) |
marcozecchini | 0:9fca2b23d0ba | 198 | { return static_cast<const Thing<T>*>(t)->t; } |
marcozecchini | 0:9fca2b23d0ba | 199 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 200 | T const_void_func1(const void *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 201 | { return static_cast<const Thing<T>*>(t)->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 202 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 203 | T const_void_func2(const void *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 204 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 205 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 206 | T const_void_func3(const void *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 207 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 208 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 209 | T const_void_func4(const void *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 210 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 211 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 212 | T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 213 | { return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 214 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 215 | T volatile_void_func0(volatile void *t) |
marcozecchini | 0:9fca2b23d0ba | 216 | { return static_cast<volatile Thing<T>*>(t)->t; } |
marcozecchini | 0:9fca2b23d0ba | 217 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 218 | T volatile_void_func1(volatile void *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 219 | { return static_cast<volatile Thing<T>*>(t)->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 220 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 221 | T volatile_void_func2(volatile void *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 222 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 223 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 224 | T volatile_void_func3(volatile void *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 225 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 226 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 227 | T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 228 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 229 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 230 | T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 231 | { return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 232 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 233 | T const_volatile_void_func0(const volatile void *t) |
marcozecchini | 0:9fca2b23d0ba | 234 | { return static_cast<const volatile Thing<T>*>(t)->t; } |
marcozecchini | 0:9fca2b23d0ba | 235 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 236 | T const_volatile_void_func1(const volatile void *t, T a0) |
marcozecchini | 0:9fca2b23d0ba | 237 | { return static_cast<const volatile Thing<T>*>(t)->t | a0; } |
marcozecchini | 0:9fca2b23d0ba | 238 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 239 | T const_volatile_void_func2(const volatile void *t, T a0, T a1) |
marcozecchini | 0:9fca2b23d0ba | 240 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; } |
marcozecchini | 0:9fca2b23d0ba | 241 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 242 | T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2) |
marcozecchini | 0:9fca2b23d0ba | 243 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; } |
marcozecchini | 0:9fca2b23d0ba | 244 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 245 | T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3) |
marcozecchini | 0:9fca2b23d0ba | 246 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; } |
marcozecchini | 0:9fca2b23d0ba | 247 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 248 | T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4) |
marcozecchini | 0:9fca2b23d0ba | 249 | { return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; } |
marcozecchini | 0:9fca2b23d0ba | 250 | |
marcozecchini | 0:9fca2b23d0ba | 251 | // Inheriting class |
marcozecchini | 0:9fca2b23d0ba | 252 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 253 | class Thing2 : public Thing<T> { |
marcozecchini | 0:9fca2b23d0ba | 254 | }; |
marcozecchini | 0:9fca2b23d0ba | 255 | |
marcozecchini | 0:9fca2b23d0ba | 256 | |
marcozecchini | 0:9fca2b23d0ba | 257 | // function call and result verification |
marcozecchini | 0:9fca2b23d0ba | 258 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 259 | struct Verifier { |
marcozecchini | 0:9fca2b23d0ba | 260 | static void verify0(Callback<T()> func) { |
marcozecchini | 0:9fca2b23d0ba | 261 | T result = func(); |
marcozecchini | 0:9fca2b23d0ba | 262 | TEST_ASSERT_EQUAL(result, 0x00); |
marcozecchini | 0:9fca2b23d0ba | 263 | } |
marcozecchini | 0:9fca2b23d0ba | 264 | |
marcozecchini | 0:9fca2b23d0ba | 265 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 266 | static void verify0(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 267 | Callback<T()> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 268 | T result = func(); |
marcozecchini | 0:9fca2b23d0ba | 269 | TEST_ASSERT_EQUAL(result, 0x80); |
marcozecchini | 0:9fca2b23d0ba | 270 | } |
marcozecchini | 0:9fca2b23d0ba | 271 | |
marcozecchini | 0:9fca2b23d0ba | 272 | static void verify1(Callback<T(T)> func) { |
marcozecchini | 0:9fca2b23d0ba | 273 | T result = func((1 << 0)); |
marcozecchini | 0:9fca2b23d0ba | 274 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); |
marcozecchini | 0:9fca2b23d0ba | 275 | } |
marcozecchini | 0:9fca2b23d0ba | 276 | |
marcozecchini | 0:9fca2b23d0ba | 277 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 278 | static void verify1(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 279 | Callback<T(T)> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 280 | T result = func((1 << 0)); |
marcozecchini | 0:9fca2b23d0ba | 281 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); |
marcozecchini | 0:9fca2b23d0ba | 282 | } |
marcozecchini | 0:9fca2b23d0ba | 283 | |
marcozecchini | 0:9fca2b23d0ba | 284 | static void verify2(Callback<T(T, T)> func) { |
marcozecchini | 0:9fca2b23d0ba | 285 | T result = func((1 << 0), (1 << 1)); |
marcozecchini | 0:9fca2b23d0ba | 286 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); |
marcozecchini | 0:9fca2b23d0ba | 287 | } |
marcozecchini | 0:9fca2b23d0ba | 288 | |
marcozecchini | 0:9fca2b23d0ba | 289 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 290 | static void verify2(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 291 | Callback<T(T, T)> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 292 | T result = func((1 << 0), (1 << 1)); |
marcozecchini | 0:9fca2b23d0ba | 293 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); |
marcozecchini | 0:9fca2b23d0ba | 294 | } |
marcozecchini | 0:9fca2b23d0ba | 295 | |
marcozecchini | 0:9fca2b23d0ba | 296 | static void verify3(Callback<T(T, T, T)> func) { |
marcozecchini | 0:9fca2b23d0ba | 297 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
marcozecchini | 0:9fca2b23d0ba | 298 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); |
marcozecchini | 0:9fca2b23d0ba | 299 | } |
marcozecchini | 0:9fca2b23d0ba | 300 | |
marcozecchini | 0:9fca2b23d0ba | 301 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 302 | static void verify3(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 303 | Callback<T(T, T, T)> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 304 | T result = func((1 << 0), (1 << 1), (1 << 2)); |
marcozecchini | 0:9fca2b23d0ba | 305 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); |
marcozecchini | 0:9fca2b23d0ba | 306 | } |
marcozecchini | 0:9fca2b23d0ba | 307 | |
marcozecchini | 0:9fca2b23d0ba | 308 | static void verify4(Callback<T(T, T, T, T)> func) { |
marcozecchini | 0:9fca2b23d0ba | 309 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
marcozecchini | 0:9fca2b23d0ba | 310 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
marcozecchini | 0:9fca2b23d0ba | 311 | } |
marcozecchini | 0:9fca2b23d0ba | 312 | |
marcozecchini | 0:9fca2b23d0ba | 313 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 314 | static void verify4(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 315 | Callback<T(T, T, T, T)> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 316 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); |
marcozecchini | 0:9fca2b23d0ba | 317 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); |
marcozecchini | 0:9fca2b23d0ba | 318 | } |
marcozecchini | 0:9fca2b23d0ba | 319 | |
marcozecchini | 0:9fca2b23d0ba | 320 | static void verify5(Callback<T(T, T, T, T, T)> func) { |
marcozecchini | 0:9fca2b23d0ba | 321 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
marcozecchini | 0:9fca2b23d0ba | 322 | TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
marcozecchini | 0:9fca2b23d0ba | 323 | } |
marcozecchini | 0:9fca2b23d0ba | 324 | |
marcozecchini | 0:9fca2b23d0ba | 325 | template <typename O, typename M> |
marcozecchini | 0:9fca2b23d0ba | 326 | static void verify5(O *obj, M method) { |
marcozecchini | 0:9fca2b23d0ba | 327 | Callback<T(T, T, T, T, T)> func(obj, method); |
marcozecchini | 0:9fca2b23d0ba | 328 | T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); |
marcozecchini | 0:9fca2b23d0ba | 329 | TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); |
marcozecchini | 0:9fca2b23d0ba | 330 | } |
marcozecchini | 0:9fca2b23d0ba | 331 | }; |
marcozecchini | 0:9fca2b23d0ba | 332 | |
marcozecchini | 0:9fca2b23d0ba | 333 | |
marcozecchini | 0:9fca2b23d0ba | 334 | // test dispatch |
marcozecchini | 0:9fca2b23d0ba | 335 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 336 | void test_dispatch0() { |
marcozecchini | 0:9fca2b23d0ba | 337 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 338 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 339 | Verifier<T>::verify0(static_func0<T>); |
marcozecchini | 0:9fca2b23d0ba | 340 | Verifier<T>::verify0(&thing, &Thing<T>::member_func0); |
marcozecchini | 0:9fca2b23d0ba | 341 | Verifier<T>::verify0((const Thing<T>*)&thing, &Thing<T>::const_member_func0); |
marcozecchini | 0:9fca2b23d0ba | 342 | Verifier<T>::verify0((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func0); |
marcozecchini | 0:9fca2b23d0ba | 343 | Verifier<T>::verify0((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func0); |
marcozecchini | 0:9fca2b23d0ba | 344 | Verifier<T>::verify0(&thing2, &Thing2<T>::member_func0); |
marcozecchini | 0:9fca2b23d0ba | 345 | Verifier<T>::verify0(&bound_func0<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 346 | Verifier<T>::verify0(&const_bound_func0<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 347 | Verifier<T>::verify0(&volatile_bound_func0<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 348 | Verifier<T>::verify0(&const_volatile_bound_func0<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 349 | Verifier<T>::verify0(&bound_func0<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 350 | Verifier<T>::verify0(&void_func0<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 351 | Verifier<T>::verify0(&const_void_func0<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 352 | Verifier<T>::verify0(&volatile_void_func0<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 353 | Verifier<T>::verify0(&const_volatile_void_func0<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 354 | Verifier<T>::verify0(callback(static_func0<T>)); |
marcozecchini | 0:9fca2b23d0ba | 355 | |
marcozecchini | 0:9fca2b23d0ba | 356 | Callback<T()> cb(static_func0); |
marcozecchini | 0:9fca2b23d0ba | 357 | Verifier<T>::verify0(cb); |
marcozecchini | 0:9fca2b23d0ba | 358 | cb = static_func0; |
marcozecchini | 0:9fca2b23d0ba | 359 | Verifier<T>::verify0(cb); |
marcozecchini | 0:9fca2b23d0ba | 360 | cb.attach(&bound_func0<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 361 | Verifier<T>::verify0(&cb, &Callback<T()>::call); |
marcozecchini | 0:9fca2b23d0ba | 362 | Verifier<T>::verify0(&Callback<T()>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 363 | } |
marcozecchini | 0:9fca2b23d0ba | 364 | |
marcozecchini | 0:9fca2b23d0ba | 365 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 366 | void test_dispatch1() { |
marcozecchini | 0:9fca2b23d0ba | 367 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 368 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 369 | Verifier<T>::verify1(static_func1<T>); |
marcozecchini | 0:9fca2b23d0ba | 370 | Verifier<T>::verify1(&thing, &Thing<T>::member_func1); |
marcozecchini | 0:9fca2b23d0ba | 371 | Verifier<T>::verify1((const Thing<T>*)&thing, &Thing<T>::const_member_func1); |
marcozecchini | 0:9fca2b23d0ba | 372 | Verifier<T>::verify1((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func1); |
marcozecchini | 0:9fca2b23d0ba | 373 | Verifier<T>::verify1((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func1); |
marcozecchini | 0:9fca2b23d0ba | 374 | Verifier<T>::verify1(&thing2, &Thing2<T>::member_func1); |
marcozecchini | 0:9fca2b23d0ba | 375 | Verifier<T>::verify1(&bound_func1<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 376 | Verifier<T>::verify1(&const_bound_func1<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 377 | Verifier<T>::verify1(&volatile_bound_func1<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 378 | Verifier<T>::verify1(&const_volatile_bound_func1<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 379 | Verifier<T>::verify1(&bound_func1<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 380 | Verifier<T>::verify1(&void_func1<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 381 | Verifier<T>::verify1(&const_void_func1<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 382 | Verifier<T>::verify1(&volatile_void_func1<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 383 | Verifier<T>::verify1(&const_volatile_void_func1<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 384 | Verifier<T>::verify1(callback(static_func1<T>)); |
marcozecchini | 0:9fca2b23d0ba | 385 | |
marcozecchini | 0:9fca2b23d0ba | 386 | Callback<T(T)> cb(static_func1); |
marcozecchini | 0:9fca2b23d0ba | 387 | Verifier<T>::verify1(cb); |
marcozecchini | 0:9fca2b23d0ba | 388 | cb = static_func1; |
marcozecchini | 0:9fca2b23d0ba | 389 | Verifier<T>::verify1(cb); |
marcozecchini | 0:9fca2b23d0ba | 390 | cb.attach(&bound_func1<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 391 | Verifier<T>::verify1(&cb, &Callback<T(T)>::call); |
marcozecchini | 0:9fca2b23d0ba | 392 | Verifier<T>::verify1(&Callback<T(T)>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 393 | } |
marcozecchini | 0:9fca2b23d0ba | 394 | |
marcozecchini | 0:9fca2b23d0ba | 395 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 396 | void test_dispatch2() { |
marcozecchini | 0:9fca2b23d0ba | 397 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 398 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 399 | Verifier<T>::verify2(static_func2<T>); |
marcozecchini | 0:9fca2b23d0ba | 400 | Verifier<T>::verify2(&thing, &Thing<T>::member_func2); |
marcozecchini | 0:9fca2b23d0ba | 401 | Verifier<T>::verify2((const Thing<T>*)&thing, &Thing<T>::const_member_func2); |
marcozecchini | 0:9fca2b23d0ba | 402 | Verifier<T>::verify2((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func2); |
marcozecchini | 0:9fca2b23d0ba | 403 | Verifier<T>::verify2((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func2); |
marcozecchini | 0:9fca2b23d0ba | 404 | Verifier<T>::verify2(&thing2, &Thing2<T>::member_func2); |
marcozecchini | 0:9fca2b23d0ba | 405 | Verifier<T>::verify2(&bound_func2<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 406 | Verifier<T>::verify2(&const_bound_func2<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 407 | Verifier<T>::verify2(&volatile_bound_func2<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 408 | Verifier<T>::verify2(&const_volatile_bound_func2<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 409 | Verifier<T>::verify2(&bound_func2<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 410 | Verifier<T>::verify2(&void_func2<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 411 | Verifier<T>::verify2(&const_void_func2<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 412 | Verifier<T>::verify2(&volatile_void_func2<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 413 | Verifier<T>::verify2(&const_volatile_void_func2<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 414 | Verifier<T>::verify2(callback(static_func2<T>)); |
marcozecchini | 0:9fca2b23d0ba | 415 | |
marcozecchini | 0:9fca2b23d0ba | 416 | Callback<T(T, T)> cb(static_func2); |
marcozecchini | 0:9fca2b23d0ba | 417 | Verifier<T>::verify2(cb); |
marcozecchini | 0:9fca2b23d0ba | 418 | cb = static_func2; |
marcozecchini | 0:9fca2b23d0ba | 419 | Verifier<T>::verify2(cb); |
marcozecchini | 0:9fca2b23d0ba | 420 | cb.attach(&bound_func2<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 421 | Verifier<T>::verify2(&cb, &Callback<T(T, T)>::call); |
marcozecchini | 0:9fca2b23d0ba | 422 | Verifier<T>::verify2(&Callback<T(T, T)>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 423 | } |
marcozecchini | 0:9fca2b23d0ba | 424 | |
marcozecchini | 0:9fca2b23d0ba | 425 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 426 | void test_dispatch3() { |
marcozecchini | 0:9fca2b23d0ba | 427 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 428 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 429 | Verifier<T>::verify3(static_func3<T>); |
marcozecchini | 0:9fca2b23d0ba | 430 | Verifier<T>::verify3(&thing, &Thing<T>::member_func3); |
marcozecchini | 0:9fca2b23d0ba | 431 | Verifier<T>::verify3((const Thing<T>*)&thing, &Thing<T>::const_member_func3); |
marcozecchini | 0:9fca2b23d0ba | 432 | Verifier<T>::verify3((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func3); |
marcozecchini | 0:9fca2b23d0ba | 433 | Verifier<T>::verify3((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func3); |
marcozecchini | 0:9fca2b23d0ba | 434 | Verifier<T>::verify3(&thing2, &Thing2<T>::member_func3); |
marcozecchini | 0:9fca2b23d0ba | 435 | Verifier<T>::verify3(&bound_func3<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 436 | Verifier<T>::verify3(&const_bound_func3<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 437 | Verifier<T>::verify3(&volatile_bound_func3<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 438 | Verifier<T>::verify3(&const_volatile_bound_func3<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 439 | Verifier<T>::verify3(&bound_func3<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 440 | Verifier<T>::verify3(&void_func3<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 441 | Verifier<T>::verify3(&const_void_func3<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 442 | Verifier<T>::verify3(&volatile_void_func3<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 443 | Verifier<T>::verify3(&const_volatile_void_func3<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 444 | Verifier<T>::verify3(callback(static_func3<T>)); |
marcozecchini | 0:9fca2b23d0ba | 445 | |
marcozecchini | 0:9fca2b23d0ba | 446 | Callback<T(T, T, T)> cb(static_func3); |
marcozecchini | 0:9fca2b23d0ba | 447 | Verifier<T>::verify3(cb); |
marcozecchini | 0:9fca2b23d0ba | 448 | cb = static_func3; |
marcozecchini | 0:9fca2b23d0ba | 449 | Verifier<T>::verify3(cb); |
marcozecchini | 0:9fca2b23d0ba | 450 | cb.attach(&bound_func3<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 451 | Verifier<T>::verify3(&cb, &Callback<T(T, T, T)>::call); |
marcozecchini | 0:9fca2b23d0ba | 452 | Verifier<T>::verify3(&Callback<T(T, T, T)>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 453 | } |
marcozecchini | 0:9fca2b23d0ba | 454 | |
marcozecchini | 0:9fca2b23d0ba | 455 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 456 | void test_dispatch4() { |
marcozecchini | 0:9fca2b23d0ba | 457 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 458 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 459 | Verifier<T>::verify4(static_func4<T>); |
marcozecchini | 0:9fca2b23d0ba | 460 | Verifier<T>::verify4(&thing, &Thing<T>::member_func4); |
marcozecchini | 0:9fca2b23d0ba | 461 | Verifier<T>::verify4((const Thing<T>*)&thing, &Thing<T>::const_member_func4); |
marcozecchini | 0:9fca2b23d0ba | 462 | Verifier<T>::verify4((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func4); |
marcozecchini | 0:9fca2b23d0ba | 463 | Verifier<T>::verify4((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func4); |
marcozecchini | 0:9fca2b23d0ba | 464 | Verifier<T>::verify4(&thing2, &Thing2<T>::member_func4); |
marcozecchini | 0:9fca2b23d0ba | 465 | Verifier<T>::verify4(&bound_func4<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 466 | Verifier<T>::verify4(&const_bound_func4<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 467 | Verifier<T>::verify4(&volatile_bound_func4<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 468 | Verifier<T>::verify4(&const_volatile_bound_func4<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 469 | Verifier<T>::verify4(&bound_func4<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 470 | Verifier<T>::verify4(&void_func4<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 471 | Verifier<T>::verify4(&const_void_func4<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 472 | Verifier<T>::verify4(&volatile_void_func4<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 473 | Verifier<T>::verify4(&const_volatile_void_func4<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 474 | Verifier<T>::verify4(callback(static_func4<T>)); |
marcozecchini | 0:9fca2b23d0ba | 475 | |
marcozecchini | 0:9fca2b23d0ba | 476 | Callback<T(T, T, T, T)> cb(static_func4); |
marcozecchini | 0:9fca2b23d0ba | 477 | Verifier<T>::verify4(cb); |
marcozecchini | 0:9fca2b23d0ba | 478 | cb = static_func4; |
marcozecchini | 0:9fca2b23d0ba | 479 | Verifier<T>::verify4(cb); |
marcozecchini | 0:9fca2b23d0ba | 480 | cb.attach(&bound_func4<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 481 | Verifier<T>::verify4(&cb, &Callback<T(T, T, T, T)>::call); |
marcozecchini | 0:9fca2b23d0ba | 482 | Verifier<T>::verify4(&Callback<T(T, T, T, T)>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 483 | } |
marcozecchini | 0:9fca2b23d0ba | 484 | |
marcozecchini | 0:9fca2b23d0ba | 485 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 486 | void test_dispatch5() { |
marcozecchini | 0:9fca2b23d0ba | 487 | Thing<T> thing; |
marcozecchini | 0:9fca2b23d0ba | 488 | Thing2<T> thing2; |
marcozecchini | 0:9fca2b23d0ba | 489 | Verifier<T>::verify5(static_func5<T>); |
marcozecchini | 0:9fca2b23d0ba | 490 | Verifier<T>::verify5(&thing, &Thing<T>::member_func5); |
marcozecchini | 0:9fca2b23d0ba | 491 | Verifier<T>::verify5((const Thing<T>*)&thing, &Thing<T>::const_member_func5); |
marcozecchini | 0:9fca2b23d0ba | 492 | Verifier<T>::verify5((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func5); |
marcozecchini | 0:9fca2b23d0ba | 493 | Verifier<T>::verify5((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func5); |
marcozecchini | 0:9fca2b23d0ba | 494 | Verifier<T>::verify5(&thing2, &Thing2<T>::member_func5); |
marcozecchini | 0:9fca2b23d0ba | 495 | Verifier<T>::verify5(&bound_func5<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 496 | Verifier<T>::verify5(&const_bound_func5<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 497 | Verifier<T>::verify5(&volatile_bound_func5<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 498 | Verifier<T>::verify5(&const_volatile_bound_func5<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 499 | Verifier<T>::verify5(&bound_func5<T>, &thing2); |
marcozecchini | 0:9fca2b23d0ba | 500 | Verifier<T>::verify5(&void_func5<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 501 | Verifier<T>::verify5(&const_void_func5<T>, (const Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 502 | Verifier<T>::verify5(&volatile_void_func5<T>, (volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 503 | Verifier<T>::verify5(&const_volatile_void_func5<T>, (const volatile Thing<T>*)&thing); |
marcozecchini | 0:9fca2b23d0ba | 504 | Verifier<T>::verify5(callback(static_func5<T>)); |
marcozecchini | 0:9fca2b23d0ba | 505 | |
marcozecchini | 0:9fca2b23d0ba | 506 | Callback<T(T, T, T, T, T)> cb(static_func5); |
marcozecchini | 0:9fca2b23d0ba | 507 | Verifier<T>::verify5(cb); |
marcozecchini | 0:9fca2b23d0ba | 508 | cb = static_func5; |
marcozecchini | 0:9fca2b23d0ba | 509 | Verifier<T>::verify5(cb); |
marcozecchini | 0:9fca2b23d0ba | 510 | cb.attach(&bound_func5<T>, &thing); |
marcozecchini | 0:9fca2b23d0ba | 511 | Verifier<T>::verify5(&cb, &Callback<T(T, T, T, T, T)>::call); |
marcozecchini | 0:9fca2b23d0ba | 512 | Verifier<T>::verify5(&Callback<T(T, T, T, T, T)>::thunk, (void*)&cb); |
marcozecchini | 0:9fca2b23d0ba | 513 | } |
marcozecchini | 0:9fca2b23d0ba | 514 | |
marcozecchini | 0:9fca2b23d0ba | 515 | |
marcozecchini | 0:9fca2b23d0ba | 516 | // Test setup |
marcozecchini | 0:9fca2b23d0ba | 517 | utest::v1::status_t test_setup(const size_t number_of_cases) { |
marcozecchini | 0:9fca2b23d0ba | 518 | GREENTEA_SETUP(10, "default_auto"); |
marcozecchini | 0:9fca2b23d0ba | 519 | return verbose_test_setup_handler(number_of_cases); |
marcozecchini | 0:9fca2b23d0ba | 520 | } |
marcozecchini | 0:9fca2b23d0ba | 521 | |
marcozecchini | 0:9fca2b23d0ba | 522 | Case cases[] = { |
marcozecchini | 0:9fca2b23d0ba | 523 | Case("Testing callbacks with 0 ints", test_dispatch0<int>), |
marcozecchini | 0:9fca2b23d0ba | 524 | Case("Testing callbacks with 1 ints", test_dispatch1<int>), |
marcozecchini | 0:9fca2b23d0ba | 525 | Case("Testing callbacks with 2 ints", test_dispatch2<int>), |
marcozecchini | 0:9fca2b23d0ba | 526 | Case("Testing callbacks with 3 ints", test_dispatch3<int>), |
marcozecchini | 0:9fca2b23d0ba | 527 | Case("Testing callbacks with 4 ints", test_dispatch4<int>), |
marcozecchini | 0:9fca2b23d0ba | 528 | Case("Testing callbacks with 5 ints", test_dispatch5<int>), |
marcozecchini | 0:9fca2b23d0ba | 529 | }; |
marcozecchini | 0:9fca2b23d0ba | 530 | |
marcozecchini | 0:9fca2b23d0ba | 531 | Specification specification(test_setup, cases); |
marcozecchini | 0:9fca2b23d0ba | 532 | |
marcozecchini | 0:9fca2b23d0ba | 533 | int main() { |
marcozecchini | 0:9fca2b23d0ba | 534 | return !Harness::run(specification); |
marcozecchini | 0:9fca2b23d0ba | 535 | } |