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