Greg Steiert / pegasus_dev

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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