This is an example of BLE GATT Client, which receives broadcast data from BLE_Server_BME280 ( a GATT server) , then transfers values up to mbed Device Connector (cloud).
Please refer details about BLEClient_mbedDevConn below. https://github.com/soramame21/BLEClient_mbedDevConn
The location of required BLE GATT server, BLE_Server_BME280, is at here. https://developer.mbed.org/users/edamame22/code/BLE_Server_BME280/
pal/Test/Unity/test/tests/testparameterized.c@2:b894b3508057, 2017-09-05 (annotated)
- Committer:
- Ren Boting
- Date:
- Tue Sep 05 11:56:13 2017 +0900
- Revision:
- 2:b894b3508057
- Parent:
- 0:29983394c6b6
Update all libraries and reform main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edamame22 | 0:29983394c6b6 | 1 | /* ========================================== |
edamame22 | 0:29983394c6b6 | 2 | Unity Project - A Test Framework for C |
edamame22 | 0:29983394c6b6 | 3 | Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams |
edamame22 | 0:29983394c6b6 | 4 | [Released under MIT License. Please refer to license.txt for details] |
edamame22 | 0:29983394c6b6 | 5 | ========================================== */ |
edamame22 | 0:29983394c6b6 | 6 | |
edamame22 | 0:29983394c6b6 | 7 | #include <setjmp.h> |
edamame22 | 0:29983394c6b6 | 8 | #include <stdio.h> |
edamame22 | 0:29983394c6b6 | 9 | #include "unity.h" |
edamame22 | 0:29983394c6b6 | 10 | |
edamame22 | 0:29983394c6b6 | 11 | void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests |
edamame22 | 0:29983394c6b6 | 12 | |
edamame22 | 0:29983394c6b6 | 13 | #define TEST_CASE(...) |
edamame22 | 0:29983394c6b6 | 14 | |
edamame22 | 0:29983394c6b6 | 15 | #define EXPECT_ABORT_BEGIN \ |
edamame22 | 0:29983394c6b6 | 16 | if (TEST_PROTECT()) \ |
edamame22 | 0:29983394c6b6 | 17 | { |
edamame22 | 0:29983394c6b6 | 18 | |
edamame22 | 0:29983394c6b6 | 19 | #define VERIFY_FAILS_END \ |
edamame22 | 0:29983394c6b6 | 20 | } \ |
edamame22 | 0:29983394c6b6 | 21 | Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \ |
edamame22 | 0:29983394c6b6 | 22 | if (Unity.CurrentTestFailed == 1) { \ |
edamame22 | 0:29983394c6b6 | 23 | SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ |
edamame22 | 0:29983394c6b6 | 24 | UnityPrint("[[[[ Previous Test Should Have Failed But Did Not ]]]]"); \ |
edamame22 | 0:29983394c6b6 | 25 | UNITY_OUTPUT_CHAR('\n'); \ |
edamame22 | 0:29983394c6b6 | 26 | } |
edamame22 | 0:29983394c6b6 | 27 | |
edamame22 | 0:29983394c6b6 | 28 | #define VERIFY_IGNORES_END \ |
edamame22 | 0:29983394c6b6 | 29 | } \ |
edamame22 | 0:29983394c6b6 | 30 | Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \ |
edamame22 | 0:29983394c6b6 | 31 | Unity.CurrentTestIgnored = 0; \ |
edamame22 | 0:29983394c6b6 | 32 | if (Unity.CurrentTestFailed == 1) { \ |
edamame22 | 0:29983394c6b6 | 33 | SetToOneMeanWeAlreadyCheckedThisGuy = 1; \ |
edamame22 | 0:29983394c6b6 | 34 | UnityPrint("[[[[ Previous Test Should Have Ignored But Did Not ]]]]"); \ |
edamame22 | 0:29983394c6b6 | 35 | UNITY_OUTPUT_CHAR('\n'); \ |
edamame22 | 0:29983394c6b6 | 36 | } |
edamame22 | 0:29983394c6b6 | 37 | |
edamame22 | 0:29983394c6b6 | 38 | int SetToOneToFailInTearDown; |
edamame22 | 0:29983394c6b6 | 39 | int SetToOneMeanWeAlreadyCheckedThisGuy; |
edamame22 | 0:29983394c6b6 | 40 | |
edamame22 | 0:29983394c6b6 | 41 | void setUp(void) |
edamame22 | 0:29983394c6b6 | 42 | { |
edamame22 | 0:29983394c6b6 | 43 | SetToOneToFailInTearDown = 0; |
edamame22 | 0:29983394c6b6 | 44 | SetToOneMeanWeAlreadyCheckedThisGuy = 0; |
edamame22 | 0:29983394c6b6 | 45 | } |
edamame22 | 0:29983394c6b6 | 46 | |
edamame22 | 0:29983394c6b6 | 47 | void tearDown(void) |
edamame22 | 0:29983394c6b6 | 48 | { |
edamame22 | 0:29983394c6b6 | 49 | if (SetToOneToFailInTearDown == 1) |
edamame22 | 0:29983394c6b6 | 50 | TEST_FAIL_MESSAGE("<= Failed in tearDown"); |
edamame22 | 0:29983394c6b6 | 51 | if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0)) |
edamame22 | 0:29983394c6b6 | 52 | { |
edamame22 | 0:29983394c6b6 | 53 | UnityPrint("[[[[ Previous Test Should Have Passed But Did Not ]]]]"); |
edamame22 | 0:29983394c6b6 | 54 | UNITY_OUTPUT_CHAR('\n'); |
edamame22 | 0:29983394c6b6 | 55 | } |
edamame22 | 0:29983394c6b6 | 56 | } |
edamame22 | 0:29983394c6b6 | 57 | |
edamame22 | 0:29983394c6b6 | 58 | TEST_CASE(0) |
edamame22 | 0:29983394c6b6 | 59 | TEST_CASE(44) |
edamame22 | 0:29983394c6b6 | 60 | TEST_CASE((90)+9) |
edamame22 | 0:29983394c6b6 | 61 | void test_TheseShouldAllPass(int Num) |
edamame22 | 0:29983394c6b6 | 62 | { |
edamame22 | 0:29983394c6b6 | 63 | TEST_ASSERT_TRUE(Num < 100); |
edamame22 | 0:29983394c6b6 | 64 | } |
edamame22 | 0:29983394c6b6 | 65 | |
edamame22 | 0:29983394c6b6 | 66 | TEST_CASE(3) |
edamame22 | 0:29983394c6b6 | 67 | TEST_CASE(77) |
edamame22 | 0:29983394c6b6 | 68 | TEST_CASE( (99) + 1 - (1)) |
edamame22 | 0:29983394c6b6 | 69 | void test_TheseShouldAllFail(int Num) |
edamame22 | 0:29983394c6b6 | 70 | { |
edamame22 | 0:29983394c6b6 | 71 | EXPECT_ABORT_BEGIN |
edamame22 | 0:29983394c6b6 | 72 | TEST_ASSERT_TRUE(Num > 100); |
edamame22 | 0:29983394c6b6 | 73 | VERIFY_FAILS_END |
edamame22 | 0:29983394c6b6 | 74 | } |
edamame22 | 0:29983394c6b6 | 75 | |
edamame22 | 0:29983394c6b6 | 76 | TEST_CASE(1) |
edamame22 | 0:29983394c6b6 | 77 | TEST_CASE(44) |
edamame22 | 0:29983394c6b6 | 78 | TEST_CASE(99) |
edamame22 | 0:29983394c6b6 | 79 | TEST_CASE(98) |
edamame22 | 0:29983394c6b6 | 80 | void test_TheseAreEveryOther(int Num) |
edamame22 | 0:29983394c6b6 | 81 | { |
edamame22 | 0:29983394c6b6 | 82 | if (Num & 1) |
edamame22 | 0:29983394c6b6 | 83 | { |
edamame22 | 0:29983394c6b6 | 84 | EXPECT_ABORT_BEGIN |
edamame22 | 0:29983394c6b6 | 85 | TEST_ASSERT_TRUE(Num > 100); |
edamame22 | 0:29983394c6b6 | 86 | VERIFY_FAILS_END |
edamame22 | 0:29983394c6b6 | 87 | } |
edamame22 | 0:29983394c6b6 | 88 | else |
edamame22 | 0:29983394c6b6 | 89 | { |
edamame22 | 0:29983394c6b6 | 90 | TEST_ASSERT_TRUE(Num < 100); |
edamame22 | 0:29983394c6b6 | 91 | } |
edamame22 | 0:29983394c6b6 | 92 | } |
edamame22 | 0:29983394c6b6 | 93 | |
edamame22 | 0:29983394c6b6 | 94 | void test_NormalPassesStillWork(void) |
edamame22 | 0:29983394c6b6 | 95 | { |
edamame22 | 0:29983394c6b6 | 96 | TEST_ASSERT_TRUE(1); |
edamame22 | 0:29983394c6b6 | 97 | } |
edamame22 | 0:29983394c6b6 | 98 | |
edamame22 | 0:29983394c6b6 | 99 | void test_NormalFailsStillWork(void) |
edamame22 | 0:29983394c6b6 | 100 | { |
edamame22 | 0:29983394c6b6 | 101 | EXPECT_ABORT_BEGIN |
edamame22 | 0:29983394c6b6 | 102 | TEST_ASSERT_TRUE(0); |
edamame22 | 0:29983394c6b6 | 103 | VERIFY_FAILS_END |
edamame22 | 0:29983394c6b6 | 104 | } |