mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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