ceedling 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/example_file_call.c +6 -0
- data/assets/example_file_call.h +6 -0
- data/assets/test_example_file_with_mock.c +13 -0
- data/bin/ceedling +2 -2
- data/ceedling.gemspec +1 -1
- data/lib/ceedling/configurator.rb +7 -2
- data/lib/ceedling/configurator_plugins.rb +21 -1
- data/lib/ceedling/defaults.rb +1 -0
- data/lib/ceedling/preprocessinator_extractor.rb +2 -0
- data/lib/ceedling/preprocessinator_includes_handler.rb +24 -24
- data/lib/ceedling/version.rb +11 -7
- data/plugins/gcov/config/defaults_gcov.rb +118 -0
- data/plugins/gcov/lib/gcovr_reportinator.rb +1 -1
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +1 -1
- data/plugins/junit_tests_report/lib/junit_tests_report.rb +6 -6
- data/plugins/module_generator/README.md +16 -2
- data/plugins/module_generator/lib/module_generator.rb +1 -0
- data/spec/gcov/gcov_deployment_spec.rb +1 -1
- data/spec/preprocessinator_includes_handler_spec.rb +38 -8
- data/spec/spec_system_helper.rb +19 -0
- data/spec/system/deployment_spec.rb +1 -0
- data/vendor/cmock/lib/cmock_file_writer.rb +2 -3
- data/vendor/cmock/lib/cmock_generator.rb +87 -70
- data/vendor/cmock/lib/cmock_header_parser.rb +29 -27
- data/vendor/cmock/src/cmock.h +1 -1
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +46 -41
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +46 -40
- data/vendor/cmock/vendor/c_exception/README.md +6 -4
- data/vendor/cmock/vendor/c_exception/docs/CException.md +2 -2
- data/vendor/cmock/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/cmock/vendor/c_exception/lib/meson.build +2 -2
- data/vendor/cmock/vendor/c_exception/meson.build +36 -2
- data/vendor/cmock/vendor/unity/README.md +77 -71
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/cmock/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/cmock/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/cmock/vendor/unity/src/unity.c +1 -1
- data/vendor/cmock/vendor/unity/src/unity.h +1 -1
- data/vendor/cmock/vendor/unity/src/unity_internals.h +21 -7
- data/vendor/unity/README.md +77 -71
- data/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/unity/src/unity.c +1 -1
- data/vendor/unity/src/unity.h +1 -1
- data/vendor/unity/src/unity_internals.h +21 -7
- metadata +14 -5
- data/plugins/gcov/config/defaults.yml +0 -55
@@ -16,7 +16,6 @@ source code in, well, test code.
|
|
16
16
|
- Document types, expected values, and basic behavior in your source code for
|
17
17
|
free.
|
18
18
|
|
19
|
-
|
20
19
|
### Unity Is Several Things But Mainly It's Assertions
|
21
20
|
|
22
21
|
One way to think of Unity is simply as a rich collection of assertions you can
|
@@ -24,7 +23,6 @@ use to establish whether your source code behaves the way you think it does.
|
|
24
23
|
Unity provides a framework to easily organize and execute those assertions in
|
25
24
|
test code separate from your source code.
|
26
25
|
|
27
|
-
|
28
26
|
### What's an Assertion?
|
29
27
|
|
30
28
|
At their core, assertions are an establishment of truth - boolean truth. Was this
|
@@ -36,7 +34,7 @@ execution and reports an error through some appropriate I/O channel (e.g.
|
|
36
34
|
stdout, GUI, file, blinky light).
|
37
35
|
|
38
36
|
Fundamentally, for dynamic verification all you need is a single assertion
|
39
|
-
mechanism. In fact, that's what the [assert() macro in C's standard library
|
37
|
+
mechanism. In fact, that's what the [assert() macro][] in C's standard library
|
40
38
|
is for. So why not just use it? Well, we can do far better in the reporting
|
41
39
|
department. C's `assert()` is pretty dumb as-is and is particularly poor for
|
42
40
|
handling common data types like arrays, structs, etc. And, without some other
|
@@ -44,7 +42,6 @@ support, it's far too tempting to litter source code with C's `assert()`'s. It's
|
|
44
42
|
generally much cleaner, manageable, and more useful to separate test and source
|
45
43
|
code in the way Unity facilitates.
|
46
44
|
|
47
|
-
|
48
45
|
### Unity's Assertions: Helpful Messages _and_ Free Source Code Documentation
|
49
46
|
|
50
47
|
Asserting a simple truth condition is valuable, but using the context of the
|
@@ -60,34 +57,32 @@ tests pass, you have a detailed, up-to-date view of the intent and mechanisms in
|
|
60
57
|
your source code. And due to a wondrous mystery, well-tested code usually tends
|
61
58
|
to be well designed code.
|
62
59
|
|
63
|
-
|
64
60
|
## Assertion Conventions and Configurations
|
65
61
|
|
66
62
|
### Naming and Parameter Conventions
|
67
63
|
|
68
64
|
The convention of assertion parameters generally follows this order:
|
69
65
|
|
70
|
-
```
|
66
|
+
```c
|
71
67
|
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
|
72
68
|
```
|
73
69
|
|
74
70
|
The very simplest assertion possible uses only a single `actual` parameter (e.g.
|
75
71
|
a simple null check).
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
73
|
+
- `Actual` is the value being tested and unlike the other parameters in an
|
74
|
+
assertion construction is the only parameter present in all assertion variants.
|
75
|
+
- `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas.
|
76
|
+
- `Expected` is your expected value (duh) to compare to an `actual` value; it's
|
77
|
+
marked as an optional parameter because some assertions only need a single
|
78
|
+
`actual` parameter (e.g. null check).
|
79
|
+
- `Size/count` refers to string lengths, number of array elements, etc.
|
84
80
|
|
85
81
|
Many of Unity's assertions are clear duplications in that the same data type
|
86
82
|
is handled by several assertions. The differences among these are in how failure
|
87
83
|
messages are presented. For instance, a `_HEX` variant of an assertion prints
|
88
84
|
the expected and actual values of that assertion formatted as hexadecimal.
|
89
85
|
|
90
|
-
|
91
86
|
#### TEST_ASSERT_X_MESSAGE Variants
|
92
87
|
|
93
88
|
_All_ assertions are complemented with a variant that includes a simple string
|
@@ -100,17 +95,18 @@ the reference list below and add a string as the final parameter.
|
|
100
95
|
|
101
96
|
_Example:_
|
102
97
|
|
103
|
-
```
|
98
|
+
```c
|
104
99
|
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
|
105
100
|
```
|
106
101
|
|
107
102
|
becomes messageified like thus...
|
108
103
|
|
109
|
-
```
|
104
|
+
```c
|
110
105
|
TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message )
|
111
106
|
```
|
112
107
|
|
113
108
|
Notes:
|
109
|
+
|
114
110
|
- The `_MESSAGE` variants intentionally do not support `printf` style formatting
|
115
111
|
since many embedded projects don't support or avoid `printf` for various reasons.
|
116
112
|
It is possible to use `sprintf` before the assertion to assemble a complex fail
|
@@ -119,7 +115,6 @@ Notes:
|
|
119
115
|
a loop) , building up an array of results and then using one of the `_ARRAY`
|
120
116
|
assertions (see below) might be a handy alternative to `sprintf`.
|
121
117
|
|
122
|
-
|
123
118
|
#### TEST_ASSERT_X_ARRAY Variants
|
124
119
|
|
125
120
|
Unity provides a collection of assertions for arrays containing a variety of
|
@@ -128,22 +123,21 @@ with the `_MESSAGE`variants of Unity's Asserts in that for pretty much any Unity
|
|
128
123
|
type assertion you can tack on `_ARRAY` and run assertions on an entire block of
|
129
124
|
memory.
|
130
125
|
|
131
|
-
```
|
126
|
+
```c
|
132
127
|
TEST_ASSERT_EQUAL_TYPEX_ARRAY( expected, actual, {size/count} )
|
133
128
|
```
|
134
129
|
|
135
|
-
|
136
|
-
|
137
|
-
|
130
|
+
- `Expected` is an array itself.
|
131
|
+
- `Size/count` is one or two parameters necessary to establish the number of array
|
132
|
+
elements and perhaps the length of elements within the array.
|
138
133
|
|
139
134
|
Notes:
|
140
135
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
136
|
+
- The `_MESSAGE` variant convention still applies here to array assertions. The
|
137
|
+
`_MESSAGE` variants of the `_ARRAY` assertions have names ending with
|
138
|
+
`_ARRAY_MESSAGE`.
|
139
|
+
- Assertions for handling arrays of floating point values are grouped with float
|
140
|
+
and double assertions (see immediately following section).
|
147
141
|
|
148
142
|
### TEST_ASSERT_EACH_EQUAL_X Variants
|
149
143
|
|
@@ -153,21 +147,20 @@ the Each Equal section below. these are almost on par with the `_MESSAGE`
|
|
153
147
|
variants of Unity's Asserts in that for pretty much any Unity type assertion you
|
154
148
|
can inject `_EACH_EQUAL` and run assertions on an entire block of memory.
|
155
149
|
|
156
|
-
```
|
150
|
+
```c
|
157
151
|
TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} )
|
158
152
|
```
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
154
|
+
- `Expected` is a single value to compare to.
|
155
|
+
- `Actual` is an array where each element will be compared to the expected value.
|
156
|
+
- `Size/count` is one of two parameters necessary to establish the number of array
|
157
|
+
elements and perhaps the length of elements within the array.
|
164
158
|
|
165
159
|
Notes:
|
166
160
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
161
|
+
- The `_MESSAGE` variant convention still applies here to Each Equal assertions.
|
162
|
+
- Assertions for handling Each Equal of floating point values are grouped with
|
163
|
+
float and double assertions (see immediately following section).
|
171
164
|
|
172
165
|
### Configuration
|
173
166
|
|
@@ -179,7 +172,6 @@ or disabled in Unity code. This is useful for embedded targets with no floating
|
|
179
172
|
point math support (i.e. Unity compiles free of errors for fixed point only
|
180
173
|
platforms). See Unity documentation for specifics.
|
181
174
|
|
182
|
-
|
183
175
|
#### Maximum Data Type Width Is Configurable
|
184
176
|
|
185
177
|
Not all targets support 64 bit wide types or even 32 bit wide types. Define the
|
@@ -187,14 +179,13 @@ appropriate preprocessor symbols and Unity will omit all operations from
|
|
187
179
|
compilation that exceed the maximum width of your target. See Unity
|
188
180
|
documentation for specifics.
|
189
181
|
|
190
|
-
|
191
182
|
## The Assertions in All Their Blessed Glory
|
192
183
|
|
193
184
|
### Basic Fail, Pass and Ignore
|
194
185
|
|
195
|
-
|
186
|
+
#### `TEST_FAIL()`
|
196
187
|
|
197
|
-
|
188
|
+
#### `TEST_FAIL_MESSAGE("message")`
|
198
189
|
|
199
190
|
This fella is most often used in special conditions where your test code is
|
200
191
|
performing logic beyond a simple assertion. That is, in practice, `TEST_FAIL()`
|
@@ -207,25 +198,25 @@ code then verifies as a final step.
|
|
207
198
|
- Triggering an exception and verifying it (as in Try / Catch / Throw - see the
|
208
199
|
[CException](https://github.com/ThrowTheSwitch/CException) project).
|
209
200
|
|
210
|
-
|
201
|
+
#### `TEST_PASS()`
|
211
202
|
|
212
|
-
|
203
|
+
#### `TEST_PASS_MESSAGE("message")`
|
213
204
|
|
214
205
|
This will abort the remainder of the test, but count the test as a pass. Under
|
215
206
|
normal circumstances, it is not necessary to include this macro in your tests...
|
216
207
|
a lack of failure will automatically be counted as a `PASS`. It is occasionally
|
217
208
|
useful for tests with `#ifdef`s and such.
|
218
209
|
|
219
|
-
|
210
|
+
#### `TEST_IGNORE()`
|
220
211
|
|
221
|
-
|
212
|
+
#### `TEST_IGNORE_MESSAGE("message")`
|
222
213
|
|
223
214
|
Marks a test case (i.e. function meant to contain test assertions) as ignored.
|
224
215
|
Usually this is employed as a breadcrumb to come back and implement a test case.
|
225
216
|
An ignored test case has effects if other assertions are in the enclosing test
|
226
217
|
case (see Unity documentation for more).
|
227
218
|
|
228
|
-
|
219
|
+
#### `TEST_MESSAGE(message)`
|
229
220
|
|
230
221
|
This can be useful for outputting `INFO` messages into the Unity output stream
|
231
222
|
without actually ending the test. Like pass and fail messages, it will be output
|
@@ -233,27 +224,27 @@ with the filename and line number.
|
|
233
224
|
|
234
225
|
### Boolean
|
235
226
|
|
236
|
-
|
227
|
+
#### `TEST_ASSERT (condition)`
|
237
228
|
|
238
|
-
|
229
|
+
#### `TEST_ASSERT_TRUE (condition)`
|
239
230
|
|
240
|
-
|
231
|
+
#### `TEST_ASSERT_FALSE (condition)`
|
241
232
|
|
242
|
-
|
233
|
+
#### `TEST_ASSERT_UNLESS (condition)`
|
243
234
|
|
244
235
|
A simple wording variation on `TEST_ASSERT_FALSE`.The semantics of
|
245
236
|
`TEST_ASSERT_UNLESS` aid readability in certain test constructions or
|
246
237
|
conditional statements.
|
247
238
|
|
248
|
-
|
239
|
+
#### `TEST_ASSERT_NULL (pointer)`
|
249
240
|
|
250
|
-
|
241
|
+
#### `TEST_ASSERT_NOT_NULL (pointer)`
|
251
242
|
|
252
243
|
Verify if a pointer is or is not NULL.
|
253
244
|
|
254
|
-
|
245
|
+
#### `TEST_ASSERT_EMPTY (pointer)`
|
255
246
|
|
256
|
-
|
247
|
+
#### `TEST_ASSERT_NOT_EMPTY (pointer)`
|
257
248
|
|
258
249
|
Verify if the first element dereferenced from a pointer is or is not zero. This
|
259
250
|
is particularly useful for checking for empty (or non-empty) null-terminated
|
@@ -268,26 +259,25 @@ that would break compilation (see Unity documentation for more). Refer to
|
|
268
259
|
Advanced Asserting later in this document for advice on dealing with other word
|
269
260
|
sizes.
|
270
261
|
|
271
|
-
|
262
|
+
#### `TEST_ASSERT_EQUAL_INT (expected, actual)`
|
272
263
|
|
273
|
-
|
264
|
+
#### `TEST_ASSERT_EQUAL_INT8 (expected, actual)`
|
274
265
|
|
275
|
-
|
266
|
+
#### `TEST_ASSERT_EQUAL_INT16 (expected, actual)`
|
276
267
|
|
277
|
-
|
268
|
+
#### `TEST_ASSERT_EQUAL_INT32 (expected, actual)`
|
278
269
|
|
279
|
-
|
270
|
+
#### `TEST_ASSERT_EQUAL_INT64 (expected, actual)`
|
280
271
|
|
281
|
-
|
272
|
+
#### `TEST_ASSERT_EQUAL_UINT (expected, actual)`
|
282
273
|
|
283
|
-
|
274
|
+
#### `TEST_ASSERT_EQUAL_UINT8 (expected, actual)`
|
284
275
|
|
285
|
-
|
276
|
+
#### `TEST_ASSERT_EQUAL_UINT16 (expected, actual)`
|
286
277
|
|
287
|
-
|
288
|
-
|
289
|
-
##### `TEST_ASSERT_EQUAL_UINT64 (expected, actual)`
|
278
|
+
#### `TEST_ASSERT_EQUAL_UINT32 (expected, actual)`
|
290
279
|
|
280
|
+
#### `TEST_ASSERT_EQUAL_UINT64 (expected, actual)`
|
291
281
|
|
292
282
|
### Unsigned Integers (of all sizes) in Hexadecimal
|
293
283
|
|
@@ -295,16 +285,15 @@ All `_HEX` assertions are identical in function to unsigned integer assertions
|
|
295
285
|
but produce failure messages with the `expected` and `actual` values formatted
|
296
286
|
in hexadecimal. Unity output is big endian.
|
297
287
|
|
298
|
-
|
299
|
-
|
300
|
-
##### `TEST_ASSERT_EQUAL_HEX8 (expected, actual)`
|
288
|
+
#### `TEST_ASSERT_EQUAL_HEX (expected, actual)`
|
301
289
|
|
302
|
-
|
290
|
+
#### `TEST_ASSERT_EQUAL_HEX8 (expected, actual)`
|
303
291
|
|
304
|
-
|
292
|
+
#### `TEST_ASSERT_EQUAL_HEX16 (expected, actual)`
|
305
293
|
|
306
|
-
|
294
|
+
#### `TEST_ASSERT_EQUAL_HEX32 (expected, actual)`
|
307
295
|
|
296
|
+
#### `TEST_ASSERT_EQUAL_HEX64 (expected, actual)`
|
308
297
|
|
309
298
|
### Characters
|
310
299
|
|
@@ -312,36 +301,30 @@ While you can use the 8-bit integer assertions to compare `char`, another option
|
|
312
301
|
to use this specialized assertion which will show printable characters as printables,
|
313
302
|
otherwise showing the HEX escape code for the characters.
|
314
303
|
|
315
|
-
|
316
|
-
|
304
|
+
#### `TEST_ASSERT_EQUAL_CHAR (expected, actual)`
|
317
305
|
|
318
306
|
### Masked and Bit-level Assertions
|
319
307
|
|
320
308
|
Masked and bit-level assertions produce output formatted in hexadecimal. Unity
|
321
309
|
output is big endian.
|
322
310
|
|
323
|
-
|
324
|
-
##### `TEST_ASSERT_BITS (mask, expected, actual)`
|
311
|
+
#### `TEST_ASSERT_BITS (mask, expected, actual)`
|
325
312
|
|
326
313
|
Only compares the masked (i.e. high) bits of `expected` and `actual` parameters.
|
327
314
|
|
328
|
-
|
329
|
-
##### `TEST_ASSERT_BITS_HIGH (mask, actual)`
|
315
|
+
#### `TEST_ASSERT_BITS_HIGH (mask, actual)`
|
330
316
|
|
331
317
|
Asserts the masked bits of the `actual` parameter are high.
|
332
318
|
|
333
|
-
|
334
|
-
##### `TEST_ASSERT_BITS_LOW (mask, actual)`
|
319
|
+
#### `TEST_ASSERT_BITS_LOW (mask, actual)`
|
335
320
|
|
336
321
|
Asserts the masked bits of the `actual` parameter are low.
|
337
322
|
|
338
|
-
|
339
|
-
##### `TEST_ASSERT_BIT_HIGH (bit, actual)`
|
323
|
+
#### `TEST_ASSERT_BIT_HIGH (bit, actual)`
|
340
324
|
|
341
325
|
Asserts the specified bit of the `actual` parameter is high.
|
342
326
|
|
343
|
-
|
344
|
-
##### `TEST_ASSERT_BIT_LOW (bit, actual)`
|
327
|
+
#### `TEST_ASSERT_BIT_LOW (bit, actual)`
|
345
328
|
|
346
329
|
Asserts the specified bit of the `actual` parameter is low.
|
347
330
|
|
@@ -352,16 +335,15 @@ than `threshold` (exclusive). For example, if the threshold value is 0 for the
|
|
352
335
|
greater than assertion will fail if it is 0 or less. There are assertions for
|
353
336
|
all the various sizes of ints, as for the equality assertions. Some examples:
|
354
337
|
|
355
|
-
|
338
|
+
#### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)`
|
356
339
|
|
357
|
-
|
340
|
+
#### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)`
|
358
341
|
|
359
|
-
|
342
|
+
#### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)`
|
360
343
|
|
361
|
-
|
362
|
-
|
363
|
-
##### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)`
|
344
|
+
#### `TEST_ASSERT_LESS_OR_EQUAL_UINT (threshold, actual)`
|
364
345
|
|
346
|
+
#### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)`
|
365
347
|
|
366
348
|
### Integer Ranges (of all sizes)
|
367
349
|
|
@@ -370,60 +352,57 @@ These assertions verify that the `expected` parameter is within +/- `delta`
|
|
370
352
|
and the delta is 3 then the assertion will fail for any value outside the range
|
371
353
|
of 7 - 13.
|
372
354
|
|
373
|
-
|
355
|
+
#### `TEST_ASSERT_INT_WITHIN (delta, expected, actual)`
|
374
356
|
|
375
|
-
|
357
|
+
#### `TEST_ASSERT_INT8_WITHIN (delta, expected, actual)`
|
376
358
|
|
377
|
-
|
359
|
+
#### `TEST_ASSERT_INT16_WITHIN (delta, expected, actual)`
|
378
360
|
|
379
|
-
|
361
|
+
#### `TEST_ASSERT_INT32_WITHIN (delta, expected, actual)`
|
380
362
|
|
381
|
-
|
363
|
+
#### `TEST_ASSERT_INT64_WITHIN (delta, expected, actual)`
|
382
364
|
|
383
|
-
|
365
|
+
#### `TEST_ASSERT_UINT_WITHIN (delta, expected, actual)`
|
384
366
|
|
385
|
-
|
367
|
+
#### `TEST_ASSERT_UINT8_WITHIN (delta, expected, actual)`
|
386
368
|
|
387
|
-
|
369
|
+
#### `TEST_ASSERT_UINT16_WITHIN (delta, expected, actual)`
|
388
370
|
|
389
|
-
|
371
|
+
#### `TEST_ASSERT_UINT32_WITHIN (delta, expected, actual)`
|
390
372
|
|
391
|
-
|
373
|
+
#### `TEST_ASSERT_UINT64_WITHIN (delta, expected, actual)`
|
392
374
|
|
393
|
-
|
375
|
+
#### `TEST_ASSERT_HEX_WITHIN (delta, expected, actual)`
|
394
376
|
|
395
|
-
|
377
|
+
#### `TEST_ASSERT_HEX8_WITHIN (delta, expected, actual)`
|
396
378
|
|
397
|
-
|
379
|
+
#### `TEST_ASSERT_HEX16_WITHIN (delta, expected, actual)`
|
398
380
|
|
399
|
-
|
381
|
+
#### `TEST_ASSERT_HEX32_WITHIN (delta, expected, actual)`
|
400
382
|
|
401
|
-
|
383
|
+
#### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)`
|
402
384
|
|
403
|
-
|
385
|
+
#### `TEST_ASSERT_CHAR_WITHIN (delta, expected, actual)`
|
404
386
|
|
405
387
|
### Structs and Strings
|
406
388
|
|
407
|
-
|
389
|
+
#### `TEST_ASSERT_EQUAL_PTR (expected, actual)`
|
408
390
|
|
409
391
|
Asserts that the pointers point to the same memory location.
|
410
392
|
|
411
|
-
|
412
|
-
##### `TEST_ASSERT_EQUAL_STRING (expected, actual)`
|
393
|
+
#### `TEST_ASSERT_EQUAL_STRING (expected, actual)`
|
413
394
|
|
414
395
|
Asserts that the null terminated (`'\0'`)strings are identical. If strings are
|
415
396
|
of different lengths or any portion of the strings before their terminators
|
416
397
|
differ, the assertion fails. Two NULL strings (i.e. zero length) are considered
|
417
398
|
equivalent.
|
418
399
|
|
419
|
-
|
420
|
-
##### `TEST_ASSERT_EQUAL_MEMORY (expected, actual, len)`
|
400
|
+
#### `TEST_ASSERT_EQUAL_MEMORY (expected, actual, len)`
|
421
401
|
|
422
402
|
Asserts that the contents of the memory specified by the `expected` and `actual`
|
423
403
|
pointers is identical. The size of the memory blocks in bytes is specified by
|
424
404
|
the `len` parameter.
|
425
405
|
|
426
|
-
|
427
406
|
### Arrays
|
428
407
|
|
429
408
|
`expected` and `actual` parameters are both arrays. `num_elements` specifies the
|
@@ -438,43 +417,43 @@ For array of strings comparison behavior, see comments for
|
|
438
417
|
Assertions fail upon the first element in the compared arrays found not to
|
439
418
|
match. Failure messages specify the array index of the failed comparison.
|
440
419
|
|
441
|
-
|
420
|
+
#### `TEST_ASSERT_EQUAL_INT_ARRAY (expected, actual, num_elements)`
|
442
421
|
|
443
|
-
|
422
|
+
#### `TEST_ASSERT_EQUAL_INT8_ARRAY (expected, actual, num_elements)`
|
444
423
|
|
445
|
-
|
424
|
+
#### `TEST_ASSERT_EQUAL_INT16_ARRAY (expected, actual, num_elements)`
|
446
425
|
|
447
|
-
|
426
|
+
#### `TEST_ASSERT_EQUAL_INT32_ARRAY (expected, actual, num_elements)`
|
448
427
|
|
449
|
-
|
428
|
+
#### `TEST_ASSERT_EQUAL_INT64_ARRAY (expected, actual, num_elements)`
|
450
429
|
|
451
|
-
|
430
|
+
#### `TEST_ASSERT_EQUAL_UINT_ARRAY (expected, actual, num_elements)`
|
452
431
|
|
453
|
-
|
432
|
+
#### `TEST_ASSERT_EQUAL_UINT8_ARRAY (expected, actual, num_elements)`
|
454
433
|
|
455
|
-
|
434
|
+
#### `TEST_ASSERT_EQUAL_UINT16_ARRAY (expected, actual, num_elements)`
|
456
435
|
|
457
|
-
|
436
|
+
#### `TEST_ASSERT_EQUAL_UINT32_ARRAY (expected, actual, num_elements)`
|
458
437
|
|
459
|
-
|
438
|
+
#### `TEST_ASSERT_EQUAL_UINT64_ARRAY (expected, actual, num_elements)`
|
460
439
|
|
461
|
-
|
440
|
+
#### `TEST_ASSERT_EQUAL_HEX_ARRAY (expected, actual, num_elements)`
|
462
441
|
|
463
|
-
|
442
|
+
#### `TEST_ASSERT_EQUAL_HEX8_ARRAY (expected, actual, num_elements)`
|
464
443
|
|
465
|
-
|
444
|
+
#### `TEST_ASSERT_EQUAL_HEX16_ARRAY (expected, actual, num_elements)`
|
466
445
|
|
467
|
-
|
446
|
+
#### `TEST_ASSERT_EQUAL_HEX32_ARRAY (expected, actual, num_elements)`
|
468
447
|
|
469
|
-
|
448
|
+
#### `TEST_ASSERT_EQUAL_HEX64_ARRAY (expected, actual, num_elements)`
|
470
449
|
|
471
|
-
|
450
|
+
#### `TEST_ASSERT_EQUAL_CHAR_ARRAY (expected, actual, num_elements)`
|
472
451
|
|
473
|
-
|
452
|
+
#### `TEST_ASSERT_EQUAL_PTR_ARRAY (expected, actual, num_elements)`
|
474
453
|
|
475
|
-
|
454
|
+
#### `TEST_ASSERT_EQUAL_STRING_ARRAY (expected, actual, num_elements)`
|
476
455
|
|
477
|
-
|
456
|
+
#### `TEST_ASSERT_EQUAL_MEMORY_ARRAY (expected, actual, len, num_elements)`
|
478
457
|
|
479
458
|
`len` is the memory in bytes to be compared at each array element.
|
480
459
|
|
@@ -485,37 +464,37 @@ These assertions verify that the `expected` array parameter is within +/- `delta
|
|
485
464
|
\[10, 12\] and the delta is 3 then the assertion will fail for any value
|
486
465
|
outside the range of \[7 - 13, 9 - 15\].
|
487
466
|
|
488
|
-
|
467
|
+
#### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
489
468
|
|
490
|
-
|
469
|
+
#### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
491
470
|
|
492
|
-
|
471
|
+
#### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
493
472
|
|
494
|
-
|
473
|
+
#### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
495
474
|
|
496
|
-
|
475
|
+
#### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
497
476
|
|
498
|
-
|
477
|
+
#### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
499
478
|
|
500
|
-
|
479
|
+
#### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
501
480
|
|
502
|
-
|
481
|
+
#### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
503
482
|
|
504
|
-
|
483
|
+
#### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
505
484
|
|
506
|
-
|
485
|
+
#### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
507
486
|
|
508
|
-
|
487
|
+
#### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
509
488
|
|
510
|
-
|
489
|
+
#### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
511
490
|
|
512
|
-
|
491
|
+
#### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
513
492
|
|
514
|
-
|
493
|
+
#### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
515
494
|
|
516
|
-
|
495
|
+
#### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
517
496
|
|
518
|
-
|
497
|
+
#### `TEST_ASSERT_CHAR_ARRAY_WITHIN (delta, expected, actual, num_elements)`
|
519
498
|
|
520
499
|
### Each Equal (Arrays to Single Value)
|
521
500
|
|
@@ -568,17 +547,15 @@ match. Failure messages specify the array index of the failed comparison.
|
|
568
547
|
|
569
548
|
`len` is the memory in bytes to be compared at each array element.
|
570
549
|
|
571
|
-
|
572
550
|
### Floating Point (If enabled)
|
573
551
|
|
574
|
-
|
552
|
+
#### `TEST_ASSERT_FLOAT_WITHIN (delta, expected, actual)`
|
575
553
|
|
576
554
|
Asserts that the `actual` value is within +/- `delta` of the `expected` value.
|
577
555
|
The nature of floating point representation is such that exact evaluations of
|
578
556
|
equality are not guaranteed.
|
579
557
|
|
580
|
-
|
581
|
-
##### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)`
|
558
|
+
#### `TEST_ASSERT_EQUAL_FLOAT (expected, actual)`
|
582
559
|
|
583
560
|
Asserts that the ?actual?value is "close enough to be considered equal" to the
|
584
561
|
`expected` value. If you are curious about the details, refer to the Advanced
|
@@ -586,74 +563,63 @@ Asserting section for more details on this. Omitting a user-specified delta in a
|
|
586
563
|
floating point assertion is both a shorthand convenience and a requirement of
|
587
564
|
code generation conventions for CMock.
|
588
565
|
|
589
|
-
|
590
|
-
##### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)`
|
566
|
+
#### `TEST_ASSERT_EQUAL_FLOAT_ARRAY (expected, actual, num_elements)`
|
591
567
|
|
592
568
|
See Array assertion section for details. Note that individual array element
|
593
569
|
float comparisons are executed using T?EST_ASSERT_EQUAL_FLOAT?.That is, user
|
594
570
|
specified delta comparison values requires a custom-implemented floating point
|
595
571
|
array assertion.
|
596
572
|
|
597
|
-
|
598
|
-
##### `TEST_ASSERT_FLOAT_IS_INF (actual)`
|
573
|
+
#### `TEST_ASSERT_FLOAT_IS_INF (actual)`
|
599
574
|
|
600
575
|
Asserts that `actual` parameter is equivalent to positive infinity floating
|
601
576
|
point representation.
|
602
577
|
|
603
|
-
|
604
|
-
##### `TEST_ASSERT_FLOAT_IS_NEG_INF (actual)`
|
578
|
+
#### `TEST_ASSERT_FLOAT_IS_NEG_INF (actual)`
|
605
579
|
|
606
580
|
Asserts that `actual` parameter is equivalent to negative infinity floating
|
607
581
|
point representation.
|
608
582
|
|
609
|
-
|
610
|
-
##### `TEST_ASSERT_FLOAT_IS_NAN (actual)`
|
583
|
+
#### `TEST_ASSERT_FLOAT_IS_NAN (actual)`
|
611
584
|
|
612
585
|
Asserts that `actual` parameter is a Not A Number floating point representation.
|
613
586
|
|
614
|
-
|
615
|
-
##### `TEST_ASSERT_FLOAT_IS_DETERMINATE (actual)`
|
587
|
+
#### `TEST_ASSERT_FLOAT_IS_DETERMINATE (actual)`
|
616
588
|
|
617
589
|
Asserts that ?actual?parameter is a floating point representation usable for
|
618
590
|
mathematical operations. That is, the `actual` parameter is neither positive
|
619
591
|
infinity nor negative infinity nor Not A Number floating point representations.
|
620
592
|
|
621
|
-
|
622
|
-
##### `TEST_ASSERT_FLOAT_IS_NOT_INF (actual)`
|
593
|
+
#### `TEST_ASSERT_FLOAT_IS_NOT_INF (actual)`
|
623
594
|
|
624
595
|
Asserts that `actual` parameter is a value other than positive infinity floating
|
625
596
|
point representation.
|
626
597
|
|
627
|
-
|
628
|
-
##### `TEST_ASSERT_FLOAT_IS_NOT_NEG_INF (actual)`
|
598
|
+
#### `TEST_ASSERT_FLOAT_IS_NOT_NEG_INF (actual)`
|
629
599
|
|
630
600
|
Asserts that `actual` parameter is a value other than negative infinity floating
|
631
601
|
point representation.
|
632
602
|
|
633
|
-
|
634
|
-
##### `TEST_ASSERT_FLOAT_IS_NOT_NAN (actual)`
|
603
|
+
#### `TEST_ASSERT_FLOAT_IS_NOT_NAN (actual)`
|
635
604
|
|
636
605
|
Asserts that `actual` parameter is a value other than Not A Number floating
|
637
606
|
point representation.
|
638
607
|
|
639
|
-
|
640
|
-
##### `TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE (actual)`
|
608
|
+
#### `TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE (actual)`
|
641
609
|
|
642
610
|
Asserts that `actual` parameter is not usable for mathematical operations. That
|
643
611
|
is, the `actual` parameter is either positive infinity or negative infinity or
|
644
612
|
Not A Number floating point representations.
|
645
613
|
|
646
|
-
|
647
614
|
### Double (If enabled)
|
648
615
|
|
649
|
-
|
616
|
+
#### `TEST_ASSERT_DOUBLE_WITHIN (delta, expected, actual)`
|
650
617
|
|
651
618
|
Asserts that the `actual` value is within +/- `delta` of the `expected` value.
|
652
619
|
The nature of floating point representation is such that exact evaluations of
|
653
620
|
equality are not guaranteed.
|
654
621
|
|
655
|
-
|
656
|
-
##### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)`
|
622
|
+
#### `TEST_ASSERT_EQUAL_DOUBLE (expected, actual)`
|
657
623
|
|
658
624
|
Asserts that the `actual` value is "close enough to be considered equal" to the
|
659
625
|
`expected` value. If you are curious about the details, refer to the Advanced
|
@@ -661,64 +627,54 @@ Asserting section for more details. Omitting a user-specified delta in a
|
|
661
627
|
floating point assertion is both a shorthand convenience and a requirement of
|
662
628
|
code generation conventions for CMock.
|
663
629
|
|
664
|
-
|
665
|
-
##### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)`
|
630
|
+
#### `TEST_ASSERT_EQUAL_DOUBLE_ARRAY (expected, actual, num_elements)`
|
666
631
|
|
667
632
|
See Array assertion section for details. Note that individual array element
|
668
633
|
double comparisons are executed using `TEST_ASSERT_EQUAL_DOUBLE`.That is, user
|
669
634
|
specified delta comparison values requires a custom implemented double array
|
670
635
|
assertion.
|
671
636
|
|
672
|
-
|
673
|
-
##### `TEST_ASSERT_DOUBLE_IS_INF (actual)`
|
637
|
+
#### `TEST_ASSERT_DOUBLE_IS_INF (actual)`
|
674
638
|
|
675
639
|
Asserts that `actual` parameter is equivalent to positive infinity floating
|
676
640
|
point representation.
|
677
641
|
|
678
|
-
|
679
|
-
##### `TEST_ASSERT_DOUBLE_IS_NEG_INF (actual)`
|
642
|
+
#### `TEST_ASSERT_DOUBLE_IS_NEG_INF (actual)`
|
680
643
|
|
681
644
|
Asserts that `actual` parameter is equivalent to negative infinity floating point
|
682
645
|
representation.
|
683
646
|
|
684
|
-
|
685
|
-
##### `TEST_ASSERT_DOUBLE_IS_NAN (actual)`
|
647
|
+
#### `TEST_ASSERT_DOUBLE_IS_NAN (actual)`
|
686
648
|
|
687
649
|
Asserts that `actual` parameter is a Not A Number floating point representation.
|
688
650
|
|
689
|
-
|
690
|
-
##### `TEST_ASSERT_DOUBLE_IS_DETERMINATE (actual)`
|
651
|
+
#### `TEST_ASSERT_DOUBLE_IS_DETERMINATE (actual)`
|
691
652
|
|
692
653
|
Asserts that `actual` parameter is a floating point representation usable for
|
693
654
|
mathematical operations. That is, the ?actual?parameter is neither positive
|
694
655
|
infinity nor negative infinity nor Not A Number floating point representations.
|
695
656
|
|
696
|
-
|
697
|
-
##### `TEST_ASSERT_DOUBLE_IS_NOT_INF (actual)`
|
657
|
+
#### `TEST_ASSERT_DOUBLE_IS_NOT_INF (actual)`
|
698
658
|
|
699
659
|
Asserts that `actual` parameter is a value other than positive infinity floating
|
700
660
|
point representation.
|
701
661
|
|
702
|
-
|
703
|
-
##### `TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF (actual)`
|
662
|
+
#### `TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF (actual)`
|
704
663
|
|
705
664
|
Asserts that `actual` parameter is a value other than negative infinity floating
|
706
665
|
point representation.
|
707
666
|
|
708
|
-
|
709
|
-
##### `TEST_ASSERT_DOUBLE_IS_NOT_NAN (actual)`
|
667
|
+
#### `TEST_ASSERT_DOUBLE_IS_NOT_NAN (actual)`
|
710
668
|
|
711
669
|
Asserts that `actual` parameter is a value other than Not A Number floating
|
712
670
|
point representation.
|
713
671
|
|
714
|
-
|
715
|
-
##### `TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE (actual)`
|
672
|
+
#### `TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE (actual)`
|
716
673
|
|
717
674
|
Asserts that `actual` parameter is not usable for mathematical operations. That
|
718
675
|
is, the `actual` parameter is either positive infinity or negative infinity or
|
719
676
|
Not A Number floating point representations.
|
720
677
|
|
721
|
-
|
722
678
|
## Advanced Asserting: Details On Tricky Assertions
|
723
679
|
|
724
680
|
This section helps you understand how to deal with some of the trickier
|
@@ -727,7 +683,6 @@ the under-the-hood details of Unity's assertion mechanisms. If you're one of
|
|
727
683
|
those people who likes to know what is going on in the background, read on. If
|
728
684
|
not, feel free to ignore the rest of this document until you need it.
|
729
685
|
|
730
|
-
|
731
686
|
### How do the EQUAL assertions work for FLOAT and DOUBLE?
|
732
687
|
|
733
688
|
As you may know, directly checking for equality between a pair of floats or a
|
@@ -768,7 +723,6 @@ assertions less strict, you can change these multipliers to whatever you like by
|
|
768
723
|
defining UNITY_FLOAT_PRECISION and UNITY_DOUBLE_PRECISION. See Unity
|
769
724
|
documentation for more.
|
770
725
|
|
771
|
-
|
772
726
|
### How do we deal with targets with non-standard int sizes?
|
773
727
|
|
774
728
|
It's "fun" that C is a standard where something as fundamental as an integer
|
@@ -827,5 +781,7 @@ operations, particularly `TEST_ASSERT_INT_WITHIN`.Such assertions might wrap
|
|
827
781
|
your `int` in the wrong place, and you could experience false failures. You can
|
828
782
|
always back down to a simple `TEST_ASSERT` and do the operations yourself.
|
829
783
|
|
784
|
+
*Find The Latest of This And More at [ThrowTheSwitch.org][]*
|
830
785
|
|
831
|
-
|
786
|
+
[assert() macro]: http://en.wikipedia.org/en/wiki/Assert.h
|
787
|
+
[ThrowTheSwitch.org]: https://throwtheswitch.org
|