mbed os with nrf51 internal bandgap enabled to read battery level
Dependents: BLE_file_test BLE_Blink ExternalEncoder
features/frameworks/unity/README.md@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | # UNITY: Unit Testing for C |
elessair | 0:f269e3021894 | 2 | |
elessair | 0:f269e3021894 | 3 | This yotta module is a fork of the [UNITY test framework](http://www.throwtheswitch.org/unity/) with minor modifications to be able to use it with the [utest harness](https://github.com/ARMmbed/utest) for mbed OS. |
elessair | 0:f269e3021894 | 4 | |
elessair | 0:f269e3021894 | 5 | Please note that this module only contains the unity test macros, and no additions such as the unity fixtures. |
elessair | 0:f269e3021894 | 6 | Furthermore the failure macros have been modified to integrate with `utest` failure handlers, as `setjmp` and `longjmp` are not supported by `utest`. |
elessair | 0:f269e3021894 | 7 | |
elessair | 0:f269e3021894 | 8 | Specifically |
elessair | 0:f269e3021894 | 9 | - `UNITY_FAIL_AND_BAIL` calls `utest_unity_assert_failure()`, and |
elessair | 0:f269e3021894 | 10 | - `UNITY_IGNORE_AND_BAIL` calls `utest_unity_ignore_failure()` |
elessair | 0:f269e3021894 | 11 | |
elessair | 0:f269e3021894 | 12 | which then invoke the appropriate action in `utest`. |
elessair | 0:f269e3021894 | 13 | |
elessair | 0:f269e3021894 | 14 | **To use these macros you need to depend on both `unity` and `utest`!** |
elessair | 0:f269e3021894 | 15 | |
elessair | 0:f269e3021894 | 16 | For the original documentation of UNITY, please [visit the project's homepage](http://www.throwtheswitch.org/unity/). |
elessair | 0:f269e3021894 | 17 | |
elessair | 0:f269e3021894 | 18 | ## Macros |
elessair | 0:f269e3021894 | 19 | |
elessair | 0:f269e3021894 | 20 | UNITY provides a lot of test macros. |
elessair | 0:f269e3021894 | 21 | |
elessair | 0:f269e3021894 | 22 | **Be aware of the macro argument order**: (EXPECTED VALUE, ACTUAL VALUE). |
elessair | 0:f269e3021894 | 23 | So `TEST_ASSERT_EQUAL(4, value);` is the right way around. |
elessair | 0:f269e3021894 | 24 | |
elessair | 0:f269e3021894 | 25 | Note, that you can provide a custom failure message by appending `_MESSAGE` to any macro and passing the message string as the _last argument_. |
elessair | 0:f269e3021894 | 26 | |
elessair | 0:f269e3021894 | 27 | #### Generic: |
elessair | 0:f269e3021894 | 28 | |
elessair | 0:f269e3021894 | 29 | - `TEST_FAIL()` |
elessair | 0:f269e3021894 | 30 | - `TEST_IGNORE()` |
elessair | 0:f269e3021894 | 31 | - `TEST_ONLY()` |
elessair | 0:f269e3021894 | 32 | |
elessair | 0:f269e3021894 | 33 | #### Boolean: |
elessair | 0:f269e3021894 | 34 | |
elessair | 0:f269e3021894 | 35 | - `TEST_ASSERT(condition)` |
elessair | 0:f269e3021894 | 36 | - `TEST_ASSERT_TRUE(condition)` |
elessair | 0:f269e3021894 | 37 | - `TEST_ASSERT_UNLESS(condition)` |
elessair | 0:f269e3021894 | 38 | - `TEST_ASSERT_FALSE(condition)` |
elessair | 0:f269e3021894 | 39 | |
elessair | 0:f269e3021894 | 40 | #### Pointer: |
elessair | 0:f269e3021894 | 41 | |
elessair | 0:f269e3021894 | 42 | - `TEST_ASSERT_NULL(pointer)` |
elessair | 0:f269e3021894 | 43 | - `TEST_ASSERT_NOT_NULL(pointer)` |
elessair | 0:f269e3021894 | 44 | |
elessair | 0:f269e3021894 | 45 | #### Equality: |
elessair | 0:f269e3021894 | 46 | |
elessair | 0:f269e3021894 | 47 | - `TEST_ASSERT_EQUAL(expected, actual)` |
elessair | 0:f269e3021894 | 48 | - `TEST_ASSERT_NOT_EQUAL(expected, actual)` |
elessair | 0:f269e3021894 | 49 | - `TEST_ASSERT_EQUAL_INT(expected, actual)` |
elessair | 0:f269e3021894 | 50 | - `TEST_ASSERT_EQUAL_INT8(expected, actual)` |
elessair | 0:f269e3021894 | 51 | - `TEST_ASSERT_EQUAL_INT16(expected, actual)` |
elessair | 0:f269e3021894 | 52 | - `TEST_ASSERT_EQUAL_INT32(expected, actual)` |
elessair | 0:f269e3021894 | 53 | - `TEST_ASSERT_EQUAL_INT64(expected, actual)` |
elessair | 0:f269e3021894 | 54 | - `TEST_ASSERT_EQUAL_UINT(expected, actual)` |
elessair | 0:f269e3021894 | 55 | - `TEST_ASSERT_EQUAL_UINT8(expected, actual)` |
elessair | 0:f269e3021894 | 56 | - `TEST_ASSERT_EQUAL_UINT16(expected, actual)` |
elessair | 0:f269e3021894 | 57 | - `TEST_ASSERT_EQUAL_UINT32(expected, actual)` |
elessair | 0:f269e3021894 | 58 | - `TEST_ASSERT_EQUAL_UINT64(expected, actual)` |
elessair | 0:f269e3021894 | 59 | - `TEST_ASSERT_EQUAL_HEX(expected, actual)` |
elessair | 0:f269e3021894 | 60 | - `TEST_ASSERT_EQUAL_HEX8(expected, actual)` |
elessair | 0:f269e3021894 | 61 | - `TEST_ASSERT_EQUAL_HEX16(expected, actual)` |
elessair | 0:f269e3021894 | 62 | - `TEST_ASSERT_EQUAL_HEX32(expected, actual)` |
elessair | 0:f269e3021894 | 63 | - `TEST_ASSERT_EQUAL_HEX64(expected, actual)` |
elessair | 0:f269e3021894 | 64 | |
elessair | 0:f269e3021894 | 65 | #### Bit Masks: |
elessair | 0:f269e3021894 | 66 | |
elessair | 0:f269e3021894 | 67 | - `TEST_ASSERT_BITS(mask, expected, actual)` |
elessair | 0:f269e3021894 | 68 | - `TEST_ASSERT_BITS_HIGH(mask, actual)` |
elessair | 0:f269e3021894 | 69 | - `TEST_ASSERT_BITS_LOW(mask, actual)` |
elessair | 0:f269e3021894 | 70 | - `TEST_ASSERT_BIT_HIGH(bit, actual)` |
elessair | 0:f269e3021894 | 71 | - `TEST_ASSERT_BIT_LOW(bit, actual)` |
elessair | 0:f269e3021894 | 72 | |
elessair | 0:f269e3021894 | 73 | #### Deltas: |
elessair | 0:f269e3021894 | 74 | |
elessair | 0:f269e3021894 | 75 | - `TEST_ASSERT_INT_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 76 | - `TEST_ASSERT_INT8_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 77 | - `TEST_ASSERT_INT16_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 78 | - `TEST_ASSERT_INT32_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 79 | - `TEST_ASSERT_INT64_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 80 | - `TEST_ASSERT_UINT_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 81 | - `TEST_ASSERT_UINT8_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 82 | - `TEST_ASSERT_UINT16_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 83 | - `TEST_ASSERT_UINT32_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 84 | - `TEST_ASSERT_UINT64_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 85 | - `TEST_ASSERT_HEX_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 86 | - `TEST_ASSERT_HEX8_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 87 | - `TEST_ASSERT_HEX16_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 88 | - `TEST_ASSERT_HEX32_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 89 | - `TEST_ASSERT_HEX64_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 90 | |
elessair | 0:f269e3021894 | 91 | #### Memory: |
elessair | 0:f269e3021894 | 92 | |
elessair | 0:f269e3021894 | 93 | - `TEST_ASSERT_EQUAL_PTR(expected, actual)` |
elessair | 0:f269e3021894 | 94 | - `TEST_ASSERT_EQUAL_STRING(expected, actual)` |
elessair | 0:f269e3021894 | 95 | - `TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len)` |
elessair | 0:f269e3021894 | 96 | - `TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)` |
elessair | 0:f269e3021894 | 97 | |
elessair | 0:f269e3021894 | 98 | #### Array: |
elessair | 0:f269e3021894 | 99 | |
elessair | 0:f269e3021894 | 100 | - `TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 101 | - `TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 102 | - `TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 103 | - `TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 104 | - `TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 105 | - `TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 106 | - `TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 107 | - `TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 108 | - `TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 109 | - `TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 110 | - `TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 111 | - `TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 112 | - `TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 113 | - `TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 114 | - `TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 115 | - `TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 116 | - `TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 117 | - `TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements)` |
elessair | 0:f269e3021894 | 118 | |
elessair | 0:f269e3021894 | 119 | #### Single Precision Floating Point: |
elessair | 0:f269e3021894 | 120 | |
elessair | 0:f269e3021894 | 121 | - `TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 122 | - `TEST_ASSERT_EQUAL_FLOAT(expected, actual)` |
elessair | 0:f269e3021894 | 123 | - `TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 124 | - `TEST_ASSERT_FLOAT_IS_INF(actual)` |
elessair | 0:f269e3021894 | 125 | - `TEST_ASSERT_FLOAT_IS_NEG_INF(actual)` |
elessair | 0:f269e3021894 | 126 | - `TEST_ASSERT_FLOAT_IS_NAN(actual)` |
elessair | 0:f269e3021894 | 127 | - `TEST_ASSERT_FLOAT_IS_DETERMINATE(actual)` |
elessair | 0:f269e3021894 | 128 | - `TEST_ASSERT_FLOAT_IS_NOT_INF(actual)` |
elessair | 0:f269e3021894 | 129 | - `TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual)` |
elessair | 0:f269e3021894 | 130 | - `TEST_ASSERT_FLOAT_IS_NOT_NAN(actual)` |
elessair | 0:f269e3021894 | 131 | - `TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual)` |
elessair | 0:f269e3021894 | 132 | |
elessair | 0:f269e3021894 | 133 | #### Double Precision Floating Point: |
elessair | 0:f269e3021894 | 134 | |
elessair | 0:f269e3021894 | 135 | - `TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual)` |
elessair | 0:f269e3021894 | 136 | - `TEST_ASSERT_EQUAL_DOUBLE(expected, actual)` |
elessair | 0:f269e3021894 | 137 | - `TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements)` |
elessair | 0:f269e3021894 | 138 | - `TEST_ASSERT_DOUBLE_IS_INF(actual)` |
elessair | 0:f269e3021894 | 139 | - `TEST_ASSERT_DOUBLE_IS_NEG_INF(actual)` |
elessair | 0:f269e3021894 | 140 | - `TEST_ASSERT_DOUBLE_IS_NAN(actual)` |
elessair | 0:f269e3021894 | 141 | - `TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual)` |
elessair | 0:f269e3021894 | 142 | - `TEST_ASSERT_DOUBLE_IS_NOT_INF(actual)` |
elessair | 0:f269e3021894 | 143 | - `TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual)` |
elessair | 0:f269e3021894 | 144 | - `TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual)` |
elessair | 0:f269e3021894 | 145 | - `TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual)` |