ceedling 0.31.0 → 0.31.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/assets/example_file_call.c +6 -0
  3. data/assets/example_file_call.h +6 -0
  4. data/assets/test_example_file_with_mock.c +13 -0
  5. data/bin/ceedling +2 -2
  6. data/ceedling.gemspec +1 -1
  7. data/lib/ceedling/configurator.rb +7 -2
  8. data/lib/ceedling/configurator_plugins.rb +21 -1
  9. data/lib/ceedling/defaults.rb +1 -0
  10. data/lib/ceedling/preprocessinator_extractor.rb +2 -0
  11. data/lib/ceedling/preprocessinator_includes_handler.rb +24 -24
  12. data/lib/ceedling/version.rb +11 -7
  13. data/plugins/gcov/config/defaults_gcov.rb +118 -0
  14. data/plugins/gcov/lib/gcovr_reportinator.rb +1 -1
  15. data/plugins/gcov/lib/reportgenerator_reportinator.rb +1 -1
  16. data/plugins/junit_tests_report/lib/junit_tests_report.rb +6 -6
  17. data/plugins/module_generator/README.md +16 -2
  18. data/plugins/module_generator/lib/module_generator.rb +1 -0
  19. data/spec/gcov/gcov_deployment_spec.rb +1 -1
  20. data/spec/preprocessinator_includes_handler_spec.rb +38 -8
  21. data/spec/spec_system_helper.rb +19 -0
  22. data/spec/system/deployment_spec.rb +1 -0
  23. data/vendor/cmock/lib/cmock_file_writer.rb +2 -3
  24. data/vendor/cmock/lib/cmock_generator.rb +87 -70
  25. data/vendor/cmock/lib/cmock_header_parser.rb +29 -27
  26. data/vendor/cmock/src/cmock.h +1 -1
  27. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +46 -41
  28. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +46 -40
  29. data/vendor/cmock/vendor/c_exception/README.md +6 -4
  30. data/vendor/cmock/vendor/c_exception/docs/CException.md +2 -2
  31. data/vendor/cmock/vendor/c_exception/lib/CException.h +1 -1
  32. data/vendor/cmock/vendor/c_exception/lib/meson.build +2 -2
  33. data/vendor/cmock/vendor/c_exception/meson.build +36 -2
  34. data/vendor/cmock/vendor/unity/README.md +77 -71
  35. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
  36. data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
  37. data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +149 -193
  38. data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
  39. data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
  40. data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
  41. data/vendor/cmock/vendor/unity/extras/fixture/readme.md +16 -19
  42. data/vendor/cmock/vendor/unity/extras/memory/readme.md +27 -34
  43. data/vendor/cmock/vendor/unity/src/unity.c +1 -1
  44. data/vendor/cmock/vendor/unity/src/unity.h +1 -1
  45. data/vendor/cmock/vendor/unity/src/unity_internals.h +21 -7
  46. data/vendor/unity/README.md +77 -71
  47. data/vendor/unity/auto/generate_test_runner.rb +1 -1
  48. data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
  49. data/vendor/unity/docs/UnityAssertionsReference.md +149 -193
  50. data/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
  51. data/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
  52. data/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
  53. data/vendor/unity/extras/fixture/readme.md +16 -19
  54. data/vendor/unity/extras/memory/readme.md +27 -34
  55. data/vendor/unity/src/unity.c +1 -1
  56. data/vendor/unity/src/unity.h +1 -1
  57. data/vendor/unity/src/unity_internals.h +21 -7
  58. metadata +14 -5
  59. data/plugins/gcov/config/defaults.yml +0 -55
@@ -2,133 +2,118 @@
2
2
 
3
3
  ## C Standards, Compilers and Microcontrollers
4
4
 
5
- The embedded software world contains its challenges. Compilers support different
6
- revisions of the C Standard. They ignore requirements in places, sometimes to
7
- make the language more usable in some special regard. Sometimes it's to simplify
8
- their support. Sometimes it's due to specific quirks of the microcontroller they
9
- are targeting. Simulators add another dimension to this menagerie.
10
-
11
- Unity is designed to run on almost anything that is targeted by a C compiler. It
12
- would be awesome if this could be done with zero configuration. While there are
13
- some targets that come close to this dream, it is sadly not universal. It is
14
- likely that you are going to need at least a couple of the configuration options
15
- described in this document.
16
-
17
- All of Unity's configuration options are `#defines`. Most of these are simple
18
- definitions. A couple are macros with arguments. They live inside the
19
- unity_internals.h header file. We don't necessarily recommend opening that file
20
- unless you really need to. That file is proof that a cross-platform library is
21
- challenging to build. From a more positive perspective, it is also proof that a
22
- great deal of complexity can be centralized primarily to one place to
23
- provide a more consistent and simple experience elsewhere.
24
-
5
+ The embedded software world contains its challenges.
6
+ Compilers support different revisions of the C Standard.
7
+ They ignore requirements in places, sometimes to make the language more usable in some special regard.
8
+ Sometimes it's to simplify their support.
9
+ Sometimes it's due to specific quirks of the microcontroller they are targeting.
10
+ Simulators add another dimension to this menagerie.
11
+
12
+ Unity is designed to run on almost anything that is targeted by a C compiler.
13
+ It would be awesome if this could be done with zero configuration.
14
+ While there are some targets that come close to this dream, it is sadly not universal.
15
+ It is likely that you are going to need at least a couple of the configuration options described in this document.
16
+
17
+ All of Unity's configuration options are `#defines`.
18
+ Most of these are simple definitions.
19
+ A couple are macros with arguments.
20
+ They live inside the unity_internals.h header file.
21
+ We don't necessarily recommend opening that file unless you really need to.
22
+ That file is proof that a cross-platform library is challenging to build.
23
+ From a more positive perspective, it is also proof that a great deal of complexity can be centralized primarily to one place to provide a more consistent and simple experience elsewhere.
25
24
 
