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 859034852cSGleb Smirnoff #if (UINTPTR_MAX+0 <= 0xFFFF) 86276da39aSCy Schubert #define UNITY_POINTER_WIDTH (16) 879034852cSGleb Smirnoff #elif (UINTPTR_MAX+0 <= 0xFFFFFFFF) 88276da39aSCy Schubert #define UNITY_POINTER_WIDTH (32) 899034852cSGleb 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 969034852cSGleb Smirnoff #if (INTPTR_MAX+0 <= 0x7FFF) 97276da39aSCy Schubert #define UNITY_POINTER_WIDTH (16) 989034852cSGleb Smirnoff #elif (INTPTR_MAX+0 <= 0x7FFFFFFF) 99276da39aSCy Schubert #define UNITY_POINTER_WIDTH (32) 1009034852cSGleb 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 3083311ff84SXin LI #if !defined(UNITY_NORETURN_ATTRIBUTE) 3093311ff84SXin LI # ifdef __GNUC__ // includes clang 3103311ff84SXin LI # if !(defined(__WIN32__) && defined(__clang__)) 311a466cc55SCy Schubert # define UNITY_NORETURN_ATTRIBUTE __attribute__((__noreturn__)) 3123311ff84SXin LI # endif 3133311ff84SXin LI # endif 3143311ff84SXin LI #endif 3153311ff84SXin LI 3163311ff84SXin LI #ifndef UNITY_NORETURN_ATTRIBUTE 3173311ff84SXin LI # define UNITY_NORETURN_ATTRIBUTE 3183311ff84SXin LI #endif 3193311ff84SXin LI 320276da39aSCy Schubert 321276da39aSCy Schubert //------------------------------------------------------- 322276da39aSCy Schubert // Internal Structs Needed 323276da39aSCy Schubert //------------------------------------------------------- 324276da39aSCy Schubert 325276da39aSCy Schubert typedef void (*UnityTestFunction)(void); 326276da39aSCy Schubert 327276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_INT (0x10) 328276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_UINT (0x20) 329276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_HEX (0x40) 330276da39aSCy Schubert #define UNITY_DISPLAY_RANGE_AUTO (0x80) 331276da39aSCy Schubert 332276da39aSCy Schubert typedef enum 333276da39aSCy Schubert { 334276da39aSCy Schubert #if (UNITY_INT_WIDTH == 16) 335276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 2 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 336276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 32) 337276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 4 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 338276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 64) 339276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT = 8 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO, 340276da39aSCy Schubert #endif 341276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, 342276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, 343276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, 344276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 345276da39aSCy Schubert UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, 346276da39aSCy Schubert #endif 347276da39aSCy Schubert 348276da39aSCy Schubert #if (UNITY_INT_WIDTH == 16) 349276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 2 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 350276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 32) 351276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 4 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 352276da39aSCy Schubert #elif (UNITY_INT_WIDTH == 64) 353276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT = 8 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO, 354276da39aSCy Schubert #endif 355276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, 356276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, 357276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, 358276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 359276da39aSCy Schubert UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT, 360276da39aSCy Schubert #endif 361276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX, 362276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX, 363276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX, 364276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 365276da39aSCy Schubert UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, 366276da39aSCy Schubert #endif 367276da39aSCy Schubert UNITY_DISPLAY_STYLE_UNKNOWN 368276da39aSCy Schubert } UNITY_DISPLAY_STYLE_T; 369276da39aSCy Schubert 370276da39aSCy Schubert #ifndef UNITY_EXCLUDE_FLOAT 371276da39aSCy Schubert typedef enum _UNITY_FLOAT_TRAIT_T 372276da39aSCy Schubert { 373276da39aSCy Schubert UNITY_FLOAT_IS_NOT_INF = 0, 374276da39aSCy Schubert UNITY_FLOAT_IS_INF, 375276da39aSCy Schubert UNITY_FLOAT_IS_NOT_NEG_INF, 376276da39aSCy Schubert UNITY_FLOAT_IS_NEG_INF, 377276da39aSCy Schubert UNITY_FLOAT_IS_NOT_NAN, 378276da39aSCy Schubert UNITY_FLOAT_IS_NAN, 379276da39aSCy Schubert UNITY_FLOAT_IS_NOT_DET, 380276da39aSCy Schubert UNITY_FLOAT_IS_DET, 381276da39aSCy Schubert } UNITY_FLOAT_TRAIT_T; 382276da39aSCy Schubert #endif 383276da39aSCy Schubert 384276da39aSCy Schubert struct _Unity 385276da39aSCy Schubert { 386276da39aSCy Schubert const char* TestFile; 387276da39aSCy Schubert const char* CurrentTestName; 388276da39aSCy Schubert UNITY_LINE_TYPE CurrentTestLineNumber; 389276da39aSCy Schubert UNITY_COUNTER_TYPE NumberOfTests; 390276da39aSCy Schubert UNITY_COUNTER_TYPE TestFailures; 391276da39aSCy Schubert UNITY_COUNTER_TYPE TestIgnores; 392276da39aSCy Schubert UNITY_COUNTER_TYPE CurrentTestFailed; 393276da39aSCy Schubert UNITY_COUNTER_TYPE CurrentTestIgnored; 394276da39aSCy Schubert jmp_buf AbortFrame; 395276da39aSCy Schubert int isExpectingFail; 396276da39aSCy Schubert UNITY_COUNTER_TYPE TestXFAILS; 397276da39aSCy Schubert UNITY_COUNTER_TYPE TestPasses; 398276da39aSCy Schubert UNITY_COUNTER_TYPE TestXPASSES; 399276da39aSCy Schubert const char* XFAILMessage; 400276da39aSCy Schubert }; 401276da39aSCy Schubert 402276da39aSCy Schubert extern struct _Unity Unity; 403276da39aSCy Schubert 404276da39aSCy Schubert //------------------------------------------------------- 405276da39aSCy Schubert // Test Suite Management 406276da39aSCy Schubert //------------------------------------------------------- 407276da39aSCy Schubert 408276da39aSCy Schubert void UnityBegin(const char* filename); 409276da39aSCy Schubert int UnityEnd(void); 410276da39aSCy Schubert void UnityConcludeTest(void); 411276da39aSCy Schubert void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); 412276da39aSCy Schubert 413276da39aSCy Schubert //------------------------------------------------------- 414276da39aSCy Schubert // Test Output 415276da39aSCy Schubert //------------------------------------------------------- 416276da39aSCy Schubert 417276da39aSCy Schubert void UnityPrint(const char* string); 418276da39aSCy Schubert void UnityPrintMask(const _U_UINT mask, const _U_UINT number); 419276da39aSCy Schubert void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style); 420276da39aSCy Schubert void UnityPrintNumber(const _U_SINT number); 421276da39aSCy Schubert void UnityPrintNumberUnsigned(const _U_UINT number); 422276da39aSCy Schubert void UnityPrintNumberHex(const _U_UINT number, const char nibbles); 423276da39aSCy Schubert 424276da39aSCy Schubert #ifdef UNITY_FLOAT_VERBOSE 425276da39aSCy Schubert void UnityPrintFloat(const _UF number); 426276da39aSCy Schubert #endif 427276da39aSCy Schubert 428276da39aSCy Schubert //------------------------------------------------------- 429276da39aSCy Schubert // Test Assertion Fuctions 430276da39aSCy Schubert //------------------------------------------------------- 431276da39aSCy Schubert // Use the macros below this section instead of calling 432276da39aSCy Schubert // these directly. The macros have a consistent naming 433276da39aSCy Schubert // convention and will pull in file and line information 434276da39aSCy Schubert // for you. 435276da39aSCy Schubert 436276da39aSCy Schubert void UnityAssertEqualNumber(const _U_SINT expected, 437276da39aSCy Schubert const _U_SINT actual, 438276da39aSCy Schubert const char* msg, 439276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 440276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 441276da39aSCy Schubert 442276da39aSCy Schubert void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected, 443276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const void* actual, 444276da39aSCy Schubert const _UU32 num_elements, 445276da39aSCy Schubert const char* msg, 446276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 447276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 448276da39aSCy Schubert 449276da39aSCy Schubert void UnityAssertBits(const _U_SINT mask, 450276da39aSCy Schubert const _U_SINT expected, 451276da39aSCy Schubert const _U_SINT actual, 452276da39aSCy Schubert const char* msg, 453276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 454276da39aSCy Schubert 455276da39aSCy Schubert void UnityAssertEqualString(const char* expected, 456276da39aSCy Schubert const char* actual, 457276da39aSCy Schubert const char* msg, 458276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 459276da39aSCy Schubert 460276da39aSCy Schubert void UnityAssertEqualStringArray( const char** expected, 461276da39aSCy Schubert const char** actual, 462276da39aSCy Schubert const _UU32 num_elements, 463276da39aSCy Schubert const char* msg, 464276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 465276da39aSCy Schubert 466276da39aSCy Schubert void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected, 467276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const void* actual, 468276da39aSCy Schubert const _UU32 length, 469276da39aSCy Schubert const _UU32 num_elements, 470276da39aSCy Schubert const char* msg, 471276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 472276da39aSCy Schubert 473276da39aSCy Schubert void UnityAssertNumbersWithin(const _U_SINT delta, 474276da39aSCy Schubert const _U_SINT expected, 475276da39aSCy Schubert const _U_SINT actual, 476276da39aSCy Schubert const char* msg, 477276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 478276da39aSCy Schubert const UNITY_DISPLAY_STYLE_T style); 479276da39aSCy Schubert 4803311ff84SXin LI void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_NORETURN_ATTRIBUTE; 481276da39aSCy Schubert 482276da39aSCy Schubert void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); 483276da39aSCy Schubert 484276da39aSCy Schubert #ifndef UNITY_EXCLUDE_FLOAT 485276da39aSCy Schubert void UnityAssertFloatsWithin(const _UF delta, 486276da39aSCy Schubert const _UF expected, 487276da39aSCy Schubert const _UF actual, 488276da39aSCy Schubert const char* msg, 489276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 490276da39aSCy Schubert 491276da39aSCy Schubert void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected, 492276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const _UF* actual, 493276da39aSCy Schubert const _UU32 num_elements, 494276da39aSCy Schubert const char* msg, 495276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 496276da39aSCy Schubert 497276da39aSCy Schubert void UnityAssertFloatSpecial(const _UF actual, 498276da39aSCy Schubert const char* msg, 499276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 500276da39aSCy Schubert const UNITY_FLOAT_TRAIT_T style); 501276da39aSCy Schubert #endif 502276da39aSCy Schubert 503276da39aSCy Schubert #ifndef UNITY_EXCLUDE_DOUBLE 504276da39aSCy Schubert void UnityAssertDoublesWithin(const _UD delta, 505276da39aSCy Schubert const _UD expected, 506276da39aSCy Schubert const _UD actual, 507276da39aSCy Schubert const char* msg, 508276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 509276da39aSCy Schubert 510276da39aSCy Schubert void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected, 511276da39aSCy Schubert UNITY_PTR_ATTRIBUTE const _UD* actual, 512276da39aSCy Schubert const _UU32 num_elements, 513276da39aSCy Schubert const char* msg, 514276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber); 515276da39aSCy Schubert 516276da39aSCy Schubert void UnityAssertDoubleSpecial(const _UD actual, 517276da39aSCy Schubert const char* msg, 518276da39aSCy Schubert const UNITY_LINE_TYPE lineNumber, 519276da39aSCy Schubert const UNITY_FLOAT_TRAIT_T style); 520276da39aSCy Schubert #endif 521276da39aSCy Schubert 522*f5f40dd6SCy Schubert void UnityExpectFailMessage(const char* msg, 523*f5f40dd6SCy Schubert const UNITY_LINE_TYPE line); 524*f5f40dd6SCy Schubert 525276da39aSCy Schubert //------------------------------------------------------- 526276da39aSCy Schubert // Error Strings We Might Need 527276da39aSCy Schubert //------------------------------------------------------- 528276da39aSCy Schubert 529276da39aSCy Schubert extern const char UnityStrErrFloat[]; 530276da39aSCy Schubert extern const char UnityStrErrDouble[]; 531276da39aSCy Schubert extern const char UnityStrErr64[]; 532276da39aSCy Schubert 533276da39aSCy Schubert //------------------------------------------------------- 534276da39aSCy Schubert // Test Running Macros 535276da39aSCy Schubert //------------------------------------------------------- 536276da39aSCy Schubert 537276da39aSCy Schubert #define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) 538276da39aSCy Schubert 539276da39aSCy Schubert #define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);} 540276da39aSCy Schubert 541276da39aSCy Schubert //This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) 542276da39aSCy Schubert #ifndef RUN_TEST 543276da39aSCy Schubert #ifdef __STDC_VERSION__ 544276da39aSCy Schubert #if __STDC_VERSION__ >= 199901L 545276da39aSCy Schubert #define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) 546276da39aSCy Schubert #define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) 547276da39aSCy Schubert #define RUN_TEST_FIRST_HELPER(first,...) first, #first 548276da39aSCy Schubert #define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) 549276da39aSCy Schubert #define RUN_TEST_SECOND_HELPER(first,second,...) second 550276da39aSCy Schubert #endif 551276da39aSCy Schubert #endif 552276da39aSCy Schubert #endif 553276da39aSCy Schubert 554276da39aSCy Schubert //If we can't do the tricky version, we'll just have to require them to always include the line number 555276da39aSCy Schubert #ifndef RUN_TEST 556276da39aSCy Schubert #ifdef CMOCK 557276da39aSCy Schubert #define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) 558276da39aSCy Schubert #else 559276da39aSCy Schubert #define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) 560276da39aSCy Schubert #endif 561276da39aSCy Schubert #endif 562276da39aSCy Schubert 563276da39aSCy Schubert #define TEST_LINE_NUM (Unity.CurrentTestLineNumber) 564276da39aSCy Schubert #define TEST_IS_IGNORED (Unity.CurrentTestIgnored) 565276da39aSCy Schubert #define UNITY_NEW_TEST(a) \ 566276da39aSCy Schubert Unity.CurrentTestName = a; \ 567276da39aSCy Schubert Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \ 568276da39aSCy Schubert Unity.NumberOfTests++; 569276da39aSCy Schubert 570276da39aSCy Schubert #ifndef UNITY_BEGIN 571276da39aSCy Schubert #define UNITY_BEGIN() UnityBegin(__FILE__) 572276da39aSCy Schubert #endif 573276da39aSCy Schubert 574276da39aSCy Schubert #ifndef UNITY_END 575276da39aSCy Schubert #define UNITY_END() UnityEnd() 576276da39aSCy Schubert #endif 577276da39aSCy Schubert 578276da39aSCy Schubert //------------------------------------------------------- 579276da39aSCy Schubert // Basic Fail and Ignore 580276da39aSCy Schubert //------------------------------------------------------- 581276da39aSCy Schubert 582276da39aSCy Schubert #define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)line); 583276da39aSCy Schubert #define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)line); 584276da39aSCy Schubert 585276da39aSCy Schubert //------------------------------------------------------- 586276da39aSCy Schubert // Test Asserts 587276da39aSCy Schubert //------------------------------------------------------- 588276da39aSCy Schubert 589276da39aSCy Schubert #define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, message);} 590276da39aSCy Schubert #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)line, message) 591276da39aSCy Schubert #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)line, message) 592276da39aSCy Schubert 593276da39aSCy 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) 594276da39aSCy 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) 595276da39aSCy 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) 596276da39aSCy 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) 597276da39aSCy 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) 598276da39aSCy 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) 599276da39aSCy 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) 600276da39aSCy 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) 601276da39aSCy 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) 602276da39aSCy 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) 603276da39aSCy 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) 604276da39aSCy 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) 605276da39aSCy Schubert 606276da39aSCy 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) 607276da39aSCy 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) 608276da39aSCy 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) 609276da39aSCy 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) 610276da39aSCy 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) 611276da39aSCy 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) 612276da39aSCy 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) 613276da39aSCy 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) 614276da39aSCy 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) 615276da39aSCy 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) 616276da39aSCy 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) 617276da39aSCy Schubert 618276da39aSCy 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) 619276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line) 62068ba7e87SXin LI #define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line) 621276da39aSCy Schubert 622276da39aSCy 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) 623276da39aSCy 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) 624276da39aSCy 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) 625276da39aSCy 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) 626276da39aSCy 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) 627276da39aSCy 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) 628276da39aSCy 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) 629276da39aSCy 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) 630276da39aSCy 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) 631276da39aSCy 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) 632276da39aSCy 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) 633276da39aSCy 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) 634276da39aSCy 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) 635276da39aSCy 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) 636276da39aSCy Schubert 637276da39aSCy Schubert #ifdef UNITY_SUPPORT_64 638276da39aSCy 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) 639276da39aSCy 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) 640276da39aSCy 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) 641276da39aSCy 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) 642276da39aSCy 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) 643276da39aSCy 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) 644276da39aSCy 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) 645276da39aSCy 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) 646276da39aSCy 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) 647276da39aSCy Schubert #else 648276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 649276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 650276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 651276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 652276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 653276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 654276da39aSCy Schubert #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 655276da39aSCy Schubert #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 656276da39aSCy Schubert #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64) 657276da39aSCy Schubert #endif 658276da39aSCy Schubert 659276da39aSCy Schubert #ifdef UNITY_EXCLUDE_FLOAT 660276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 661276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 662276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 663276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 664276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 665276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 666276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 667276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 668276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 669276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 670276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat) 671276da39aSCy Schubert #else 672276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)line) 673276da39aSCy 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) 674276da39aSCy 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) 675276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF) 676276da39aSCy 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) 677276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN) 678276da39aSCy Schubert #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET) 679276da39aSCy 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) 680276da39aSCy 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) 681276da39aSCy 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) 682276da39aSCy 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) 683276da39aSCy Schubert #endif 684276da39aSCy Schubert 685276da39aSCy Schubert #ifdef UNITY_EXCLUDE_DOUBLE 686276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 687276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 688276da39aSCy Schubert #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 689276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 690276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 691276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 692276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 693276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 694276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 695276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 696276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble) 697276da39aSCy Schubert #else 698276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line) 699276da39aSCy 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) 700276da39aSCy 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) 701276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF) 702276da39aSCy 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) 703276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN) 704276da39aSCy Schubert #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET) 705276da39aSCy 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) 706276da39aSCy 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) 707276da39aSCy 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) 708276da39aSCy 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) 709276da39aSCy Schubert #endif 710276da39aSCy Schubert 711276da39aSCy Schubert //End of UNITY_INTERNALS_H 712276da39aSCy Schubert #endif 713276da39aSCy Schubert 714*f5f40dd6SCy Schubert // Not part of standard distribution 715276da39aSCy Schubert 716276da39aSCy Schubert #define TEST_EXPECT_FAIL() UnityExpectFail(); 717*f5f40dd6SCy Schubert #define TEST_EXPECT_FAIL_MESSAGE(message) UnityExpectFailMessage((message), __LINE__); 718