Toyomasa Watarai / simple-mbed-cloud-client

Dependents:  

Committer:
MACRUM
Date:
Mon Jul 02 08:06:37 2018 +0000
Revision:
2:bf2124b482f9
Parent:
0:276e7a263c35
Update library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:276e7a263c35 1 /* Unity Configuration
MACRUM 0:276e7a263c35 2 * As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529
MACRUM 0:276e7a263c35 3 * See Also: Unity/docs/UnityConfigurationGuide.pdf
MACRUM 0:276e7a263c35 4 *
MACRUM 0:276e7a263c35 5 * Unity is designed to run on almost anything that is targeted by a C compiler.
MACRUM 0:276e7a263c35 6 * It would be awesome if this could be done with zero configuration. While
MACRUM 0:276e7a263c35 7 * there are some targets that come close to this dream, it is sadly not
MACRUM 0:276e7a263c35 8 * universal. It is likely that you are going to need at least a couple of the
MACRUM 0:276e7a263c35 9 * configuration options described in this document.
MACRUM 0:276e7a263c35 10 *
MACRUM 0:276e7a263c35 11 * All of Unity's configuration options are `#defines`. Most of these are simple
MACRUM 0:276e7a263c35 12 * definitions. A couple are macros with arguments. They live inside the
MACRUM 0:276e7a263c35 13 * unity_internals.h header file. We don't necessarily recommend opening that
MACRUM 0:276e7a263c35 14 * file unless you really need to. That file is proof that a cross-platform
MACRUM 0:276e7a263c35 15 * library is challenging to build. From a more positive perspective, it is also
MACRUM 0:276e7a263c35 16 * proof that a great deal of complexity can be centralized primarily to one
MACRUM 0:276e7a263c35 17 * place in order to provide a more consistent and simple experience elsewhere.
MACRUM 0:276e7a263c35 18 *
MACRUM 0:276e7a263c35 19 * Using These Options
MACRUM 0:276e7a263c35 20 * It doesn't matter if you're using a target-specific compiler and a simulator
MACRUM 0:276e7a263c35 21 * or a native compiler. In either case, you've got a couple choices for
MACRUM 0:276e7a263c35 22 * configuring these options:
MACRUM 0:276e7a263c35 23 *
MACRUM 0:276e7a263c35 24 * 1. Because these options are specified via C defines, you can pass most of
MACRUM 0:276e7a263c35 25 * these options to your compiler through command line compiler flags. Even
MACRUM 0:276e7a263c35 26 * if you're using an embedded target that forces you to use their
MACRUM 0:276e7a263c35 27 * overbearing IDE for all configuration, there will be a place somewhere in
MACRUM 0:276e7a263c35 28 * your project to configure defines for your compiler.
MACRUM 0:276e7a263c35 29 * 2. You can create a custom `unity_config.h` configuration file (present in
MACRUM 0:276e7a263c35 30 * your toolchain's search paths). In this file, you will list definitions
MACRUM 0:276e7a263c35 31 * and macros specific to your target. All you must do is define
MACRUM 0:276e7a263c35 32 * `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any
MACRUM 0:276e7a263c35 33 * further definitions it may need.
MACRUM 0:276e7a263c35 34 */
MACRUM 0:276e7a263c35 35
MACRUM 0:276e7a263c35 36 #ifndef UNITY_CONFIG_H
MACRUM 0:276e7a263c35 37 #define UNITY_CONFIG_H
MACRUM 0:276e7a263c35 38
MACRUM 0:276e7a263c35 39 #ifdef __cplusplus
MACRUM 0:276e7a263c35 40 extern "C"
MACRUM 0:276e7a263c35 41 {
MACRUM 0:276e7a263c35 42 #endif
MACRUM 0:276e7a263c35 43
MACRUM 0:276e7a263c35 44 /* ************************* AUTOMATIC INTEGER TYPES ***************************
MACRUM 0:276e7a263c35 45 * C's concept of an integer varies from target to target. The C Standard has
MACRUM 0:276e7a263c35 46 * rules about the `int` matching the register size of the target
MACRUM 0:276e7a263c35 47 * microprocessor. It has rules about the `int` and how its size relates to
MACRUM 0:276e7a263c35 48 * other integer types. An `int` on one target might be 16 bits while on another
MACRUM 0:276e7a263c35 49 * target it might be 64. There are more specific types in compilers compliant
MACRUM 0:276e7a263c35 50 * with C99 or later, but that's certainly not every compiler you are likely to
MACRUM 0:276e7a263c35 51 * encounter. Therefore, Unity has a number of features for helping to adjust
MACRUM 0:276e7a263c35 52 * itself to match your required integer sizes. It starts off by trying to do it
MACRUM 0:276e7a263c35 53 * automatically.
MACRUM 0:276e7a263c35 54 **************************************************************************** */
MACRUM 0:276e7a263c35 55
MACRUM 0:276e7a263c35 56 /* The first thing that Unity does to guess your types is check `stdint.h`. This
MACRUM 0:276e7a263c35 57 * file includes defines like `UINT_MAX` that Unity can make use of to learn a
MACRUM 0:276e7a263c35 58 * lot about your system. It's possible you don't want it to do this or it's
MACRUM 0:276e7a263c35 59 * possible that your system doesn't support `stdint.h`. If that's the case,
MACRUM 0:276e7a263c35 60 * you're going to want to define this. That way, Unity will know to skip the
MACRUM 0:276e7a263c35 61 * inclusion of this file and you won't be left with a compiler error.
MACRUM 0:276e7a263c35 62 */
MACRUM 0:276e7a263c35 63 /* #define UNITY_EXCLUDE_STDINT_H */
MACRUM 0:276e7a263c35 64
MACRUM 0:276e7a263c35 65 /* The second attempt to guess your types is to check `limits.h`. Some compilers
MACRUM 0:276e7a263c35 66 * that don't support `stdint.h` could include `limits.h` instead. If you don't
MACRUM 0:276e7a263c35 67 * want Unity to check this file either, define this to make it skip the
MACRUM 0:276e7a263c35 68 * inclusion.
MACRUM 0:276e7a263c35 69 */
MACRUM 0:276e7a263c35 70 /* #define UNITY_EXCLUDE_LIMITS_H */
MACRUM 0:276e7a263c35 71
MACRUM 0:276e7a263c35 72 /* The third and final attempt to guess your types is to use the `sizeof()`
MACRUM 0:276e7a263c35 73 * operator. Even if the first two options don't work, this one covers most
MACRUM 0:276e7a263c35 74 * cases. There _is_ a rare compiler or two out there that doesn't support
MACRUM 0:276e7a263c35 75 * `sizeof()` in the preprocessing stage, though. For these, you have the
MACRUM 0:276e7a263c35 76 * ability to disable this feature as well.
MACRUM 0:276e7a263c35 77 */
MACRUM 0:276e7a263c35 78 /* #define UNITY_EXCLUDE_SIZEOF */
MACRUM 0:276e7a263c35 79
MACRUM 0:276e7a263c35 80
MACRUM 0:276e7a263c35 81 /* ********************** MANUAL INTEGER TYPE DEFINITION ***********************
MACRUM 0:276e7a263c35 82 * If you've disabled all of the automatic options above, you're going to have
MACRUM 0:276e7a263c35 83 * to do the configuration yourself. There are just a handful of defines that
MACRUM 0:276e7a263c35 84 * you are going to specify if you don't like the defaults.
MACRUM 0:276e7a263c35 85 **************************************************************************** */
MACRUM 0:276e7a263c35 86
MACRUM 0:276e7a263c35 87 /* Define this to be the number of bits an `int` takes up on your system. The
MACRUM 0:276e7a263c35 88 * default, if not auto-detected, is 32 bits.
MACRUM 0:276e7a263c35 89 *
MACRUM 0:276e7a263c35 90 * Example:
MACRUM 0:276e7a263c35 91 */
MACRUM 0:276e7a263c35 92 /* #define UNITY_INT_WIDTH 16 */
MACRUM 0:276e7a263c35 93
MACRUM 0:276e7a263c35 94 /* Define this to be the number of bits a `long` takes up on your system. The
MACRUM 0:276e7a263c35 95 * default, if not autodetected, is 32 bits. This is used to figure out what
MACRUM 0:276e7a263c35 96 * kind of 64-bit support your system can handle. Does it need to specify a
MACRUM 0:276e7a263c35 97 * `long` or a `long long` to get a 64-bit value. On 16-bit systems, this option
MACRUM 0:276e7a263c35 98 * is going to be ignored.
MACRUM 0:276e7a263c35 99 *
MACRUM 0:276e7a263c35 100 * Example:
MACRUM 0:276e7a263c35 101 */
MACRUM 0:276e7a263c35 102 /* #define UNITY_LONG_WIDTH 16 */
MACRUM 0:276e7a263c35 103
MACRUM 0:276e7a263c35 104 /* Define this to be the number of bits a pointer takes up on your system. The
MACRUM 0:276e7a263c35 105 * default, if not autodetected, is 32-bits. If you're getting ugly compiler
MACRUM 0:276e7a263c35 106 * warnings about casting from pointers, this is the one to look at.
MACRUM 0:276e7a263c35 107 *
MACRUM 0:276e7a263c35 108 * Example:
MACRUM 0:276e7a263c35 109 */
MACRUM 0:276e7a263c35 110 /* #define UNITY_POINTER_WIDTH 64 */
MACRUM 0:276e7a263c35 111
MACRUM 0:276e7a263c35 112 /* Unity will automatically include 64-bit support if it auto-detects it, or if
MACRUM 0:276e7a263c35 113 * your `int`, `long`, or pointer widths are greater than 32-bits. Define this
MACRUM 0:276e7a263c35 114 * to enable 64-bit support if none of the other options already did it for you.
MACRUM 0:276e7a263c35 115 * There can be a significant size and speed impact to enabling 64-bit support
MACRUM 0:276e7a263c35 116 * on small targets, so don't define it if you don't need it.
MACRUM 0:276e7a263c35 117 */
MACRUM 0:276e7a263c35 118 /* #define UNITY_INCLUDE_64 */
MACRUM 0:276e7a263c35 119
MACRUM 0:276e7a263c35 120
MACRUM 0:276e7a263c35 121 /* *************************** FLOATING POINT TYPES ****************************
MACRUM 0:276e7a263c35 122 * In the embedded world, it's not uncommon for targets to have no support for
MACRUM 0:276e7a263c35 123 * floating point operations at all or to have support that is limited to only
MACRUM 0:276e7a263c35 124 * single precision. We are able to guess integer sizes on the fly because
MACRUM 0:276e7a263c35 125 * integers are always available in at least one size. Floating point, on the
MACRUM 0:276e7a263c35 126 * other hand, is sometimes not available at all. Trying to include `float.h` on
MACRUM 0:276e7a263c35 127 * these platforms would result in an error. This leaves manual configuration as
MACRUM 0:276e7a263c35 128 * the only option.
MACRUM 0:276e7a263c35 129 **************************************************************************** */
MACRUM 0:276e7a263c35 130
MACRUM 0:276e7a263c35 131 /* By default, Unity guesses that you will want single precision floating point
MACRUM 0:276e7a263c35 132 * support, but not double precision. It's easy to change either of these using
MACRUM 0:276e7a263c35 133 * the include and exclude options here. You may include neither, either, or
MACRUM 0:276e7a263c35 134 * both, as suits your needs.
MACRUM 0:276e7a263c35 135 */
MACRUM 0:276e7a263c35 136 /* #define UNITY_INCLUDE_FLOAT */
MACRUM 0:276e7a263c35 137 /* #define UNITY_EXCLUDE_FLOAT */
MACRUM 0:276e7a263c35 138 /* #define UNITY_INCLUDE_DOUBLE */
MACRUM 0:276e7a263c35 139 /* #define UNITY_EXCLUDE_DOUBLE */
MACRUM 0:276e7a263c35 140
MACRUM 0:276e7a263c35 141 /* For features that are enabled, the following floating point options also
MACRUM 0:276e7a263c35 142 * become available.
MACRUM 0:276e7a263c35 143 */
MACRUM 0:276e7a263c35 144
MACRUM 0:276e7a263c35 145 /* Unity aims for as small of a footprint as possible and avoids most standard
MACRUM 0:276e7a263c35 146 * library calls (some embedded platforms don't have a standard library!).
MACRUM 0:276e7a263c35 147 * Because of this, its routines for printing integer values are minimalist and
MACRUM 0:276e7a263c35 148 * hand-coded. To keep Unity universal, though, we chose to _not_ develop our
MACRUM 0:276e7a263c35 149 * own floating point print routines. Instead, the display of floating point
MACRUM 0:276e7a263c35 150 * values during a failure are optional. By default, Unity will not print the
MACRUM 0:276e7a263c35 151 * actual results of floating point assertion failure. So a failed assertion
MACRUM 0:276e7a263c35 152 * will produce a message like `"Values Not Within Delta"`. If you would like
MACRUM 0:276e7a263c35 153 * verbose failure messages for floating point assertions, use these options to
MACRUM 0:276e7a263c35 154 * give more explicit failure messages (e.g. `"Expected 4.56 Was 4.68"`). Note
MACRUM 0:276e7a263c35 155 * that this feature requires the use of `sprintf` so might not be desirable in
MACRUM 0:276e7a263c35 156 * all cases.
MACRUM 0:276e7a263c35 157 */
MACRUM 0:276e7a263c35 158 /* #define UNITY_FLOAT_VERBOSE */
MACRUM 0:276e7a263c35 159 /* #define UNITY_DOUBLE_VERBOSE */
MACRUM 0:276e7a263c35 160
MACRUM 0:276e7a263c35 161 /* If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C
MACRUM 0:276e7a263c35 162 * floats. If your compiler supports a specialty floating point type, you can
MACRUM 0:276e7a263c35 163 * always override this behavior by using this definition.
MACRUM 0:276e7a263c35 164 *
MACRUM 0:276e7a263c35 165 * Example:
MACRUM 0:276e7a263c35 166 */
MACRUM 0:276e7a263c35 167 /* #define UNITY_FLOAT_TYPE float16_t */
MACRUM 0:276e7a263c35 168
MACRUM 0:276e7a263c35 169 /* If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard
MACRUM 0:276e7a263c35 170 * C doubles. If you would like to change this, you can specify something else
MACRUM 0:276e7a263c35 171 * by using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long
MACRUM 0:276e7a263c35 172 * double` could enable gargantuan floating point types on your 64-bit processor
MACRUM 0:276e7a263c35 173 * instead of the standard `double`.
MACRUM 0:276e7a263c35 174 *
MACRUM 0:276e7a263c35 175 * Example:
MACRUM 0:276e7a263c35 176 */
MACRUM 0:276e7a263c35 177 /* #define UNITY_DOUBLE_TYPE long double */
MACRUM 0:276e7a263c35 178
MACRUM 0:276e7a263c35 179 /* If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as
MACRUM 0:276e7a263c35 180 * documented in the Unity Assertion Guide, you will learn that they are not
MACRUM 0:276e7a263c35 181 * really asserting that two values are equal but rather that two values are
MACRUM 0:276e7a263c35 182 * "close enough" to equal. "Close enough" is controlled by these precision
MACRUM 0:276e7a263c35 183 * configuration options. If you are working with 32-bit floats and/or 64-bit
MACRUM 0:276e7a263c35 184 * doubles (the normal on most processors), you should have no need to change
MACRUM 0:276e7a263c35 185 * these options. They are both set to give you approximately 1 significant bit
MACRUM 0:276e7a263c35 186 * in either direction. The float precision is 0.00001 while the double is
MACRUM 0:276e7a263c35 187 * 10^-12. For further details on how this works, see the appendix of the Unity
MACRUM 0:276e7a263c35 188 * Assertion Guide.
MACRUM 0:276e7a263c35 189 *
MACRUM 0:276e7a263c35 190 * Example:
MACRUM 0:276e7a263c35 191 */
MACRUM 0:276e7a263c35 192 /* #define UNITY_FLOAT_PRECISION 0.001f */
MACRUM 0:276e7a263c35 193 /* #define UNITY_DOUBLE_PRECISION 0.001f */
MACRUM 0:276e7a263c35 194
MACRUM 0:276e7a263c35 195
MACRUM 0:276e7a263c35 196 /* *************************** TOOLSET CUSTOMIZATION ***************************
MACRUM 0:276e7a263c35 197 * In addition to the options listed above, there are a number of other options
MACRUM 0:276e7a263c35 198 * which will come in handy to customize Unity's behavior for your specific
MACRUM 0:276e7a263c35 199 * toolchain. It is possible that you may not need to touch any of these but
MACRUM 0:276e7a263c35 200 * certain platforms, particularly those running in simulators, may need to jump
MACRUM 0:276e7a263c35 201 * through extra hoops to operate properly. These macros will help in those
MACRUM 0:276e7a263c35 202 * situations.
MACRUM 0:276e7a263c35 203 **************************************************************************** */
MACRUM 0:276e7a263c35 204
MACRUM 0:276e7a263c35 205 /* By default, Unity prints its results to `stdout` as it runs. This works
MACRUM 0:276e7a263c35 206 * perfectly fine in most situations where you are using a native compiler for
MACRUM 0:276e7a263c35 207 * testing. It works on some simulators as well so long as they have `stdout`
MACRUM 0:276e7a263c35 208 * routed back to the command line. There are times, however, where the
MACRUM 0:276e7a263c35 209 * simulator will lack support for dumping results or you will want to route
MACRUM 0:276e7a263c35 210 * results elsewhere for other reasons. In these cases, you should define the
MACRUM 0:276e7a263c35 211 * `UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time
MACRUM 0:276e7a263c35 212 * (as an `int`, since this is the parameter type of the standard C `putchar`
MACRUM 0:276e7a263c35 213 * function most commonly used). You may replace this with whatever function
MACRUM 0:276e7a263c35 214 * call you like.
MACRUM 0:276e7a263c35 215 *
MACRUM 0:276e7a263c35 216 * Example:
MACRUM 0:276e7a263c35 217 * Say you are forced to run your test suite on an embedded processor with no
MACRUM 0:276e7a263c35 218 * `stdout` option. You decide to route your test result output to a custom
MACRUM 0:276e7a263c35 219 * serial `RS232_putc()` function you wrote like thus:
MACRUM 0:276e7a263c35 220 */
MACRUM 0:276e7a263c35 221 /* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */
MACRUM 0:276e7a263c35 222 /* #define UNITY_OUTPUT_FLUSH() RS232_config(115200,1,8,0) */
MACRUM 0:276e7a263c35 223 /* #define UNITY_OUTPUT_START() RS232_flush() */
MACRUM 0:276e7a263c35 224 /* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
MACRUM 0:276e7a263c35 225
MACRUM 0:276e7a263c35 226 /* For some targets, Unity can make the otherwise required `setUp()` and
MACRUM 0:276e7a263c35 227 * `tearDown()` functions optional. This is a nice convenience for test writers
MACRUM 0:276e7a263c35 228 * since `setUp` and `tearDown` don't often actually _do_ anything. If you're
MACRUM 0:276e7a263c35 229 * using gcc or clang, this option is automatically defined for you. Other
MACRUM 0:276e7a263c35 230 * compilers can also support this behavior, if they support a C feature called
MACRUM 0:276e7a263c35 231 * weak functions. A weak function is a function that is compiled into your
MACRUM 0:276e7a263c35 232 * executable _unless_ a non-weak version of the same function is defined
MACRUM 0:276e7a263c35 233 * elsewhere. If a non-weak version is found, the weak version is ignored as if
MACRUM 0:276e7a263c35 234 * it never existed. If your compiler supports this feature, you can let Unity
MACRUM 0:276e7a263c35 235 * know by defining `UNITY_SUPPORT_WEAK` as the function attributes that would
MACRUM 0:276e7a263c35 236 * need to be applied to identify a function as weak. If your compiler lacks
MACRUM 0:276e7a263c35 237 * support for weak functions, you will always need to define `setUp` and
MACRUM 0:276e7a263c35 238 * `tearDown` functions (though they can be and often will be just empty). The
MACRUM 0:276e7a263c35 239 * most common options for this feature are:
MACRUM 0:276e7a263c35 240 */
MACRUM 0:276e7a263c35 241 /* #define UNITY_SUPPORT_WEAK weak */
MACRUM 0:276e7a263c35 242 /* #define UNITY_SUPPORT_WEAK __attribute__((weak)) */
MACRUM 0:276e7a263c35 243
MACRUM 0:276e7a263c35 244 /* Some compilers require a custom attribute to be assigned to pointers, like
MACRUM 0:276e7a263c35 245 * `near` or `far`. In these cases, you can give Unity a safe default for these
MACRUM 0:276e7a263c35 246 * by defining this option with the attribute you would like.
MACRUM 0:276e7a263c35 247 *
MACRUM 0:276e7a263c35 248 * Example:
MACRUM 0:276e7a263c35 249 */
MACRUM 0:276e7a263c35 250 /* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */
MACRUM 0:276e7a263c35 251 /* #define UNITY_PTR_ATTRIBUTE near */
MACRUM 0:276e7a263c35 252
MACRUM 0:276e7a263c35 253 #ifdef __cplusplus
MACRUM 0:276e7a263c35 254 }
MACRUM 0:276e7a263c35 255 #endif /* extern "C" */
MACRUM 0:276e7a263c35 256
MACRUM 0:276e7a263c35 257 #endif /* UNITY_CONFIG_H */