Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Nov 11 20:59:50 2016 +0000
Revision:
0:5c4d7b2438d3
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 #include <stdio.h>
switches 0:5c4d7b2438d3 2 #include <stdint.h>
switches 0:5c4d7b2438d3 3
switches 0:5c4d7b2438d3 4 #include "toolchain.h"
switches 0:5c4d7b2438d3 5 #include "greentea-client/test_env.h"
switches 0:5c4d7b2438d3 6 #include "unity.h"
switches 0:5c4d7b2438d3 7 #include "utest.h"
switches 0:5c4d7b2438d3 8
switches 0:5c4d7b2438d3 9 using namespace utest::v1;
switches 0:5c4d7b2438d3 10
switches 0:5c4d7b2438d3 11
switches 0:5c4d7b2438d3 12 // Test functions declared as C functions to avoid issues with name mangling
switches 0:5c4d7b2438d3 13 extern "C" {
switches 0:5c4d7b2438d3 14 int testPacked();
switches 0:5c4d7b2438d3 15 int testAlign();
switches 0:5c4d7b2438d3 16 int testUnused();
switches 0:5c4d7b2438d3 17 int testWeak();
switches 0:5c4d7b2438d3 18 int testPure();
switches 0:5c4d7b2438d3 19 int testForceInline();
switches 0:5c4d7b2438d3 20 int testNoReturn();
switches 0:5c4d7b2438d3 21 int testUnreachable();
switches 0:5c4d7b2438d3 22 int testDeprecated();
switches 0:5c4d7b2438d3 23 }
switches 0:5c4d7b2438d3 24
switches 0:5c4d7b2438d3 25
switches 0:5c4d7b2438d3 26 // Test wrapper and test cases for utest
switches 0:5c4d7b2438d3 27 template <int (*F)()>
switches 0:5c4d7b2438d3 28 void test_wrapper() {
switches 0:5c4d7b2438d3 29 TEST_ASSERT_UNLESS(F());
switches 0:5c4d7b2438d3 30 }
switches 0:5c4d7b2438d3 31
switches 0:5c4d7b2438d3 32 utest::v1::status_t test_setup(const size_t number_of_cases) {
switches 0:5c4d7b2438d3 33 GREENTEA_SETUP(5, "default_auto");
switches 0:5c4d7b2438d3 34 return verbose_test_setup_handler(number_of_cases);
switches 0:5c4d7b2438d3 35 }
switches 0:5c4d7b2438d3 36
switches 0:5c4d7b2438d3 37 Case cases[] = {
switches 0:5c4d7b2438d3 38 Case("Testing PACKED attribute", test_wrapper<testPacked>),
switches 0:5c4d7b2438d3 39 Case("Testing ALIGN attribute", test_wrapper<testAlign>),
switches 0:5c4d7b2438d3 40 Case("Testing UNUSED attribute", test_wrapper<testUnused>),
switches 0:5c4d7b2438d3 41 Case("Testing WEAK attribute", test_wrapper<testWeak>),
switches 0:5c4d7b2438d3 42 Case("Testing PURE attribute", test_wrapper<testPure>),
switches 0:5c4d7b2438d3 43 Case("Testing FORCEINLINE attribute", test_wrapper<testForceInline>),
switches 0:5c4d7b2438d3 44 Case("Testing NORETURN attribute", test_wrapper<testNoReturn>),
switches 0:5c4d7b2438d3 45 Case("Testing UNREACHABLE attribute", test_wrapper<testUnreachable>),
switches 0:5c4d7b2438d3 46 Case("Testing DEPRECATED attribute", test_wrapper<testDeprecated>),
switches 0:5c4d7b2438d3 47 };
switches 0:5c4d7b2438d3 48
switches 0:5c4d7b2438d3 49 Specification specification(test_setup, cases);
switches 0:5c4d7b2438d3 50
switches 0:5c4d7b2438d3 51 int main() {
switches 0:5c4d7b2438d3 52 return !Harness::run(specification);
switches 0:5c4d7b2438d3 53 }