19750e409Sopenharmony_ci/* Unity Configuration
29750e409Sopenharmony_ci * As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529
39750e409Sopenharmony_ci * Update: December 29th, 2016
49750e409Sopenharmony_ci * See Also: Unity/docs/UnityConfigurationGuide.pdf
59750e409Sopenharmony_ci *
69750e409Sopenharmony_ci * Unity is designed to run on almost anything that is targeted by a C compiler.
79750e409Sopenharmony_ci * It would be awesome if this could be done with zero configuration. While
89750e409Sopenharmony_ci * there are some targets that come close to this dream, it is sadly not
99750e409Sopenharmony_ci * universal. It is likely that you are going to need at least a couple of the
109750e409Sopenharmony_ci * configuration options described in this document.
119750e409Sopenharmony_ci *
129750e409Sopenharmony_ci * All of Unity's configuration options are `#defines`. Most of these are simple
139750e409Sopenharmony_ci * definitions. A couple are macros with arguments. They live inside the
149750e409Sopenharmony_ci * unity_internals.h header file. We don't necessarily recommend opening that
159750e409Sopenharmony_ci * file unless you really need to. That file is proof that a cross-platform
169750e409Sopenharmony_ci * library is challenging to build. From a more positive perspective, it is also
179750e409Sopenharmony_ci * proof that a great deal of complexity can be centralized primarily to one
189750e409Sopenharmony_ci * place in order to provide a more consistent and simple experience elsewhere.
199750e409Sopenharmony_ci *
209750e409Sopenharmony_ci * Using These Options
219750e409Sopenharmony_ci * It doesn't matter if you're using a target-specific compiler and a simulator
229750e409Sopenharmony_ci * or a native compiler. In either case, you've got a couple choices for
239750e409Sopenharmony_ci * configuring these options:
249750e409Sopenharmony_ci *
259750e409Sopenharmony_ci *  1. Because these options are specified via C defines, you can pass most of
269750e409Sopenharmony_ci *     these options to your compiler through command line compiler flags. Even
279750e409Sopenharmony_ci *     if you're using an embedded target that forces you to use their
289750e409Sopenharmony_ci *     overbearing IDE for all configuration, there will be a place somewhere in
299750e409Sopenharmony_ci *     your project to configure defines for your compiler.
309750e409Sopenharmony_ci *  2. You can create a custom `unity_config.h` configuration file (present in
319750e409Sopenharmony_ci *     your toolchain's search paths). In this file, you will list definitions
329750e409Sopenharmony_ci *     and macros specific to your target. All you must do is define
339750e409Sopenharmony_ci *     `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any
349750e409Sopenharmony_ci *     further definitions it may need.
359750e409Sopenharmony_ci */
369750e409Sopenharmony_ci
379750e409Sopenharmony_ci#ifndef UNITY_CONFIG_H
389750e409Sopenharmony_ci#define UNITY_CONFIG_H
399750e409Sopenharmony_ci
409750e409Sopenharmony_ci/* ************************* AUTOMATIC INTEGER TYPES ***************************
419750e409Sopenharmony_ci * C's concept of an integer varies from target to target. The C Standard has
429750e409Sopenharmony_ci * rules about the `int` matching the register size of the target
439750e409Sopenharmony_ci * microprocessor. It has rules about the `int` and how its size relates to
449750e409Sopenharmony_ci * other integer types. An `int` on one target might be 16 bits while on another
459750e409Sopenharmony_ci * target it might be 64. There are more specific types in compilers compliant
469750e409Sopenharmony_ci * with C99 or later, but that's certainly not every compiler you are likely to
479750e409Sopenharmony_ci * encounter. Therefore, Unity has a number of features for helping to adjust
489750e409Sopenharmony_ci * itself to match your required integer sizes. It starts off by trying to do it
499750e409Sopenharmony_ci * automatically.
509750e409Sopenharmony_ci **************************************************************************** */
519750e409Sopenharmony_ci
529750e409Sopenharmony_ci/* The first attempt to guess your types is to check `limits.h`. Some compilers
539750e409Sopenharmony_ci * that don't support `stdint.h` could include `limits.h`. If you don't
549750e409Sopenharmony_ci * want Unity to check this file, define this to make it skip the inclusion.
559750e409Sopenharmony_ci * Unity looks at UINT_MAX & ULONG_MAX, which were available since C89.
569750e409Sopenharmony_ci */
579750e409Sopenharmony_ci/* #define UNITY_EXCLUDE_LIMITS_H */
589750e409Sopenharmony_ci
599750e409Sopenharmony_ci/* The second thing that Unity does to guess your types is check `stdint.h`.
609750e409Sopenharmony_ci * This file defines `UINTPTR_MAX`, since C99, that Unity can make use of to
619750e409Sopenharmony_ci * learn about your system. It's possible you don't want it to do this or it's
629750e409Sopenharmony_ci * possible that your system doesn't support `stdint.h`. If that's the case,
639750e409Sopenharmony_ci * you're going to want to define this. That way, Unity will know to skip the
649750e409Sopenharmony_ci * inclusion of this file and you won't be left with a compiler error.
659750e409Sopenharmony_ci */
669750e409Sopenharmony_ci/* #define UNITY_EXCLUDE_STDINT_H */
679750e409Sopenharmony_ci
689750e409Sopenharmony_ci/* ********************** MANUAL INTEGER TYPE DEFINITION ***********************
699750e409Sopenharmony_ci * If you've disabled all of the automatic options above, you're going to have
709750e409Sopenharmony_ci * to do the configuration yourself. There are just a handful of defines that
719750e409Sopenharmony_ci * you are going to specify if you don't like the defaults.
729750e409Sopenharmony_ci **************************************************************************** */
739750e409Sopenharmony_ci
749750e409Sopenharmony_ci /* Define this to be the number of bits an `int` takes up on your system. The
759750e409Sopenharmony_ci * default, if not auto-detected, is 32 bits.
769750e409Sopenharmony_ci *
779750e409Sopenharmony_ci * Example:
789750e409Sopenharmony_ci */
799750e409Sopenharmony_ci/* #define UNITY_INT_WIDTH 16 */
809750e409Sopenharmony_ci
819750e409Sopenharmony_ci/* Define this to be the number of bits a `long` takes up on your system. The
829750e409Sopenharmony_ci * default, if not autodetected, is 32 bits. This is used to figure out what
839750e409Sopenharmony_ci * kind of 64-bit support your system can handle.  Does it need to specify a
849750e409Sopenharmony_ci * `long` or a `long long` to get a 64-bit value. On 16-bit systems, this option
859750e409Sopenharmony_ci * is going to be ignored.
869750e409Sopenharmony_ci *
879750e409Sopenharmony_ci * Example:
889750e409Sopenharmony_ci */
899750e409Sopenharmony_ci/* #define UNITY_LONG_WIDTH 16 */
909750e409Sopenharmony_ci
919750e409Sopenharmony_ci/* Define this to be the number of bits a pointer takes up on your system. The
929750e409Sopenharmony_ci * default, if not autodetected, is 32-bits. If you're getting ugly compiler
939750e409Sopenharmony_ci * warnings about casting from pointers, this is the one to look at.
949750e409Sopenharmony_ci *
959750e409Sopenharmony_ci * Example:
969750e409Sopenharmony_ci */
979750e409Sopenharmony_ci/* #define UNITY_POINTER_WIDTH 64 */
989750e409Sopenharmony_ci
999750e409Sopenharmony_ci/* Unity will automatically include 64-bit support if it auto-detects it, or if
1009750e409Sopenharmony_ci * your `int`, `long`, or pointer widths are greater than 32-bits. Define this
1019750e409Sopenharmony_ci * to enable 64-bit support if none of the other options already did it for you.
1029750e409Sopenharmony_ci * There can be a significant size and speed impact to enabling 64-bit support
1039750e409Sopenharmony_ci * on small targets, so don't define it if you don't need it.
1049750e409Sopenharmony_ci */
1059750e409Sopenharmony_ci/* #define UNITY_INCLUDE_64 */
1069750e409Sopenharmony_ci
1079750e409Sopenharmony_ci
1089750e409Sopenharmony_ci/* *************************** FLOATING POINT TYPES ****************************
1099750e409Sopenharmony_ci * In the embedded world, it's not uncommon for targets to have no support for
1109750e409Sopenharmony_ci * floating point operations at all or to have support that is limited to only
1119750e409Sopenharmony_ci * single precision. We are able to guess integer sizes on the fly because
1129750e409Sopenharmony_ci * integers are always available in at least one size. Floating point, on the
1139750e409Sopenharmony_ci * other hand, is sometimes not available at all. Trying to include `float.h` on
1149750e409Sopenharmony_ci * these platforms would result in an error. This leaves manual configuration as
1159750e409Sopenharmony_ci * the only option.
1169750e409Sopenharmony_ci **************************************************************************** */
1179750e409Sopenharmony_ci
1189750e409Sopenharmony_ci /* By default, Unity guesses that you will want single precision floating point
1199750e409Sopenharmony_ci  * support, but not double precision. It's easy to change either of these using
1209750e409Sopenharmony_ci  * the include and exclude options here. You may include neither, just float,
1219750e409Sopenharmony_ci  * or both, as suits your needs.
1229750e409Sopenharmony_ci  */
1239750e409Sopenharmony_ci/* #define UNITY_EXCLUDE_FLOAT  */
1249750e409Sopenharmony_ci#define UNITY_INCLUDE_DOUBLE
1259750e409Sopenharmony_ci/* #define UNITY_EXCLUDE_DOUBLE */
1269750e409Sopenharmony_ci
1279750e409Sopenharmony_ci/* For features that are enabled, the following floating point options also
1289750e409Sopenharmony_ci * become available.
1299750e409Sopenharmony_ci */
1309750e409Sopenharmony_ci
1319750e409Sopenharmony_ci/* Unity aims for as small of a footprint as possible and avoids most standard
1329750e409Sopenharmony_ci * library calls (some embedded platforms don't have a standard library!).
1339750e409Sopenharmony_ci * Because of this, its routines for printing integer values are minimalist and
1349750e409Sopenharmony_ci * hand-coded. To keep Unity universal, though, we eventually chose to develop
1359750e409Sopenharmony_ci * our own floating point print routines. Still, the display of floating point
1369750e409Sopenharmony_ci * values during a failure are optional. By default, Unity will print the
1379750e409Sopenharmony_ci * actual results of floating point assertion failures. So a failed assertion
1389750e409Sopenharmony_ci * will produce a message like "Expected 4.0 Was 4.25". If you would like less
1399750e409Sopenharmony_ci * verbose failure messages for floating point assertions, use this option to
1409750e409Sopenharmony_ci * give a failure message `"Values Not Within Delta"` and trim the binary size.
1419750e409Sopenharmony_ci */
1429750e409Sopenharmony_ci/* #define UNITY_EXCLUDE_FLOAT_PRINT */
1439750e409Sopenharmony_ci
1449750e409Sopenharmony_ci/* If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C
1459750e409Sopenharmony_ci * floats. If your compiler supports a specialty floating point type, you can
1469750e409Sopenharmony_ci * always override this behavior by using this definition.
1479750e409Sopenharmony_ci *
1489750e409Sopenharmony_ci * Example:
1499750e409Sopenharmony_ci */
1509750e409Sopenharmony_ci/* #define UNITY_FLOAT_TYPE float16_t */
1519750e409Sopenharmony_ci
1529750e409Sopenharmony_ci/* If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard
1539750e409Sopenharmony_ci * C doubles. If you would like to change this, you can specify something else
1549750e409Sopenharmony_ci * by using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long
1559750e409Sopenharmony_ci * double` could enable gargantuan floating point types on your 64-bit processor
1569750e409Sopenharmony_ci * instead of the standard `double`.
1579750e409Sopenharmony_ci *
1589750e409Sopenharmony_ci * Example:
1599750e409Sopenharmony_ci */
1609750e409Sopenharmony_ci/* #define UNITY_DOUBLE_TYPE long double */
1619750e409Sopenharmony_ci
1629750e409Sopenharmony_ci/* If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as
1639750e409Sopenharmony_ci * documented in the Unity Assertion Guide, you will learn that they are not
1649750e409Sopenharmony_ci * really asserting that two values are equal but rather that two values are
1659750e409Sopenharmony_ci * "close enough" to equal. "Close enough" is controlled by these precision
1669750e409Sopenharmony_ci * configuration options. If you are working with 32-bit floats and/or 64-bit
1679750e409Sopenharmony_ci * doubles (the normal on most processors), you should have no need to change
1689750e409Sopenharmony_ci * these options. They are both set to give you approximately 1 significant bit
1699750e409Sopenharmony_ci * in either direction. The float precision is 0.00001 while the double is
1709750e409Sopenharmony_ci * 10^-12. For further details on how this works, see the appendix of the Unity
1719750e409Sopenharmony_ci * Assertion Guide.
1729750e409Sopenharmony_ci *
1739750e409Sopenharmony_ci * Example:
1749750e409Sopenharmony_ci */
1759750e409Sopenharmony_ci/* #define UNITY_FLOAT_PRECISION 0.001f  */
1769750e409Sopenharmony_ci/* #define UNITY_DOUBLE_PRECISION 0.001f */
1779750e409Sopenharmony_ci
1789750e409Sopenharmony_ci
1799750e409Sopenharmony_ci/* *************************** TOOLSET CUSTOMIZATION ***************************
1809750e409Sopenharmony_ci * In addition to the options listed above, there are a number of other options
1819750e409Sopenharmony_ci * which will come in handy to customize Unity's behavior for your specific
1829750e409Sopenharmony_ci * toolchain. It is possible that you may not need to touch any of these but
1839750e409Sopenharmony_ci * certain platforms, particularly those running in simulators, may need to jump
1849750e409Sopenharmony_ci * through extra hoops to operate properly. These macros will help in those
1859750e409Sopenharmony_ci * situations.
1869750e409Sopenharmony_ci **************************************************************************** */
1879750e409Sopenharmony_ci
1889750e409Sopenharmony_ci/* By default, Unity prints its results to `stdout` as it runs. This works
1899750e409Sopenharmony_ci * perfectly fine in most situations where you are using a native compiler for
1909750e409Sopenharmony_ci * testing. It works on some simulators as well so long as they have `stdout`
1919750e409Sopenharmony_ci * routed back to the command line. There are times, however, where the
1929750e409Sopenharmony_ci * simulator will lack support for dumping results or you will want to route
1939750e409Sopenharmony_ci * results elsewhere for other reasons. In these cases, you should define the
1949750e409Sopenharmony_ci * `UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time
1959750e409Sopenharmony_ci * (as an `int`, since this is the parameter type of the standard C `putchar`
1969750e409Sopenharmony_ci * function most commonly used). You may replace this with whatever function
1979750e409Sopenharmony_ci * call you like.
1989750e409Sopenharmony_ci *
1999750e409Sopenharmony_ci * Example:
2009750e409Sopenharmony_ci * Say you are forced to run your test suite on an embedded processor with no
2019750e409Sopenharmony_ci * `stdout` option. You decide to route your test result output to a custom
2029750e409Sopenharmony_ci * serial `RS232_putc()` function you wrote like thus:
2039750e409Sopenharmony_ci */
2049750e409Sopenharmony_ci/* #define UNITY_OUTPUT_CHAR(a)                    RS232_putc(a) */
2059750e409Sopenharmony_ci/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION    RS232_putc(int) */
2069750e409Sopenharmony_ci/* #define UNITY_OUTPUT_FLUSH()                    RS232_flush() */
2079750e409Sopenharmony_ci/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION   RS232_flush(void) */
2089750e409Sopenharmony_ci/* #define UNITY_OUTPUT_START()                    RS232_config(115200,1,8,0) */
2099750e409Sopenharmony_ci/* #define UNITY_OUTPUT_COMPLETE()                 RS232_close() */
2109750e409Sopenharmony_ci
2119750e409Sopenharmony_ci/* For some targets, Unity can make the otherwise required `setUp()` and
2129750e409Sopenharmony_ci * `tearDown()` functions optional. This is a nice convenience for test writers
2139750e409Sopenharmony_ci * since `setUp` and `tearDown` don't often actually _do_ anything. If you're
2149750e409Sopenharmony_ci * using gcc or clang, this option is automatically defined for you. Other
2159750e409Sopenharmony_ci * compilers can also support this behavior, if they support a C feature called
2169750e409Sopenharmony_ci * weak functions. A weak function is a function that is compiled into your
2179750e409Sopenharmony_ci * executable _unless_ a non-weak version of the same function is defined
2189750e409Sopenharmony_ci * elsewhere. If a non-weak version is found, the weak version is ignored as if
2199750e409Sopenharmony_ci * it never existed. If your compiler supports this feature, you can let Unity
2209750e409Sopenharmony_ci * know by defining `UNITY_SUPPORT_WEAK` as the function attributes that would
2219750e409Sopenharmony_ci * need to be applied to identify a function as weak. If your compiler lacks
2229750e409Sopenharmony_ci * support for weak functions, you will always need to define `setUp` and
2239750e409Sopenharmony_ci * `tearDown` functions (though they can be and often will be just empty). The
2249750e409Sopenharmony_ci * most common options for this feature are:
2259750e409Sopenharmony_ci */
2269750e409Sopenharmony_ci/* #define UNITY_SUPPORT_WEAK weak */
2279750e409Sopenharmony_ci/* #define UNITY_SUPPORT_WEAK __attribute__((weak)) */
2289750e409Sopenharmony_ci/* #define UNITY_NO_WEAK */
2299750e409Sopenharmony_ci
2309750e409Sopenharmony_ci/* Some compilers require a custom attribute to be assigned to pointers, like
2319750e409Sopenharmony_ci * `near` or `far`. In these cases, you can give Unity a safe default for these
2329750e409Sopenharmony_ci * by defining this option with the attribute you would like.
2339750e409Sopenharmony_ci *
2349750e409Sopenharmony_ci * Example:
2359750e409Sopenharmony_ci */
2369750e409Sopenharmony_ci/* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */
2379750e409Sopenharmony_ci/* #define UNITY_PTR_ATTRIBUTE near */
2389750e409Sopenharmony_ci
2399750e409Sopenharmony_ci#endif /* UNITY_CONFIG_H */
240