Merge branch 'master' into more-float

This commit is contained in:
Jonathan Reichelt Gjertsen
2021-12-03 18:23:22 +01:00
6 changed files with 96 additions and 64 deletions

View File

@@ -49,11 +49,11 @@ set(UNITY_EXTENSION_FIXTURE_ENABLED $<BOOL:${UNITY_EXTENSION_FIXTURE}>)
set(UNITY_EXTENSION_MEMORY_ENABLED $<OR:${UNITY_EXTENSION_FIXTURE_ENABLED},$<BOOL:${UNITY_EXTENSION_MEMORY}>>)
if(${UNITY_EXTENSION_FIXTURE})
message(STATUS "Unity: Bulding with the fixture extension.")
message(STATUS "Unity: Building with the fixture extension.")
endif()
if(${UNITY_EXTENSION_MEMORY})
message(STATUS "Unity: Bulding with the memory extension.")
message(STATUS "Unity: Building with the memory extension.")
endif()
# Main target ------------------------------------------------------------------
@@ -99,7 +99,9 @@ set_target_properties(${PROJECT_NAME}
target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<C_COMPILER_ID:Clang>:-Wcast-align
# Clang
$<$<C_COMPILER_ID:Clang>:
-Wcast-align
-Wcast-qual
-Wconversion
-Wexit-time-destructors
@@ -111,8 +113,13 @@ target_compile_options(${PROJECT_NAME}
-Wshadow
-Wweak-vtables
-Werror
-Wall>
$<$<C_COMPILER_ID:GNU>:-Waddress
-Wall
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,8.0.0>:-Wextra-semi-stmt>
>
# GCC
$<$<C_COMPILER_ID:GNU>:
-Waddress
-Waggregate-return
-Wformat-nonliteral
-Wformat-security
@@ -128,8 +135,13 @@ target_compile_options(${PROJECT_NAME}
-Wwrite-strings
-Wpointer-arith
-Werror
-Wall>
$<$<C_COMPILER_ID:MSVC>:/Wall>
-Wall
>
# MSVC
$<$<C_COMPILER_ID:MSVC>:
/Wall
>
)
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake

View File

@@ -170,9 +170,9 @@ class UnityModuleGenerator
############################
def neutralize_filename(name, start_cap = true)
return name if name.empty?
name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map { |v| v.capitalize }.join('_')
name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map(&:capitalize).join('_')
name = name[0].downcase + name[1..-1] unless start_cap
return name
name
end
############################
@@ -211,8 +211,8 @@ class UnityModuleGenerator
f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil?
f.write(file[:template] % [file[:name],
file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join,
file[:name].upcase.gsub(/-/, '_'),
file[:name].gsub(/-/, '_')])
file[:name].upcase.tr('-', '_'),
file[:name].tr('-', '_')])
end
if @options[:update_svn]
`svn add \"#{file[:path]}\"`

View File

@@ -9,13 +9,20 @@
#define UNITY_FIXTURE_H_
#include "unity.h"
#include "unity_internals.h"
#include "unity_fixture_internals.h"
#ifndef UNITY_FIXTURE_NO_EXTRAS
#include "unity_memory.h"
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#include "unity_internals.h"
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
@@ -80,4 +87,8 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
#define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual))
#endif
#ifdef __cplusplus
}
#endif
#endif /* UNITY_FIXTURE_H_ */

View File

@@ -19,9 +19,9 @@ void UNITY_OUTPUT_CHAR(int);
#endif
/* Helpful macros for us to use here in Assert functions */
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT()
#define UNITY_FAIL_AND_BAIL do { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
#define UNITY_IGNORE_AND_BAIL do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
#define RETURN_IF_FAIL_OR_IGNORE do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0)
struct UNITY_STORAGE_T Unity;
@@ -369,9 +369,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
}
else
{
UNITY_INT32 n_int = 0, n;
UNITY_INT32 n_int = 0;
UNITY_INT32 n;
int exponent = 0;
int decimals, digits;
int decimals;
int digits;
char buf[16] = {0};
/*
@@ -450,9 +452,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
buf[digits++] = (char)('0' + n % 10);
n /= 10;
}
/* print out buffer (backwards) */
while (digits > 0)
{
if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); }
if (digits == decimals)
{
UNITY_OUTPUT_CHAR('.');
}
UNITY_OUTPUT_CHAR(buf[--digits]);
}
@@ -765,11 +772,12 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
}
#define UnityPrintPointlessAndBail() \
{ \
do { \
UnityTestResultsFailBegin(lineNumber); \
UnityPrint(UnityStrPointless); \
UnityAddMsgIfSpecified(msg); \
UNITY_FAIL_AND_BAIL; }
UNITY_FAIL_AND_BAIL; \
} while (0)
/*-----------------------------------------------*/
void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
@@ -884,11 +892,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
#ifndef UNITY_EXCLUDE_FLOAT_PRINT
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
{ \
do { \
UnityPrint(UnityStrExpected); \
UnityPrintFloat(expected); \
UnityPrint(UnityStrWas); \
UnityPrintFloat(actual); }
UnityPrintFloat(actual); \
} while (0)
#else
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
UnityPrint(UnityStrDelta)

View File

@@ -290,7 +290,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout)
#else
/* We've specified nothing, therefore flush should just be ignored */
#define UNITY_OUTPUT_FLUSH()
#define UNITY_OUTPUT_FLUSH() (void)0
#endif
#else
/* If defined as something else, make sure we declare it here so it's ready for use */
@@ -365,11 +365,11 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#endif
#ifndef UNITY_EXEC_TIME_START
#define UNITY_EXEC_TIME_START() do{}while(0)
#define UNITY_EXEC_TIME_START() do { /* nothing*/ } while (0)
#endif
#ifndef UNITY_EXEC_TIME_STOP
#define UNITY_EXEC_TIME_STOP() do{}while(0)
#define UNITY_EXEC_TIME_STOP() do { /* nothing*/ } while (0)
#endif
#ifndef UNITY_TIME_TYPE
@@ -377,7 +377,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#endif
#ifndef UNITY_PRINT_EXEC_TIME
#define UNITY_PRINT_EXEC_TIME() do{}while(0)
#define UNITY_PRINT_EXEC_TIME() do { /* nothing*/ } while (0)
#endif
/*-------------------------------------------------------
@@ -516,9 +516,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
#define UNITY_SET_DETAIL(d1)
#define UNITY_SET_DETAILS(d1,d2)
#else
#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); }
#define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0)
#define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0)
#define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0)
#ifndef UNITY_DETAIL1_NAME
#define UNITY_DETAIL1_NAME "Function"
@@ -798,7 +798,7 @@ int UnityTestMatches(void);
* Test Asserts
*-------------------------------------------------------*/
#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0)
#define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message)); } } while (0)
#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message))