vendor/unity/src/unity_internals.h in ceedling-0.15.2 vs vendor/unity/src/unity_internals.h in ceedling-0.15.3

- old
+ new

@@ -1,15 +1,18 @@ /* ========================================== Unity Project - A Test Framework for C - Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ #ifndef UNITY_INTERNALS_H #define UNITY_INTERNALS_H -#include <stdio.h> +#ifdef UNITY_INCLUDE_CONFIG_H +#include "unity_config.h" +#endif + #include <setjmp.h> // Unity Attempts to Auto-Detect Integer Types // Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h> // Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h> @@ -235,31 +238,42 @@ #undef UNITY_INCLUDE_DOUBLE #endif #else -//Floating Point Support +//Double Floating Point Support #ifndef UNITY_DOUBLE_PRECISION #define UNITY_DOUBLE_PRECISION (1e-12f) #endif #ifndef UNITY_DOUBLE_TYPE #define UNITY_DOUBLE_TYPE double #endif typedef UNITY_DOUBLE_TYPE _UD; #endif +#ifdef UNITY_DOUBLE_VERBOSE +#ifndef UNITY_FLOAT_VERBOSE +#define UNITY_FLOAT_VERBOSE +#endif +#endif + //------------------------------------------------------- // Output Method //------------------------------------------------------- #ifndef UNITY_OUTPUT_CHAR -//Default to using putchar, which is defined in stdio.h above + +//Default to using putchar, which is defined in stdio.h +#include <stdio.h> #define UNITY_OUTPUT_CHAR(a) putchar(a) + #else + //If defined as something else, make sure we declare it here so it's ready for use extern int UNITY_OUTPUT_CHAR(int); + #endif //------------------------------------------------------- // Footprint //------------------------------------------------------- @@ -495,10 +509,51 @@ extern const char* UnityStrErrFloat; extern const char* UnityStrErrDouble; extern const char* UnityStrErr64; //------------------------------------------------------- +// Test Running Macros +//------------------------------------------------------- + +#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) + +#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);} + +//This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) +#ifndef RUN_TEST +#ifdef __STDC_VERSION__ +#if __STDC_VERSION__ >= 199901L +#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) +#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) +#define RUN_TEST_FIRST_HELPER(first,...) first, #first +#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) +#define RUN_TEST_SECOND_HELPER(first,second,...) second +#endif +#endif +#endif + +//If we can't do the tricky version, we'll just have to require them to always include the line number +#ifndef RUN_TEST +#ifdef CMOCK +#define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) +#else +#define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) +#endif +#endif + +#define TEST_LINE_NUM (Unity.CurrentTestLineNumber) +#define TEST_IS_IGNORED (Unity.CurrentTestIgnored) + +#ifndef UNITY_BEGIN +#define UNITY_BEGIN() {UnityBegin(); Unity.TestFile = __FILE__;} +#endif + +#ifndef UNITY_END +#define UNITY_END() UnityEnd() +#endif + +//------------------------------------------------------- // Basic Fail and Ignore //------------------------------------------------------- #define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)line); #define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)line); @@ -627,6 +682,7 @@ #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) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET) #endif +//End of UNITY_INTERNALS_H #endif