1276da39aSCy Schubert /* ========================================== 2276da39aSCy Schubert Unity Project - A Test Framework for C 3276da39aSCy Schubert Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams 4276da39aSCy Schubert [Released under MIT License. Please refer to license.txt for details] 5276da39aSCy Schubert ========================================== */ 6276da39aSCy Schubert 7276da39aSCy Schubert #ifndef UNITY_INTERNALS_H 8276da39aSCy Schubert #define UNITY_INTERNALS_H 9276da39aSCy Schubert 10276da39aSCy Schubert #ifdef UNITY_INCLUDE_CONFIG_H 11276da39aSCy Schubert #include "unity_config.h" 12276da39aSCy Schubert #endif 13276da39aSCy Schubert 14276da39aSCy Schubert #include <setjmp.h> 15276da39aSCy Schubert 16276da39aSCy Schubert // Unity Attempts to Auto-Detect Integer Types 17276da39aSCy Schubert // Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h> 18276da39aSCy Schubert // Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h> 19276da39aSCy Schubert // Attempt 3: Deduced from sizeof() macros 20276da39aSCy Schubert #ifndef UNITY_EXCLUDE_STDINT_H 21276da39aSCy Schubert #include <stdint.h> 22276da39aSCy Schubert #endif 23276da39aSCy Schubert 24276da39aSCy Schubert #ifndef UNITY_EXCLUDE_LIMITS_H 25276da39aSCy Schubert #include <limits.h> 26276da39aSCy Schubert #endif 27276da39aSCy Schubert 28276da39aSCy Schubert #ifndef UNITY_EXCLUDE_SIZEOF 29276da39aSCy Schubert #ifndef UINT_MAX 30276da39aSCy Schubert #define UINT_MAX (sizeof(unsigned int) * 256 - 1) 31276da39aSCy Schubert #endif 32276da39aSCy Schubert #ifndef ULONG_MAX 33276da39aSCy Schubert #define ULONG_MAX (sizeof(unsigned long) * 256 - 1) 34276da39aSCy Schubert #endif 35276da39aSCy Schubert #ifndef UINTPTR_MAX 36276da39aSCy Schubert //apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1) so we have to just let this fall through 37276da39aSCy Schubert #endif 38276da39aSCy Schubert #endif 39276da39aSCy Schubert //------------------------------------------------------- 40276da39aSCy Schubert // Guess Widths If Not Specified 41276da39aSCy Schubert //------------------------------------------------------- 42276da39aSCy Schubert 43276da39aSCy Schubert // Determine the size of an int, if not already specificied. 44276da39aSCy Schubert // We cannot use sizeof(int), because it is not yet defined 45276da39aSCy Schubert // at this stage in the trnslation of the C program. 46276da39aSCy Schubert // Therefore, infer it from UINT_MAX if possible. 47276da39aSCy Schubert #ifndef UNITY_INT_WIDTH 48276da39aSCy Schubert #ifdef UINT_MAX 49276da39aSCy Schubert #if (UINT_MAX == 0xFFFF) 50276da39aSCy Schubert #define UNITY_INT_WIDTH (16) 51276da39aSCy Schubert #elif (UINT_MAX == 0xFFFFFFFF) 52276da39aSCy Schubert #define UNITY_INT_WIDTH (32) 53276da39aSCy Schubert #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) 54276da39aSCy Schubert #define UNITY_INT_WIDTH (64) 55276da39aSCy Schubert #endif 56276da39aSCy Schubert #endif 57276da39aSCy Schubert #endif 58276da39aSCy Schubert #ifndef UNITY_INT_WIDTH 59276da39aSCy Schubert #define UNITY_INT_WIDTH (32) 60276da39aSCy Schubert #endif 61276da39aSCy Schubert 62276da39aSCy Schubert // Determine the size of a long, if not already specified, 63276da39aSCy Schubert // by following the process used above to define 64276da39aSCy Schubert // UNITY_INT_WIDTH. 65276da39aSCy Schubert #ifndef UNITY_LONG_WIDTH 66276da39aSCy Schubert #ifdef ULONG_MAX 67276da39aSCy Schubert #if (ULONG_MAX == 0xFFFF) 68276da39aSCy Schubert #define UNITY_LONG_WIDTH (16) 69276da39aSCy Schubert #elif (ULONG_MAX == 0xFFFFFFFF) 70276da39aSCy Schubert #define UNITY_LONG_WIDTH (32) 71276da39aSCy Schubert #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) 72276da39aSCy Schubert #define UNITY_LONG_WIDTH (64) 73276da39aSCy Schubert #endif 74276da39aSCy Schubert #endif 75276da39aSCy Schubert #endif 76276da39aSCy Schubert #ifndef UNITY_LONG_WIDTH 77276da39aSCy Schubert #define UNITY_LONG_WIDTH (32) 78276da39aSCy Schubert #endif 79276da39aSCy Schubert 80276da39aSCy Schubert // Determine the size of a pointer, if not already specified, 81276da39aSCy Schubert // by following the process used above to define 82276da39aSCy Schubert // UNITY_INT_WIDTH. 83276da39aSCy Schubert #ifndef UNITY_POINTER_WIDTH 84276da39aSCy Schubert #ifdef UINTPTR_MAX 85*9034852cSGleb Smirnoff #if (UINTPTR_MAX+0 <= 0xFFFF) 86276da39aSCy Schubert #define UNITY_POINTER_WIDTH (16) 87*9034852cSGleb Smirnoff #elif (UINTPTR_MAX+0 <= 0xFFFFFFFF) 88276da39aSCy Schubert #define UNITY_POINTER_WIDTH (32) 89*9034852cSGleb Smirnoff #elif (UINTPTR_MAX+0 <= 0xFFFFFFFFFFFFFFFF) 90276da39aSCy Schubert #define UNITY_POINTER_WIDTH (64) 91276da39aSCy Schubert #endif 92276da39aSCy Schubert #endif 93276da39aSCy Schubert #endif 94276da39aSCy Schubert #ifndef UNITY_POINTER_WIDTH 95276da39aSCy Schubert #ifdef INTPTR_MAX 96*9034852cSGleb Smirnoff #if (INTPTR_MAX+0 <= 0x7FFF) 97276da39aSCy Schubert #define UNITY_POINTER_WIDTH (16) 98*9034852cSGleb Smirnoff #elif (INTPTR_MAX+0 <= 0x7FFFFFFF) 99276da39aSCy Schubert #define UNITY_POINTER_WIDTH (32) 100*9034852cSGleb Smirnoff #elif (INTPTR_MAX+0 <= 0x7FFFFFFFFFFFFFFF) 101276da39aSCy Schubert #define UNITY_POINTER_WIDTH (64) 102276da39aSCy Schubert #endif 103276da39aSCy Schubert #endif 104276da39aSCy Schubert #endif 105276da39aSCy Schubert #ifndef UNITY_POINTER_WIDTH 106276da39aSCy Schubert #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH 107276da39aSCy Schubert #endif 108276da39aSCy Schubert 109276da39aSCy Schubert //------------------------------------------------------- 110276da39aSCy Schubert // Int Support (Define types based on detected sizes) 111276da39aSCy Schubert //------------------------------------------------------- 112276da39aSCy Schubert 113276da39aSCy Schubert #if (UNITY_INT_WIDTH == 32) 114276da39aSCy Schubert typedef unsigned char _UU8; 115276da39aSCy Schubert typedef unsigned short _UU16; 116276da39aSCy Schubert typedef unsigned int _UU32; 117276da39aSCy Schubert typedef signed char _US8; 118276da39aSCy Schubert typedef signed short _US16; 119276da39aSCy Schubert typedef signed int _US32; 120276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 16) 121276da39aSCy Schubert typedef unsigned char _UU8; 122276da39aSCy Schubert typedef unsigned int _UU16; 123276da39aSCy Schubert typedef unsigned long _UU32; 124276da39aSCy Schubert typedef signed char _US8; 125276da39aSCy Schubert typedef signed int _US16; 126276da39aSCy Schubert typedef signed long _US32; 127276da39aSCy Schubert #else 128276da39aSCy Schubert #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported) 129276da39aSCy Schubert #endif 130276da39aSCy Schubert 131276da39aSCy Schubert //------------------------------------------------------- 132276da39aSCy Schubert // 64-bit Support 133276da39aSCy Schubert //------------------------------------------------------- 134276da39aSCy Schubert 135276da39aSCy Schubert #ifndef UNITY_SUPPORT_64 136276da39aSCy Schubert #if UNITY_LONG_WIDTH > 32 137276da39aSCy Schubert #define UNITY_SUPPORT_64 138276da39aSCy Schubert #endif 139276da39aSCy Schubert #endif 140276da39aSCy Schubert #ifndef UNITY_SUPPORT_64 141276da39aSCy Schubert #if UNITY_POINTER_WIDTH > 32 142276da39aSCy Schubert #define UNITY_SUPPORT_64 143276da39aSCy Schubert #endif 144276da39aSCy Schubert #endif 145276da39aSCy Schubert 146276da39aSCy Schubert #ifndef UNITY_SUPPORT_64 147276da39aSCy Schubert 148276da39aSCy Schubert //No 64-bit Support 149276da39aSCy Schubert typedef _UU32 _U_UINT; 150276da39aSCy Schubert typedef _US32 _U_SINT; 151276da39aSCy Schubert 152276da39aSCy Schubert #else 153276da39aSCy Schubert 154276da39aSCy Schubert //64-bit Support 155276da39aSCy Schubert #if (UNITY_LONG_WIDTH == 32) 156276da39aSCy Schubert typedef unsigned long long _UU64; 157276da39aSCy Schubert typedef signed long long _US64; 158276da39aSCy Schubert #elif (UNITY_LONG_WIDTH == 64) 159276da39aSCy Schubert typedef unsigned long _UU64; 160276da39aSCy Schubert typedef signed long _US64; 161276da39aSCy Schubert #else 162276da39aSCy Schubert #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) 163276da39aSCy Schubert #endif 164276da39aSCy Schubert typedef _UU64 _U_UINT; 165276da39aSCy Schubert typedef _US64 _U_SINT; 166276da39aSCy Schubert 167276da39aSCy Schubert #endif 168276da39aSCy Schubert 169276da39aSCy Schubert //------------------------------------------------------- 170276da39aSCy Schubert // Pointer Support 171276da39aSCy Schubert //------------------------------------------------------- 172276da39aSCy Schubert 173276da39aSCy Schubert #if (UNITY_POINTER_WIDTH == 32) 174276da39aSCy Schubert typedef _UU32 _UP; 175276da39aSCy Schubert #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 176276da39aSCy Schubert #elif (UNITY_POINTER_WIDTH == 64) 177276da39aSCy Schubert typedef _UU64 _UP; 178276da39aSCy Schubert #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 179276da39aSCy Schubert #elif (UNITY_POINTER_WIDTH == 16) 180276da39aSCy Schubert typedef _UU16 _UP; 181276da39aSCy Schubert #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 182276da39aSCy Schubert #else 183276da39aSCy Schubert #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) 184276da39aSCy Schubert #endif 185276da39aSCy Schubert 186276da39aSCy Schubert #ifndef UNITY_PTR_ATTRIBUTE 187276da39aSCy Schubert #define UNITY_PTR_ATTRIBUTE 188276da39aSCy Schubert #endif 189276da39aSCy Schubert 190276da39aSCy Schubert //------------------------------------------------------- 191276da39aSCy Schubert // Float Support 192276da39aSCy Schubert //------------------------------------------------------- 193276da39aSCy Schubert 194276da39aSCy Schubert #ifdef UNITY_EXCLUDE_FLOAT 195276da39aSCy Schubert 196276da39aSCy Schubert //No Floating Point Support 197276da39aSCy Schubert #undef UNITY_INCLUDE_FLOAT 198276da39aSCy Schubert #undef UNITY_FLOAT_PRECISION 199276da39aSCy Schubert #undef UNITY_FLOAT_TYPE 200276da39aSCy Schubert #undef UNITY_FLOAT_VERBOSE 201276da39aSCy Schubert 202276da39aSCy Schubert #else 203276da39aSCy Schubert 204276da39aSCy Schubert #ifndef UNITY_INCLUDE_FLOAT 205276da39aSCy Schubert #define UNITY_INCLUDE_FLOAT 206276da39aSCy Schubert #endif 207276da39aSCy Schubert 208276da39aSCy Schubert //Floating Point Support 209276da39aSCy Schubert #ifndef UNITY_FLOAT_PRECISION 210276da39aSCy Schubert #define UNITY_FLOAT_PRECISION (0.00001f) 211276da39aSCy Schubert #endif 212276da39aSCy Schubert #ifndef UNITY_FLOAT_TYPE 213276da39aSCy Schubert #define UNITY_FLOAT_TYPE float 214276da39aSCy Schubert #endif 215276da39aSCy Schubert typedef UNITY_FLOAT_TYPE _UF; 216276da39aSCy Schubert 217276da39aSCy Schubert #endif 218276da39aSCy Schubert 219276da39aSCy Schubert //------------------------------------------------------- 220276da39aSCy Schubert // Double Float Support 221276da39aSCy Schubert //------------------------------------------------------- 222276da39aSCy Schubert 223276da39aSCy Schubert //unlike FLOAT, we DON'T include by default 224276da39aSCy Schubert #ifndef UNITY_EXCLUDE_DOUBLE 225276da39aSCy Schubert #ifndef UNITY_INCLUDE_DOUBLE 226276da39aSCy Schubert #define UNITY_EXCLUDE_DOUBLE 227276da39aSCy Schubert #endif 228276da39aSCy Schubert #endif 229276da39aSCy Schubert 230276da39aSCy Schubert #ifdef UNITY_EXCLUDE_DOUBLE 231276da39aSCy Schubert 232276da39aSCy Schubert //No Floating Point Support 233276da39aSCy Schubert #undef UNITY_DOUBLE_PRECISION 234276da39aSCy Schubert #undef UNITY_DOUBLE_TYPE 235276da39aSCy Schubert #undef UNITY_DOUBLE_VERBOSE 236276da39aSCy Schubert 237276da39aSCy Schubert #ifdef UNITY_INCLUDE_DOUBLE 238276da39aSCy Schubert #undef UNITY_INCLUDE_DOUBLE 239276da39aSCy Schubert #endif 240276da39aSCy Schubert 241276da39aSCy Schubert #else 242276da39aSCy Schubert 243276da39aSCy Schubert //Double Floating Point Support 244276da39aSCy Schubert #ifndef UNITY_DOUBLE_PRECISION 245276da39aSCy Schubert #define UNITY_DOUBLE_PRECISION (1e-12f) 246276da39aSCy Schubert #endif 247276da39aSCy Schubert #ifndef UNITY_DOUBLE_TYPE 248276da39aSCy Schubert #define UNITY_DOUBLE_TYPE double 249276da39aSCy Schubert #endif 250276da39aSCy Schubert typedef UNITY_DOUBLE_TYPE _UD; 251276da39aSCy Schubert 252276da39aSCy Schubert #endif 253276da39aSCy Schubert 254276da39aSCy Schubert #ifdef UNITY_DOUBLE_VERBOSE 255276da39aSCy Schubert #ifndef UNITY_FLOAT_VERBOSE 256276da39aSCy Schubert #define UNITY_FLOAT_VERBOSE 257276da39aSCy Schubert #endif 258276da39aSCy Schubert #endif 259276da39aSCy Schubert 260276da39aSCy Schubert //------------------------------------------------------- 261276da39aSCy Schubert // Output Method: stdout (DEFAULT) 262276da39aSCy Schubert //------------------------------------------------------- 263276da39aSCy Schubert #ifndef UNITY_OUTPUT_CHAR 264276da39aSCy Schubert //Default to using putchar, which is defined in stdio.h 265276da39aSCy Schubert #include <stdio.h> 266276da39aSCy Schubert #define UNITY_OUTPUT_CHAR(a) putchar(a) 267276da39aSCy Schubert #else 268276da39aSCy Schubert //If defined as something else, make sure we declare it here so it's ready for use 269276da39aSCy Schubert extern int UNITY_OUTPUT_CHAR(int); 270276da39aSCy Schubert #endif 271276da39aSCy Schubert 272276da39aSCy Schubert #ifndef UNITY_OUTPUT_START 273276da39aSCy Schubert #define UNITY_OUTPUT_START() 274276da39aSCy Schubert #endif 275276da39aSCy Schubert 276276da39aSCy Schubert #ifndef UNITY_OUTPUT_COMPLETE 277276da39aSCy Schubert #define UNITY_OUTPUT_COMPLETE() 278276da39aSCy Schubert #endif 279276da39aSCy Schubert 280276da39aSCy Schubert //------------------------------------------------------- 281276da39aSCy Schubert // Footprint 282276da39aSCy Schubert //------------------------------------------------------- 283276da39aSCy Schubert 284276da39aSCy Schubert #ifndef UNITY_LINE_TYPE 285276da39aSCy Schubert #define UNITY_LINE_TYPE _U_UINT 286276da39aSCy Schubert #endif 287276da39aSCy Schubert 288276da39aSCy Schubert #ifndef UNITY_COUNTER_TYPE 289276da39aSCy Schubert #define UNITY_COUNTER_TYPE _U_UINT 290276da39aSCy Schubert #endif 291276da39aSCy Schubert 292276da39aSCy Schubert //------------------------------------------------------- 293276da39aSCy Schubert // Language Features Available 294276da39aSCy Schubert //------------------------------------------------------- 295276da39aSCy Schubert #if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) 296276da39aSCy Schubert # ifdef __GNUC__ // includes clang 297276da39aSCy Schubert # if !(defined(__WIN32__) && defined(__clang__)) 298276da39aSCy Schubert # define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) 299276da39aSCy Schubert # endif 300276da39aSCy Schubert # endif 301276da39aSCy Schubert #endif 302276da39aSCy Schubert 303276da39aSCy Schubert #ifdef UNITY_NO_WEAK 304276da39aSCy Schubert # undef UNITY_WEAK_ATTRIBUTE 305276da39aSCy Schubert # undef UNITY_WEAK_PRAGMA 306276da39aSCy Schubert #endif 307276da39aSCy Schubert 308276da39aSCy Schubert 309276da39aSCy Schubert //------------------------------------------------------- 310276da39aSCy Schubert // Internal Structs Needed 311276da39aSCy Schubert //------------------------------------------------------- 312276da39aSCy Schubert 313276da39aSCy Schubert typedef void (*UnityTestFunction)(void); 314276da39aSCy Schubert 315276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_INT (0x10) 316276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_UINT (0x20) 317276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_HEX (0x40) 318276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_AUTO (0x80) 319276da39aSCy Schubert 320276da39aSCy Schubert typedef enum 321276da39aSCy Schubert { 322276da39aSCy Schubert #if (UNITY_INT_WIDTH == 16) 323276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 2 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 324276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 32) 325276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 4 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 326276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 64) 327276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 8 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 328276da39aSCy Schubert #endif 329276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, 330276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, 331276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, 332276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 333276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, 334276da39aSCy Schubert #endif 335276da39aSCy Schubert 336276da39aSCy Schubert #if (UNITY_INT_WIDTH == 16) 337276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 2 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 338276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 32) 339276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 4 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 340276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 64) 341276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 8 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 342276da39aSCy Schubert #endif 343276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, 344276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, 345276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, 346276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 347276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT, 348276da39aSCy Schubert #endif 349276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX, 350276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX, 351276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX, 352276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 353276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, 354276da39aSCy Schubert #endif 355276da39aSCy Schubert UNITY_DISPLAY_STYLE_UNKNOWN 356276da39aSCy Schubert } UNITY_DISPLAY_STYLE_T; 357276da39aSCy Schubert 358276da39aSCy Schubert #ifndef UNITY_EXCLUDE_FLOAT 359276da39aSCy Schubert typedef enum _UNITY_FLOAT_TRAIT_T 360276da39aSCy Schubert { 361276da39aSCy Schubert UNITY_FLOAT_IS_NOT_INF = 0, 362276da39aSCy Schubert UNITY_FLOAT_IS_INF, 363276da39aSCy Schubert UNITY_FLOAT_IS_NOT_NEG_INF, 364276da39aSCy Schubert UNITY_FLOAT_IS_NEG_INF, 365276da39aSCy Schubert UNITY_FLOAT_IS_NOT_NAN, 366276da39aSCy Schubert UNITY_FLOAT_IS_NAN, 367276da39aSCy Schubert UNITY_FLOAT_IS_NOT_DET, 368276da39aSCy Schubert UNITY_FLOAT_IS_DET, 369276da39aSCy Schubert } UNITY_FLOAT_TRAIT_T; 370276da39aSCy Schubert #endif 371276da39aSCy Schubert 372276da39aSCy Schubert struct _Unity 373276da39aSCy Schubert { 374276da39aSCy Schubert const char* TestFile; 375276da39aSCy Schubert const char* CurrentTestName; 376276da39aSCy Schubert UNITY_LINE_TYPE CurrentTestLineNumber; 377276da39aSCy Schubert UNITY_COUNTER_TYPE NumberOfTests; 378276da39aSCy Schubert UNITY_COUNTER_TYPE TestFailures; 379276da39aSCy Schubert UNITY_COUNTER_TYPE TestIgnores; 380276da39aSCy Schubert UNITY_COUNTER_TYPE CurrentTestFailed; 381276da39aSCy Schubert UNITY_COUNTER_TYPE CurrentTestIgnored; 382276da39aSCy Schubert jmp_buf AbortFrame; 383276da39aSCy Schubert int isExpectingFail; 384276da39aSCy Schubert UNITY_COUNTER_TYPE TestXFAILS; 385276da39aSCy Schubert UNITY_COUNTER_TYPE TestPasses; 386276da39aSCy Schubert UNITY_COUNTER_TYPE TestXPASSES; 387276da39aSCy Schubert const char* XFAILMessage; 388276da39aSCy Schubert }; 389276da39aSCy Schubert 390276da39aSCy Schubert extern struct _Unity Unity; 391276da39aSCy Schubert 392276da39aSCy Schubert //------------------------------------------------------- 393276da39aSCy Schubert // Test Suite Management 394276da39aSCy Schubert //------------------------------------------------------- 395276da39aSCy Schubert 396276da39aSCy Schubert void UnityBegin(const char* filename); 397276da39aSCy Schubert int UnityEnd(void); 398276da39aSCy Schubert void UnityConcludeTest(void); 399276da39aSCy Schubert void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); 400276da39aSCy Schubert 401276da39aSCy Schubert //------------------------------------------------------- 402276da39aSCy Schubert // Test Output 403276da39aSCy Schubert //------------------------------------------------------- 404276da39aSCy Schubert 405276da39aSCy Schubert void UnityPrint(const char* string); 406276da39aSCy Schubert void UnityPrintMask(const _U_UINT mask, const _U_UINT number); 407276da39aSCy Schubert void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style); 408276da39aSCy Schubert void UnityPrintNumber(const _U_SINT number); 409276da39aSCy Schubert void UnityPrintNumberUnsigned(const _U_UINT number); 410276da39aSCy Schubert void UnityPrintNumberHex(const _U_UINT number, const char nibbles); 411276da39aSCy Schubert 412276da39aSCy Schubert #ifdef UNITY_FLOAT_VERBOSE 413276da39aSCy Schubert void UnityPrintFloat(const _UF number); 414276da39aSCy Schubert #endif 415276da39aSCy Schubert 416276da39aSCy Schubert //------------------------------------------------------- 417276da39aSCy Schubert // Test Assertion Fuctions 418276da39aSCy Schubert //------------------------------------------------------- 419276da39aSCy Schubert // Use the macros below this section instead of calling 420276da39aSCy Schubert // these directly. The macros have a consistent naming 421276da39aSCy Schubert // convention and will pull in file and line information 422276da39aSCy Schubert // for you. 423276da39aSCy Schubert 424276da39aSCy Schubert void UnityAssertEqualNumber(const _U_SINT expected, 425276da39aSCy Schubert const _U_SINT actual, 426276da39aSCy Schubert const char* msg, 427276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 428276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 429276da39aSCy Schubert 430276da39aSCy Schubert void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected, 431276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const void* actual, 432276da39aSCy Schubert const _UU32 num_elements, 433276da39aSCy Schubert const char* msg, 434276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 435276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 436276da39aSCy Schubert 437276da39aSCy Schubert void UnityAssertBits(const _U_SINT mask, 438276da39aSCy Schubert const _U_SINT expected, 439276da39aSCy Schubert const _U_SINT actual, 440276da39aSCy Schubert const char* msg, 441276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 442276da39aSCy Schubert 443276da39aSCy Schubert void UnityAssertEqualString(const char* expected, 444276da39aSCy Schubert const char* actual, 445276da39aSCy Schubert const char* msg, 446276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 447276da39aSCy Schubert 448276da39aSCy Schubert void UnityAssertEqualStringArray( const char** expected, 449276da39aSCy Schubert const char** actual, 450276da39aSCy Schubert const _UU32 num_elements, 451276da39aSCy Schubert const char* msg, 452276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 453276da39aSCy Schubert 454276da39aSCy Schubert void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected, 455276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const void* actual, 456276da39aSCy Schubert const _UU32 length, 457276da39aSCy Schubert const _UU32 num_elements, 458276da39aSCy Schubert const char* msg, 459276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 460276da39aSCy Schubert 461276da39aSCy Schubert void UnityAssertNumbersWithin(const _U_SINT delta, 462276da39aSCy Schubert const _U_SINT expected, 463276da39aSCy Schubert const _U_SINT actual, 464276da39aSCy Schubert const char* msg, 465276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 466276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 467276da39aSCy Schubert 468276da39aSCy Schubert void UnityFail(const char* message, const UNITY_LINE_TYPE line); 469276da39aSCy Schubert 470276da39aSCy Schubert void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); 471276da39aSCy Schubert 472276da39aSCy Schubert #ifndef UNITY_EXCLUDE_FLOAT 473276da39aSCy Schubert void UnityAssertFloatsWithin(const _UF delta, 474276da39aSCy Schubert const _UF expected, 475276da39aSCy Schubert const _UF actual, 476276da39aSCy Schubert const char* msg, 477276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 478276da39aSCy Schubert 479276da39aSCy Schubert void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected, 480276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const _UF* actual, 481276da39aSCy Schubert const _UU32 num_elements, 482276da39aSCy Schubert const char* msg, 483276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 484276da39aSCy Schubert 485276da39aSCy Schubert void UnityAssertFloatSpecial(const _UF actual, 486276da39aSCy Schubert const char* msg, 487276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 488276da39aSCy Schubert const UNITY_FLOAT_TRAIT_T style); 489276da39aSCy Schubert #endif 490276da39aSCy Schubert 491276da39aSCy Schubert #ifndef UNITY_EXCLUDE_DOUBLE 492276da39aSCy Schubert void UnityAssertDoublesWithin(const _UD delta, 493276da39aSCy Schubert const _UD expected, 494276da39aSCy Schubert const _UD actual, 495276da39aSCy Schubert const char* msg, 496276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 497276da39aSCy Schubert 498276da39aSCy Schubert void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected, 499276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const _UD* actual, 500276da39aSCy Schubert const _UU32 num_elements, 501276da39aSCy Schubert const char* msg, 502276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 503276da39aSCy Schubert 504276da39aSCy Schubert void UnityAssertDoubleSpecial(const _UD actual, 505276da39aSCy Schubert const char* msg, 506276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 507276da39aSCy Schubert const UNITY_FLOAT_TRAIT_T style); 508276da39aSCy Schubert #endif 509276da39aSCy Schubert 510276da39aSCy Schubert //------------------------------------------------------- 511276da39aSCy Schubert // Error Strings We Might Need 512276da39aSCy Schubert //------------------------------------------------------- 513276da39aSCy Schubert 514276da39aSCy Schubert extern const char UnityStrErrFloat[]; 515276da39aSCy Schubert extern const char UnityStrErrDouble[]; 516276da39aSCy Schubert extern const char UnityStrErr64[]; 517276da39aSCy Schubert 518276da39aSCy Schubert //------------------------------------------------------- 519276da39aSCy Schubert // Test Running Macros 520276da39aSCy Schubert //------------------------------------------------------- 521276da39aSCy Schubert 522276da39aSCy Schubert #define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) 523276da39aSCy Schubert 524276da39aSCy Schubert #define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);} 525276da39aSCy Schubert 526276da39aSCy Schubert //This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) 527276da39aSCy Schubert #ifndef RUN_TEST 528276da39aSCy Schubert #ifdef __STDC_VERSION__ 529276da39aSCy Schubert #if __STDC_VERSION__ >= 199901L 530276da39aSCy Schubert #define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) 531276da39aSCy Schubert #define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) 532276da39aSCy Schubert #define RUN_TEST_FIRST_HELPER(first,...) first, #first 533276da39aSCy Schubert #define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) 534276da39aSCy Schubert #define RUN_TEST_SECOND_HELPER(first,second,...) second 535276da39aSCy Schubert #endif 536276da39aSCy Schubert #endif 537276da39aSCy Schubert #endif 538276da39aSCy Schubert 539276da39aSCy Schubert //If we can't do the tricky version, we'll just have to require them to always include the line number 540276da39aSCy Schubert #ifndef RUN_TEST 541276da39aSCy Schubert #ifdef CMOCK 542276da39aSCy Schubert #define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) 543276da39aSCy Schubert #else 544276da39aSCy Schubert #define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) 545276da39aSCy Schubert #endif 546276da39aSCy Schubert #endif 547276da39aSCy Schubert 548276da39aSCy Schubert #define TEST_LINE_NUM (Unity.CurrentTestLineNumber) 549276da39aSCy Schubert #define TEST_IS_IGNORED (Unity.CurrentTestIgnored) 550276da39aSCy Schubert #define UNITY_NEW_TEST(a) \ 551276da39aSCy Schubert Unity.CurrentTestName = a; \ 552276da39aSCy Schubert Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \ 553276da39aSCy Schubert Unity.NumberOfTests++; 554276da39aSCy Schubert 555276da39aSCy Schubert #ifndef UNITY_BEGIN 556276da39aSCy Schubert #define UNITY_BEGIN() UnityBegin(__FILE__) 557276da39aSCy Schubert #endif 558276da39aSCy Schubert 559276da39aSCy Schubert #ifndef UNITY_END 560276da39aSCy Schubert #define UNITY_END() UnityEnd() 561276da39aSCy Schubert #endif 562276da39aSCy Schubert 563276da39aSCy Schubert //------------------------------------------------------- 564276da39aSCy Schubert // Basic Fail and Ignore 565276da39aSCy Schubert //------------------------------------------------------- 566276da39aSCy Schubert 567276da39aSCy Schubert #define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)line); 568276da39aSCy Schubert #define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)line); 569276da39aSCy Schubert 570276da39aSCy Schubert //------------------------------------------------------- 571276da39aSCy Schubert // Test Asserts 572276da39aSCy Schubert //------------------------------------------------------- 573276da39aSCy Schubert 574276da39aSCy Schubert #define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, message);} 575276da39aSCy Schubert #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)line, message) 576276da39aSCy Schubert #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)line, message) 577276da39aSCy Schubert 578276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT) 579276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8) 580276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16) 581276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32) 582276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT) 583276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU8 )(expected), (_U_SINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8) 584276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU16)(expected), (_U_SINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16) 585276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU32)(expected), (_U_SINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32) 586276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8) 587276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16) 588276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32) 589276da39aSCy Schubert #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((_U_SINT)(mask), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line) 590276da39aSCy Schubert 591276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT) 592276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US8 )(delta), (_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8) 593276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US16)(delta), (_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16) 594276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US32)(delta), (_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32) 595276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT) 596276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8) 597276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16) 598276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32) 599276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8) 600276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16) 601276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32) 602276da39aSCy Schubert 603276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER) 604276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line) 605276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line) 606276da39aSCy Schubert 607276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT) 608276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8) 609276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16) 610276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32) 611276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT) 612276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8) 613276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16) 614276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32) 615276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8) 616276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16) 617276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32) 618276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(_UP*)(expected), (const void*)(_UP*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER) 619276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((const char**)(expected), (const char**)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line) 620276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line) 621276da39aSCy Schubert 622276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 623276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64) 624276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64) 625276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64) 626276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64) 627276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64) 628276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64) 629276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64) 630276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64) 631276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64) 632276da39aSCy Schubert #else 633276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 634276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 635276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 636276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 637276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 638276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 639276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 640276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 641276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 642276da39aSCy Schubert #endif 643276da39aSCy Schubert 644276da39aSCy Schubert #ifdef UNITY_EXCLUDE_FLOAT 645276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 646276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 647276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 648276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 649276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 650276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 651276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 652276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 653276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 654276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 655276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 656276da39aSCy Schubert #else 657276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)line) 658276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((_UF)(expected) * (_UF)UNITY_FLOAT_PRECISION, (_UF)expected, (_UF)actual, (UNITY_LINE_TYPE)line, message) 659276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((_UF*)(expected), (_UF*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line) 660276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF) 661276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF) 662276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN) 663276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET) 664276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF) 665276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF) 666276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN) 667276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET) 668276da39aSCy Schubert #endif 669276da39aSCy Schubert 670276da39aSCy Schubert #ifdef UNITY_EXCLUDE_DOUBLE 671276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 672276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 673276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 674276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 675276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 676276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 677276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 678276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 679276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 680276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 681276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 682276da39aSCy Schubert #else 683276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line) 684276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((_UD)(expected) * (_UD)UNITY_DOUBLE_PRECISION, (_UD)expected, (_UD)actual, (UNITY_LINE_TYPE)line, message) 685276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((_UD*)(expected), (_UD*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line) 686276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF) 687276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF) 688276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN) 689276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET) 690276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF) 691276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF) 692276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN) 693276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET) 694276da39aSCy Schubert #endif 695276da39aSCy Schubert 696276da39aSCy Schubert //End of UNITY_INTERNALS_H 697276da39aSCy Schubert #endif 698276da39aSCy Schubert 699276da39aSCy Schubert //#define TEST_EXPECT_FAIL() Unity.isExpectingFail = 1; 700276da39aSCy Schubert //#define TEST_EXPECT_FAIL_MESSAGE(message) Unity.isExpectingFail = 1; Unity.XFAILMessage = message; //PROBLEM : does this work on all compilers? 701276da39aSCy Schubert 702276da39aSCy Schubert #define TEST_EXPECT_FAIL() UnityExpectFail(); 703276da39aSCy Schubert #define TEST_EXPECT_FAIL_MESSAGE(message) UnityExpectFailMessage( (message) ); 704