26
25
  ### Using These Options
27
26
 
28
- It doesn't matter if you're using a target-specific compiler and a simulator or
29
- a native compiler. In either case, you've got a couple choices for configuring
30
- these options:
31
-
32
- 1. Because these options are specified via C defines, you can pass most of these
33
- options to your compiler through command line compiler flags. Even if you're
34
- using an embedded target that forces you to use their overbearing IDE for all
35
- configuration, there will be a place somewhere in your project to configure
36
- defines for your compiler.
37
- 2. You can create a custom `unity_config.h` configuration file (present in your
38
- toolchain's search paths). In this file, you will list definitions and macros
39
- specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and
40
- Unity will rely on `unity_config.h` for any further definitions it may need.
41
-
42
- Unfortunately, it doesn't usually work well to just #define these things in the
43
- test itself. These defines need to take effect where ever unity.h is included.
44
- This would be test test, the test runner (if you're generating one), and from
45
- unity.c when it's compiled.
27
+ It doesn't matter if you're using a target-specific compiler and a simulator or a native compiler.
28
+ In either case, you've got a couple choices for configuring these options:
29
+
30
+ 1. Because these options are specified via C defines, you can pass most of these options to your compiler through command line compiler flags. Even if you're using an embedded target that forces you to use their overbearing IDE for all configuration, there will be a place somewhere in your project to configure defines for your compiler.
31
+ 2. You can create a custom `unity_config.h` configuration file (present in your toolchain's search paths).
32
+ In this file, you will list definitions and macros specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any further definitions it may need.
33
+
34
+ Unfortunately, it doesn't usually work well to just #define these things in the test itself.
35
+ These defines need to take effect where ever unity.h is included.
36
+ This would be test test, the test runner (if you're generating one), and from unity.c when it's compiled.
46
37
 
47
38
  ## The Options
48
39
 
49
40
  ### Integer Types
50
41
 
51
- If you've been a C developer for long, you probably already know that C's
52
- concept of an integer varies from target to target. The C Standard has rules
53
- about the `int` matching the register size of the target microprocessor. It has
54
- rules about the `int` and how its size relates to other integer types. An `int`
55
- on one target might be 16 bits while on another target it might be 64. There are
56
- more specific types in compilers compliant with C99 or later, but that's
57
- certainly not every compiler you are likely to encounter. Therefore, Unity has a
58
- number of features for helping to adjust itself to match your required integer
59
- sizes. It starts off by trying to do it automatically.
60
-
42
+ If you've been a C developer for long, you probably already know that C's concept of an integer varies from target to target.
43
+ The C Standard has rules about the `int` matching the register size of the target microprocessor.
44
+ It has rules about the `int` and how its size relates to other integer types.
45
+ An `int` on one target might be 16 bits while on another target it might be 64.
46
+ There are more specific types in compilers compliant with C99 or later, but that's certainly not every compiler you are likely to encounter.
47
+ Therefore, Unity has a number of features for helping to adjust itself to match your required integer sizes.
48
+ It starts off by trying to do it automatically.
61
49
 
62
- ##### `UNITY_EXCLUDE_STDINT_H`
50
+ #### `UNITY_EXCLUDE_STDINT_H`
63
51
 
64
52
  The first thing that Unity does to guess your types is check `stdint.h`.
65
- This file includes defines like `UINT_MAX` that Unity can use to
66
- learn a lot about your system. It's possible you don't want it to do this
67
- (um. why not?) or (more likely) it's possible that your system doesn't
68
- support `stdint.h`. If that's the case, you're going to want to define this.
69
- That way, Unity will know to skip the inclusion of this file and you won't
70
- be left with a compiler error.
53
+ This file includes defines like `UINT_MAX` that Unity can use to learn a lot about your system.
54
+ It's possible you don't want it to do this (um. why not?) or (more likely) it's possible that your system doesn't support `stdint.h`.
55
+ If that's the case, you're going to want to define this.
56
+ That way, Unity will know to skip the inclusion of this file and you won't be left with a compiler error.
71
57
 
72
58
  _Example:_
59
+
73
60
  ```C
74
61
  #define UNITY_EXCLUDE_STDINT_H
75
62
  ```
76
63
 
64
+ #### `UNITY_EXCLUDE_LIMITS_H`
77
65
 
78
- ##### `UNITY_EXCLUDE_LIMITS_H`
79
-
80
- The second attempt to guess your types is to check `limits.h`. Some compilers
81
- that don't support `stdint.h` could include `limits.h` instead. If you don't
82
- want Unity to check this file either, define this to make it skip the inclusion.
66
+ The second attempt to guess your types is to check `limits.h`.
67
+ Some compilers that don't support `stdint.h` could include `limits.h` instead.
68
+ If you don't want Unity to check this file either, define this to make it skip the inclusion.
83
69
 
84
70
  _Example:_
71
+
85
72
  ```C
86
73
  #define UNITY_EXCLUDE_LIMITS_H
87
74
  ```
88
75
 
89
- If you've disabled both of the automatic options above, you're going to have to
90
- do the configuration yourself. Don't worry. Even this isn't too bad... there are
91
- just a handful of defines that you are going to specify if you don't like the
92
- defaults.
76
+ If you've disabled both of the automatic options above, you're going to have to do the configuration yourself.
77
+ Don't worry.
78
+ Even this isn't too bad... there are just a handful of defines that you are going to specify if you don't like the defaults.
93
79
 
80
+ #### `UNITY_INT_WIDTH`
94
81
 
95
- ##### `UNITY_INT_WIDTH`
96
-
97
- Define this to be the number of bits an `int` takes up on your system. The
98
- default, if not autodetected, is 32 bits.
82
+ Define this to be the number of bits an `int` takes up on your system.
83
+ The default, if not autodetected, is 32 bits.
99
84
 
100
85
  _Example:_
86
+
101
87
  ```C
102
88
  #define UNITY_INT_WIDTH 16
103
89
  ```
104
90
 
91
+ #### `UNITY_LONG_WIDTH`
105
92
 
106
- ##### `UNITY_LONG_WIDTH`
107
-
108
- Define this to be the number of bits a `long` takes up on your system. The
109
- default, if not autodetected, is 32 bits. This is used to figure out what kind
110
- of 64-bit support your system can handle. Does it need to specify a `long` or a
111
- `long long` to get a 64-bit value. On 16-bit systems, this option is going to be
112
- ignored.
93
+ Define this to be the number of bits a `long` takes up on your system.
94
+ The default, if not autodetected, is 32 bits.
95
+ This is used to figure out what kind of 64-bit support your system can handle.
96
+ Does it need to specify a `long` or a `long long` to get a 64-bit value.
97
+ On 16-bit systems, this option is going to be ignored.
113
98
 
114
99
  _Example:_
100
+
115
101
  ```C
116
102
  #define UNITY_LONG_WIDTH 16
117
103
  ```
118
104
 
105
+ #### `UNITY_POINTER_WIDTH`
119
106
 
120
- ##### `UNITY_POINTER_WIDTH`
121
-
122
- Define this to be the number of bits a pointer takes up on your system. The
123
- default, if not autodetected, is 32-bits. If you're getting ugly compiler
124
- warnings about casting from pointers, this is the one to look at.
107
+ Define this to be the number of bits a pointer takes up on your system.
108
+ The default, if not autodetected, is 32-bits.
109
+ If you're getting ugly compiler warnings about casting from pointers, this is the one to look at.
125
110
 
126
- _Hint:_ In order to support exotic processors (for example TI C55x with a pointer
127
- width of 23-bit), choose the next power of two (in this case 32-bit).
111
+ _Hint:_ In order to support exotic processors (for example TI C55x with a pointer width of 23-bit), choose the next power of two (in this case 32-bit).
128
112
 
129
113
  _Supported values:_ 16, 32 and 64
130
114
 
131
115
  _Example:_
116
+
132
117
  ```C
133
118
  // Choose on of these #defines to set your pointer width (if not autodetected)
134
119
  //#define UNITY_POINTER_WIDTH 16
@@ -136,137 +121,117 @@ _Example:_
136
121
  #define UNITY_POINTER_WIDTH 64 // Set UNITY_POINTER_WIDTH to 64-bit
137
122
  ```
138
123
 
124
+ #### `UNITY_SUPPORT_64`
139
125
 
140
- ##### `UNITY_SUPPORT_64`
141
-
142
- Unity will automatically include 64-bit support if it auto-detects it, or if
143
- your `int`, `long`, or pointer widths are greater than 32-bits. Define this to
144
- enable 64-bit support if none of the other options already did it for you. There
145
- can be a significant size and speed impact to enabling 64-bit support on small
146
- targets, so don't define it if you don't need it.
126
+ Unity will automatically include 64-bit support if it auto-detects it, or if your `int`, `long`, or pointer widths are greater than 32-bits.
127
+ Define this to enable 64-bit support if none of the other options already did it for you.
128
+ There can be a significant size and speed impact to enabling 64-bit support on small targets, so don't define it if you don't need it.
147
129
 
148
130
  _Example:_
131
+
149
132
  ```C
150
133
  #define UNITY_SUPPORT_64
151
134
  ```
152
135
 
153
-
154
136
  ### Floating Point Types
155
137
 
156
- In the embedded world, it's not uncommon for targets to have no support for
157
- floating point operations at all or to have support that is limited to only
158
- single precision. We are able to guess integer sizes on the fly because integers
159
- are always available in at least one size. Floating point, on the other hand, is
160
- sometimes not available at all. Trying to include `float.h` on these platforms
161
- would result in an error. This leaves manual configuration as the only option.
138
+ In the embedded world, it's not uncommon for targets to have no support for floating point operations at all or to have support that is limited to only single precision.
139
+ We are able to guess integer sizes on the fly because integers are always available in at least one size.
140
+ Floating point, on the other hand, is sometimes not available at all.
141
+ Trying to include `float.h` on these platforms would result in an error. This leaves manual configuration as the only option.
162
142
 
143
+ #### `UNITY_INCLUDE_FLOAT`
163
144
 
164
- ##### `UNITY_INCLUDE_FLOAT`
145
+ #### `UNITY_EXCLUDE_FLOAT`
165
146
 
166
- ##### `UNITY_EXCLUDE_FLOAT`
147
+ #### `UNITY_INCLUDE_DOUBLE`
167
148
 
168
- ##### `UNITY_INCLUDE_DOUBLE`
149
+ #### `UNITY_EXCLUDE_DOUBLE`
169
150
 
170
- ##### `UNITY_EXCLUDE_DOUBLE`
171
-
172
- By default, Unity guesses that you will want single precision floating point
173
- support, but not double precision. It's easy to change either of these using the
174
- include and exclude options here. You may include neither, either, or both, as
175
- suits your needs. For features that are enabled, the following floating point
176
- options also become available.
151
+ By default, Unity guesses that you will want single precision floating point support, but not double precision.
152
+ It's easy to change either of these using the include and exclude options here.
153
+ You may include neither, either, or both, as suits your needs.
154
+ For features that are enabled, the following floating point options also become available.
177
155
 
178
156
  _Example:_
157
+
179
158
  ```C
180
159
  //what manner of strange processor is this?
181
160
  #define UNITY_EXCLUDE_FLOAT
182
161
  #define UNITY_INCLUDE_DOUBLE
183
162
  ```
184
163
 
164
+ #### `UNITY_EXCLUDE_FLOAT_PRINT`
185
165
 
186
- ##### `UNITY_EXCLUDE_FLOAT_PRINT`
187
-
188
- Unity aims for as small of a footprint as possible and avoids most standard
189
- library calls (some embedded platforms don’t have a standard library!). Because
190
- of this, its routines for printing integer values are minimalist and hand-coded.
166
+ Unity aims for as small of a footprint as possible and avoids most standard library calls (some embedded platforms don’t have a standard library!).
167
+ Because of this, its routines for printing integer values are minimalist and hand-coded.
191
168
  Therefore, the display of floating point values during a failure are optional.
192
- By default, Unity will print the actual results of floating point assertion
193
- failure (e.g. ”Expected 4.56 Was 4.68”). To not include this extra support, you
194
- can use this define to instead respond to a failed assertion with a message like
195
- ”Values Not Within Delta”. If you would like verbose failure messages for floating
196
- point assertions, use these options to give more explicit failure messages.
169
+ By default, Unity will print the actual results of floating point assertion failure (e.g. ”Expected 4.56 Was 4.68”).
170
+ To not include this extra support, you can use this define to instead respond to a failed assertion with a message like ”Values Not Within Delta”.
171
+ If you would like verbose failure messages for floating point assertions, use these options to give more explicit failure messages.
197
172
 
198
173
  _Example:_
174
+
199
175
  ```C
200
176
  #define UNITY_EXCLUDE_FLOAT_PRINT
201
177
  ```
202
178
 
179
+ #### `UNITY_FLOAT_TYPE`
203
180
 
204
- ##### `UNITY_FLOAT_TYPE`
205
-
206
- If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C
207
- floats. If your compiler supports a specialty floating point type, you can
208
- always override this behavior by using this definition.
181
+ If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C floats.
182
+ If your compiler supports a specialty floating point type, you can always override this behavior by using this definition.
209
183
 
210
184
  _Example:_
185
+
211
186
  ```C
212
187
  #define UNITY_FLOAT_TYPE float16_t
213
188
  ```
214
189
 
190
+ #### `UNITY_DOUBLE_TYPE`
215
191
 
216
- ##### `UNITY_DOUBLE_TYPE`
217
-
218
- If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard C
219
- doubles. If you would like to change this, you can specify something else by
220
- using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long double`
221
- could enable gargantuan floating point types on your 64-bit processor instead of
222
- the standard `double`.
192
+ If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard C doubles.
193
+ If you would like to change this, you can specify something else by using this option.
194
+ For example, defining `UNITY_DOUBLE_TYPE` to `long double` could enable gargantuan floating point types on your 64-bit processor instead of the standard `double`.
223
195
 
224
196
  _Example:_
197
+
225
198
  ```C
226
199
  #define UNITY_DOUBLE_TYPE long double
227
200
  ```
228
201
 
202
+ #### `UNITY_FLOAT_PRECISION`
229
203
 
230
- ##### `UNITY_FLOAT_PRECISION`
231
-
232
- ##### `UNITY_DOUBLE_PRECISION`
204
+ #### `UNITY_DOUBLE_PRECISION`
233
205
 
234
- If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as
235
- documented in the big daddy Unity Assertion Guide, you will learn that they are
236
- not really asserting that two values are equal but rather that two values are
237
- "close enough" to equal. "Close enough" is controlled by these precision
238
- configuration options. If you are working with 32-bit floats and/or 64-bit
239
- doubles (the normal on most processors), you should have no need to change these
240
- options. They are both set to give you approximately 1 significant bit in either
241
- direction. The float precision is 0.00001 while the double is 10-12.
242
- For further details on how this works, see the appendix of the Unity Assertion
243
- Guide.
206
+ If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as documented in the big daddy Unity Assertion Guide, you will learn that they are not really asserting that two values are equal but rather that two values are "close enough" to equal.
207
+ "Close enough" is controlled by these precision configuration options.
208
+ If you are working with 32-bit floats and/or 64-bit doubles (the normal on most processors), you should have no need to change these options.
209
+ They are both set to give you approximately 1 significant bit in either direction.
210
+ The float precision is 0.00001 while the double is 10-12.
211
+ For further details on how this works, see the appendix of the Unity Assertion Guide.
244
212
 
245
213
  _Example:_
214
+
246
215
  ```C
247
216
  #define UNITY_FLOAT_PRECISION 0.001f
248
217
  ```
249
218
 
250
-
251
219
  ### Miscellaneous
252
220
 
253
- ##### `UNITY_EXCLUDE_STDDEF_H`
221
+ #### `UNITY_EXCLUDE_STDDEF_H`
254
222
 
255
- Unity uses the `NULL` macro, which defines the value of a null pointer constant,
256
- defined in `stddef.h` by default. If you want to provide
257
- your own macro for this, you should exclude the `stddef.h` header file by adding this
258
- define to your configuration.
223
+ Unity uses the `NULL` macro, which defines the value of a null pointer constant, defined in `stddef.h` by default.
224
+ If you want to provide your own macro for this, you should exclude the `stddef.h` header file by adding this define to your configuration.
259
225
 
260
226
  _Example:_
227
+
261
228
  ```C
262
229
  #define UNITY_EXCLUDE_STDDEF_H
263
230
  ```
264
231
 
265
-
266
232
  #### `UNITY_INCLUDE_PRINT_FORMATTED`
267
233
 
268
- Unity provides a simple (and very basic) printf-like string output implementation,
269
- which is able to print a string modified by the following format string modifiers:
234
+ Unity provides a simple (and very basic) printf-like string output implementation, which is able to print a string modified by the following format string modifiers:
270
235
 
271
236
  - __%d__ - signed value (decimal)
272
237
  - __%i__ - same as __%i__
@@ -282,6 +247,7 @@ which is able to print a string modified by the following format string modifier
282
247
  - __%%__ - The "%" symbol (escaped)
283
248
 
284
249
  _Example:_
250
+
285
251
  ```C
286
252
  #define UNITY_INCLUDE_PRINT_FORMATTED
287
253
 
@@ -300,39 +266,32 @@ TEST_PRINTF("\n");
300
266
  TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345);
301
267
  ```
302
268
 
303
-
304
269
  ### Toolset Customization
305
270
 
306
- In addition to the options listed above, there are a number of other options
307
- which will come in handy to customize Unity's behavior for your specific
308
- toolchain. It is possible that you may not need to touch any of these... but
309
- certain platforms, particularly those running in simulators, may need to jump
310
- through extra hoops to run properly. These macros will help in those
311
- situations.
312
-
271
+ In addition to the options listed above, there are a number of other options which will come in handy to customize Unity's behavior for your specific toolchain.
272
+ It is possible that you may not need to touch any of these... but certain platforms, particularly those running in simulators, may need to jump through extra hoops to run properly.
273
+ These macros will help in those situations.
313
274
 
314
- ##### `UNITY_OUTPUT_CHAR(a)`
275
+ #### `UNITY_OUTPUT_CHAR(a)`
315
276
 
316
- ##### `UNITY_OUTPUT_FLUSH()`
277
+ #### `UNITY_OUTPUT_FLUSH()`
317
278
 
318
- ##### `UNITY_OUTPUT_START()`
279
+ #### `UNITY_OUTPUT_START()`
319
280
 
320
- ##### `UNITY_OUTPUT_COMPLETE()`
281
+ #### `UNITY_OUTPUT_COMPLETE()`
321
282
 
322
- By default, Unity prints its results to `stdout` as it runs. This works
323
- perfectly fine in most situations where you are using a native compiler for
324
- testing. It works on some simulators as well so long as they have `stdout`
325
- routed back to the command line. There are times, however, where the simulator
326
- will lack support for dumping results or you will want to route results
327
- elsewhere for other reasons. In these cases, you should define the
328
- `UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time (as
329
- an `int`, since this is the parameter type of the standard C `putchar` function
330
- most commonly used). You may replace this with whatever function call you like.
283
+ By default, Unity prints its results to `stdout` as it runs.
284
+ This works perfectly fine in most situations where you are using a native compiler for testing.
285
+ It works on some simulators as well so long as they have `stdout` routed back to the command line.
286
+ There are times, however, where the simulator will lack support for dumping results or you will want to route results elsewhere for other reasons.
287
+ In these cases, you should define the `UNITY_OUTPUT_CHAR` macro.
288
+ This macro accepts a single character at a time (as an `int`, since this is the parameter type of the standard C `putchar` function most commonly used).
289
+ You may replace this with whatever function call you like.
331
290
 
332
291
  _Example:_
333
- Say you are forced to run your test suite on an embedded processor with no
334
- `stdout` option. You decide to route your test result output to a custom serial
335
- `RS232_putc()` function you wrote like thus:
292
+ Say you are forced to run your test suite on an embedded processor with no `stdout` option.
293
+ You decide to route your test result output to a custom serial `RS232_putc()` function you wrote like thus:
294
+
336
295
  ```C
337
296
  #include "RS232_header.h"
338
297
  ...
@@ -343,67 +302,63 @@ Say you are forced to run your test suite on an embedded processor with no
343
302
  ```
344
303
 
345
304
  _Note:_
346
- `UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by
347
- specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required.
348
-
349
-
350
- ##### `UNITY_OUTPUT_FOR_ECLIPSE`
305
+ `UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by specifying `UNITY_USE_FLUSH_STDOUT`.
306
+ No other defines are required.
351
307
 
352
- ##### `UNITY_OUTPUT_FOR_IAR_WORKBENCH`
308
+ #### `UNITY_OUTPUT_FOR_ECLIPSE`
353
309
 
354
- ##### `UNITY_OUTPUT_FOR_QT_CREATOR`
310
+ #### `UNITY_OUTPUT_FOR_IAR_WORKBENCH`
355
311
 
356
- When managing your own builds, it is often handy to have messages output in a format which is
357
- recognized by your IDE. These are some standard formats which can be supported. If you're using
358
- Ceedling to manage your builds, it is better to stick with the standard format (leaving these
359
- all undefined) and allow Ceedling to use its own decorators.
312
+ #### `UNITY_OUTPUT_FOR_QT_CREATOR`
360
313
 
314
+ When managing your own builds, it is often handy to have messages output in a format which is recognized by your IDE.
315
+ These are some standard formats which can be supported.
316
+ If you're using Ceedling to manage your builds, it is better to stick with the standard format (leaving these all undefined) and allow Ceedling to use its own decorators.
361
317
 
362
- ##### `UNITY_PTR_ATTRIBUTE`
318
+ #### `UNITY_PTR_ATTRIBUTE`
363
319
 
364
- Some compilers require a custom attribute to be assigned to pointers, like
365
- `near` or `far`. In these cases, you can give Unity a safe default for these by
366
- defining this option with the attribute you would like.
320
+ Some compilers require a custom attribute to be assigned to pointers, like `near` or `far`.
321
+ In these cases, you can give Unity a safe default for these by defining this option with the attribute you would like.
367
322
 
368
323
  _Example:_
324
+
369
325
  ```C
370
326
  #define UNITY_PTR_ATTRIBUTE __attribute__((far))
371
327
  #define UNITY_PTR_ATTRIBUTE near
372
328
  ```
373
329
 
374
- ##### `UNITY_PRINT_EOL`
330
+ #### `UNITY_PRINT_EOL`
375
331
 
376
- By default, Unity outputs \n at the end of each line of output. This is easy
377
- to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR
378
- system. Feel free to override this and to make it whatever you wish.
332
+ By default, Unity outputs \n at the end of each line of output.
333
+ This is easy to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR system.
334
+ Feel free to override this and to make it whatever you wish.
379
335
 
380
336
  _Example:_
337
+
381
338
  ```C
382
- #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') }
339
+ #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n'); }
383
340
  ```
384
341
 
342
+ #### `UNITY_EXCLUDE_DETAILS`
385
343
 
386
- ##### `UNITY_EXCLUDE_DETAILS`
387
-
388
- This is an option for if you absolutely must squeeze every byte of memory out of
389
- your system. Unity stores a set of internal scratchpads which are used to pass
390
- extra detail information around. It's used by systems like CMock in order to
391
- report which function or argument flagged an error. If you're not using CMock and
392
- you're not using these details for other things, then you can exclude them.
344
+ This is an option for if you absolutely must squeeze every byte of memory out of your system.
345
+ Unity stores a set of internal scratchpads which are used to pass extra detail information around.
346
+ It's used by systems like CMock in order to report which function or argument flagged an error.
347
+ If you're not using CMock and you're not using these details for other things, then you can exclude them.
393
348
 
394
349
  _Example:_
350
+
395
351
  ```C
396
352
  #define UNITY_EXCLUDE_DETAILS
397
353
  ```
398
354
 
399
- ##### `UNITY_PRINT_TEST_CONTEXT`
355
+ #### `UNITY_PRINT_TEST_CONTEXT`
400
356
 
401
- This option allows you to specify your own function to print additional context
402
- as part of the error message when a test has failed. It can be useful if you
403
- want to output some specific information about the state of the test at the point
404
- of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs.
357
+ This option allows you to specify your own function to print additional context as part of the error message when a test has failed.
358
+ It can be useful if you want to output some specific information about the state of the test at the point of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs.
405
359
 
406
360
  _Example:_
361
+
407
362
  ```C
408
363
  #define UNITY_PRINT_TEST_CONTEXT PrintIterationCount
409
364
 
@@ -415,82 +370,74 @@ void PrintIterationCount(void)
415
370
  }
416
371
  ```
417
372
 
418
- ##### `UNITY_EXCLUDE_SETJMP`
373
+ #### `UNITY_EXCLUDE_SETJMP`
419
374
 
420
- If your embedded system doesn't support the standard library setjmp, you can
421
- exclude Unity's reliance on this by using this define. This dropped dependence
422
- comes at a price, though. You will be unable to use custom helper functions for
423
- your tests, and you will be unable to use tools like CMock. Very likely, if your
424
- compiler doesn't support setjmp, you wouldn't have had the memory space for those
425
- things anyway, though... so this option exists for those situations.
375
+ If your embedded system doesn't support the standard library setjmp, you can exclude Unity's reliance on this by using this define.
376
+ This dropped dependence comes at a price, though.
377
+ You will be unable to use custom helper functions for your tests, and you will be unable to use tools like CMock.
378
+ Very likely, if your compiler doesn't support setjmp, you wouldn't have had the memory space for those things anyway, though... so this option exists for those situations.
426
379
 
427
380
  _Example:_
381
+
428
382
  ```C
429
383
  #define UNITY_EXCLUDE_SETJMP
430
384
  ```
431
385
 
432
- ##### `UNITY_OUTPUT_COLOR`
386
+ #### `UNITY_OUTPUT_COLOR`
433
387
 
434
388
  If you want to add color using ANSI escape codes you can use this define.
435
389
 
436
390
  _Example:_
391
+
437
392
  ```C
438
393
  #define UNITY_OUTPUT_COLOR
439
394
  ```
440
395
 
441
- ##### `UNITY_SHORTHAND_AS_INT`
442
- ##### `UNITY_SHORTHAND_AS_MEM`
443
- ##### `UNITY_SHORTHAND_AS_RAW`
444
- ##### `UNITY_SHORTHAND_AS_NONE`
445
-
446
- These options give you control of the `TEST_ASSERT_EQUAL` and the
447
- `TEST_ASSERT_NOT_EQUAL` shorthand assertions. Historically, Unity treated the
448
- former as an alias for an integer comparison. It treated the latter as a direct
449
- comparison using `!=`. This assymetry was confusing, but there was much
450
- disagreement as to how best to treat this pair of assertions. These four options
451
- will allow you to specify how Unity will treat these assertions.
452
-
453
- - AS INT - the values will be cast to integers and directly compared. Arguments
454
- that don't cast easily to integers will cause compiler errors.
455
- - AS MEM - the address of both values will be taken and the entire object's
456
- memory footprint will be compared byte by byte. Directly placing
457
- constant numbers like `456` as expected values will cause errors.
458
- - AS_RAW - Unity assumes that you can compare the two values using `==` and `!=`
459
- and will do so. No details are given about mismatches, because it
460
- doesn't really know what type it's dealing with.
461
- - AS_NONE - Unity will disallow the use of these shorthand macros altogether,
462
- insisting that developers choose a more descriptive option.
396
+ #### `UNITY_SHORTHAND_AS_INT`
397
+
398
+ #### `UNITY_SHORTHAND_AS_MEM`
399
+
400
+ #### `UNITY_SHORTHAND_AS_RAW`
401
+
402
+ #### `UNITY_SHORTHAND_AS_NONE`
403
+
404
+ These options give you control of the `TEST_ASSERT_EQUAL` and the `TEST_ASSERT_NOT_EQUAL` shorthand assertions.
405
+ Historically, Unity treated the former as an alias for an integer comparison.
406
+ It treated the latter as a direct comparison using `!=`.
407
+ This asymmetry was confusing, but there was much disagreement as to how best to treat this pair of assertions.
408
+ These four options will allow you to specify how Unity will treat these assertions.
409
+
410
+ - AS INT - the values will be cast to integers and directly compared.
411
+ Arguments that don't cast easily to integers will cause compiler errors.
412
+ - AS MEM - the address of both values will be taken and the entire object's memory footprint will be compared byte by byte.
413
+ Directly placing constant numbers like `456` as expected values will cause errors.
414
+ - AS_RAW - Unity assumes that you can compare the two values using `==` and `!=` and will do so.
415
+ No details are given about mismatches, because it doesn't really know what type it's dealing with.
416
+ - AS_NONE - Unity will disallow the use of these shorthand macros altogether, insisting that developers choose a more descriptive option.
463
417
 
464
418
  #### `UNITY_SUPPORT_VARIADIC_MACROS`
465
419
 
466
- This will force Unity to support variadic macros when using its own built-in
467
- RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically
468
- detect if the compiler supports variadic macros by checking to see if it's C99+
469
- compatible. In the event that the compiler supports variadic macros, but is primarily
470
- C89 (ANSI), defining this option will allow you to use them. This option is also not
471
- necessary when using Ceedling or the test runner generator script.
420
+ This will force Unity to support variadic macros when using its own built-in RUN_TEST macro.
421
+ This will rarely be necessary. Most often, Unity will automatically detect if the compiler supports variadic macros by checking to see if it's C99+ compatible.
422
+ In the event that the compiler supports variadic macros, but is primarily C89 (ANSI), defining this option will allow you to use them.
423
+ This option is also not necessary when using Ceedling or the test runner generator script.
472
424
 
473
425
  ## Getting Into The Guts
474
426
 
475
- There will be cases where the options above aren't quite going to get everything
476
- perfect. They are likely sufficient for any situation where you are compiling
477
- and executing your tests with a native toolchain (e.g. clang on Mac). These
478
- options may even get you through the majority of cases encountered in working
479
- with a target simulator run from your local command line. But especially if you
480
- must run your test suite on your target hardware, your Unity configuration will
481
- require special help. This special help will usually reside in one of two
482
- places: the `main()` function or the `RUN_TEST` macro. Let's look at how these
483
- work.
427
+ There will be cases where the options above aren't quite going to get everything perfect.
428
+ They are likely sufficient for any situation where you are compiling and executing your tests with a native toolchain (e.g. clang on Mac).
429
+ These options may even get you through the majority of cases encountered in working with a target simulator run from your local command line.
430
+ But especially if you must run your test suite on your target hardware, your Unity configuration will
431
+ require special help.
432
+ This special help will usually reside in one of two places: the `main()` function or the `RUN_TEST` macro.
433
+ Let's look at how these work.
484
434
 
435
+ ### `main()`
485
436
 
486
- ##### `main()`
487
-
488
- Each test module is compiled and run on its own, separate from the other test
489
- files in your project. Each test file, therefore, has a `main` function. This
490
- `main` function will need to contain whatever code is necessary to initialize
491
- your system to a workable state. This is particularly true for situations where
492
- you must set up a memory map or initialize a communication channel for the
493
- output of your test results.
437
+ Each test module is compiled and run on its own, separate from the other test files in your project.
438
+ Each test file, therefore, has a `main` function.
439
+ This `main` function will need to contain whatever code is necessary to initialize your system to a workable state.
440
+ This is particularly true for situations where you must set up a memory map or initialize a communication channel for the output of your test results.
494
441
 
495
442
  A simple main function looks something like this:
496
443
 
@@ -504,26 +451,22 @@ int main(void) {
504
451
  }
505
452
  ```
506
453
 
507
- You can see that our main function doesn't bother taking any arguments. For our
508
- most barebones case, we'll never have arguments because we just run all the
509
- tests each time. Instead, we start by calling `UNITY_BEGIN`. We run each test
510
- (in whatever order we wish). Finally, we call `UNITY_END`, returning its return
511
- value (which is the total number of failures).
512
-
513
- It should be easy to see that you can add code before any test cases are run or
514
- after all the test cases have completed. This allows you to do any needed
515
- system-wide setup or teardown that might be required for your special
516
- circumstances.
454
+ You can see that our main function doesn't bother taking any arguments.
455
+ For our most barebones case, we'll never have arguments because we just run all the tests each time.
456
+ Instead, we start by calling `UNITY_BEGIN`.
457
+ We run each test (in whatever order we wish).
458
+ Finally, we call `UNITY_END`, returning its return value (which is the total number of failures).
517
459
 
460
+ It should be easy to see that you can add code before any test cases are run or after all the test cases have completed.
461
+ This allows you to do any needed system-wide setup or teardown that might be required for your special circumstances.
518
462
 
519
- ##### `RUN_TEST`
463
+ #### `RUN_TEST`
520
464
 
521
- The `RUN_TEST` macro is called with each test case function. Its job is to
522
- perform whatever setup and teardown is necessary for executing a single test
523
- case function. This includes catching failures, calling the test module's
524
- `setUp()` and `tearDown()` functions, and calling `UnityConcludeTest()`. If
525
- using CMock or test coverage, there will be additional stubs in use here. A
526
- simple minimalist RUN_TEST macro looks something like this:
465
+ The `RUN_TEST` macro is called with each test case function.
466
+ Its job is to perform whatever setup and teardown is necessary for executing a single test case function.
467
+ This includes catching failures, calling the test module's `setUp()` and `tearDown()` functions, and calling `UnityConcludeTest()`.
468
+ If using CMock or test coverage, there will be additional stubs in use here.
469
+ A simple minimalist RUN_TEST macro looks something like this:
527
470
 
528
471
  ```C
529
472
  #define RUN_TEST(testfunc) \
@@ -537,27 +480,26 @@ simple minimalist RUN_TEST macro looks something like this:
537
480
  UnityConcludeTest();
538
481
  ```
539
482
 
540
- So that's quite a macro, huh? It gives you a glimpse of what kind of stuff Unity
541
- has to deal with for every single test case. For each test case, we declare that
542
- it is a new test. Then we run `setUp` and our test function. These are run
543
- within a `TEST_PROTECT` block, the function of which is to handle failures that
544
- occur during the test. Then, assuming our test is still running and hasn't been
545
- ignored, we run `tearDown`. No matter what, our last step is to conclude this
546
- test before moving on to the next.
547
-
548
- Let's say you need to add a call to `fsync` to force all of your output data to
549
- flush to a file after each test. You could easily insert this after your
550
- `UnityConcludeTest` call. Maybe you want to write an xml tag before and after
551
- each result set. Again, you could do this by adding lines to this macro. Updates
552
- to this macro are for the occasions when you need an action before or after
553
- every single test case throughout your entire suite of tests.
483
+ So that's quite a macro, huh?
484
+ It gives you a glimpse of what kind of stuff Unity has to deal with for every single test case.
485
+ For each test case, we declare that it is a new test.
486
+ Then we run `setUp` and our test function.
487
+ These are run within a `TEST_PROTECT` block, the function of which is to handle failures that occur during the test.
488
+ Then, assuming our test is still running and hasn't been ignored, we run `tearDown`.
489
+ No matter what, our last step is to conclude this test before moving on to the next.
554
490
 
491
+ Let's say you need to add a call to `fsync` to force all of your output data to flush to a file after each test.
492
+ You could easily insert this after your `UnityConcludeTest` call.
493
+ Maybe you want to write an xml tag before and after each result set.
494
+ Again, you could do this by adding lines to this macro.
495
+ Updates to this macro are for the occasions when you need an action before or after every single test case throughout your entire suite of tests.
555
496
 
556
497
  ## Happy Porting
557
498
 
558
- The defines and macros in this guide should help you port Unity to just about
559
- any C target we can imagine. If you run into a snag or two, don't be afraid of
560
- asking for help on the forums. We love a good challenge!
499
+ The defines and macros in this guide should help you port Unity to just about any C target we can imagine.
500
+ If you run into a snag or two, don't be afraid of asking for help on the forums.
501
+ We love a good challenge!
561
502
 
503
+ *Find The Latest of This And More at [ThrowTheSwitch.org][]*
562
504
 
563
- *Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)*
505
+ [ThrowTheSwitch.org]: https://throwtheswitch.org