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_fparg1() {
switches 0:5c4d7b2438d3 317 Thing<T> thing;
switches 0:5c4d7b2438d3 318 FunctionPointerArg1<T,T> fp(static_func1<T>);
switches 0:5c4d7b2438d3 319 Verifier<T>::verify1(fp);
switches 0:5c4d7b2438d3 320 Verifier<T>::verify1(fp.get_function());
switches 0:5c4d7b2438d3 321 }
switches 0:5c4d7b2438d3 322
switches 0:5c4d7b2438d3 323 template <typename T>
switches 0:5c4d7b2438d3 324 void test_fparg0() {
switches 0:5c4d7b2438d3 325 Thing<T> thing;
switches 0:5c4d7b2438d3 326 FunctionPointerArg1<T,void> fp(static_func0<T>);
switches 0:5c4d7b2438d3 327 Verifier<T>::verify0(fp);
switches 0:5c4d7b2438d3 328 Verifier<T>::verify0(fp.get_function());
switches 0:5c4d7b2438d3 329 }
switches 0:5c4d7b2438d3 330
switches 0:5c4d7b2438d3 331
switches 0:5c4d7b2438d3 332 // Test setup
switches 0:5c4d7b2438d3 333 utest::v1::status_t test_setup(const size_t number_of_cases) {
switches 0:5c4d7b2438d3 334 GREENTEA_SETUP(10, "default_auto");
switches 0:5c4d7b2438d3 335 return verbose_test_setup_handler(number_of_cases);
switches 0:5c4d7b2438d3 336 }
switches 0:5c4d7b2438d3 337
switches 0:5c4d7b2438d3 338 Case cases[] = {
switches 0:5c4d7b2438d3 339 Case("Testing FunctionPointerArg1 compatibility", test_fparg1<int>),
switches 0:5c4d7b2438d3 340 Case("Testing FunctionPointer compatibility", test_fparg0<int>),
switches 0:5c4d7b2438d3 341 };
switches 0:5c4d7b2438d3 342
switches 0:5c4d7b2438d3 343 Specification specification(test_setup, cases);
switches 0:5c4d7b2438d3 344
switches 0:5c4d7b2438d3 345 int main() {
switches 0:5c4d7b2438d3 346 return !Harness::run(specification);
switches 0:5c4d7b2438d3 347 }