mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-18 12:53:23 +08:00
- updated color handling by standardizing output
- cleaned up internal types - added verbose float support when sprintf is available and desirable - tested float array handling (and fixed a bug! woo!) git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@68 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@ -7,10 +7,11 @@ def report(message)
|
||||
if not $colour_output
|
||||
$stdout.puts(message)
|
||||
else
|
||||
message = message.join('\n') if (message.class == Array)
|
||||
message.each_line do |line|
|
||||
line.chomp!
|
||||
colour = case(line)
|
||||
when /Tests\s+(\d+)\s+Failures\s+\d+\s+Ignored/
|
||||
when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
|
||||
($1.to_i == 0) ? :green : :red
|
||||
when /PASS/
|
||||
:green
|
||||
@ -23,7 +24,7 @@ def report(message)
|
||||
when /^(?:Creating|Compiling|Linking)/
|
||||
:white
|
||||
else
|
||||
:blue
|
||||
:silver
|
||||
end
|
||||
colour_puts(colour, line)
|
||||
end
|
||||
|
@ -61,7 +61,7 @@ class UnityTestSummary
|
||||
@report += "--------------------------\n"
|
||||
@report += "OVERALL UNITY TEST SUMMARY\n"
|
||||
@report += "--------------------------\n"
|
||||
@report += "TOTAL TESTS: #{@total_tests} TOTAL FAILURES: #{@failures} IGNORED: #{@ignored}\n"
|
||||
@report += "#{@total_tests} TOTAL TESTS #{@failures} TOTAL FAILURES #{@ignored} IGNORED\n"
|
||||
@report += "\n"
|
||||
end
|
||||
|
||||
|
103
src/unity.c
103
src/unity.c
@ -36,24 +36,24 @@ void UnityPrint(const char* string)
|
||||
}
|
||||
}
|
||||
|
||||
void UnityPrintNumberByStyle(const long number, const UNITY_DISPLAY_STYLE_T style)
|
||||
void UnityPrintNumberByStyle(const _US32 number, const UNITY_DISPLAY_STYLE_T style)
|
||||
{
|
||||
switch (style)
|
||||
{
|
||||
case UNITY_DISPLAY_STYLE_HEX8: UnityPrintNumberHex((unsigned long)number, 2); break;
|
||||
case UNITY_DISPLAY_STYLE_HEX16: UnityPrintNumberHex((unsigned long)number, 4); break;
|
||||
case UNITY_DISPLAY_STYLE_HEX32: UnityPrintNumberHex((unsigned long)number, 8); break;
|
||||
case UNITY_DISPLAY_STYLE_UINT: UnityPrintNumberUnsigned((unsigned long)number); break;
|
||||
case UNITY_DISPLAY_STYLE_HEX8: UnityPrintNumberHex((_UU32)number, 2); break;
|
||||
case UNITY_DISPLAY_STYLE_HEX16: UnityPrintNumberHex((_UU32)number, 4); break;
|
||||
case UNITY_DISPLAY_STYLE_HEX32: UnityPrintNumberHex((_UU32)number, 8); break;
|
||||
case UNITY_DISPLAY_STYLE_UINT: UnityPrintNumberUnsigned((_UU32)number); break;
|
||||
default: UnityPrintNumber(number); break;
|
||||
}
|
||||
}
|
||||
|
||||
/// basically do an itoa using as little ram as possible
|
||||
void UnityPrintNumber(const long number_to_print)
|
||||
void UnityPrintNumber(const _US32 number_to_print)
|
||||
{
|
||||
long divisor = 1;
|
||||
long next_divisor;
|
||||
long number = number_to_print;
|
||||
_US32 divisor = 1;
|
||||
_US32 next_divisor;
|
||||
_US32 number = number_to_print;
|
||||
|
||||
if (number < 0)
|
||||
{
|
||||
@ -81,10 +81,10 @@ void UnityPrintNumber(const long number_to_print)
|
||||
}
|
||||
|
||||
/// basically do an itoa using as little ram as possible
|
||||
void UnityPrintNumberUnsigned(const unsigned long number)
|
||||
void UnityPrintNumberUnsigned(const _UU32 number)
|
||||
{
|
||||
unsigned long divisor = 1;
|
||||
unsigned long next_divisor;
|
||||
_UU32 divisor = 1;
|
||||
_UU32 next_divisor;
|
||||
|
||||
// figure out initial divisor
|
||||
while (number / divisor > 9)
|
||||
@ -105,9 +105,9 @@ void UnityPrintNumberUnsigned(const unsigned long number)
|
||||
while (divisor > 0);
|
||||
}
|
||||
|
||||
void UnityPrintNumberHex(const unsigned long number, const char nibbles_to_print)
|
||||
void UnityPrintNumberHex(const _UU32 number, const char nibbles_to_print)
|
||||
{
|
||||
unsigned long nibble;
|
||||
_UU32 nibble;
|
||||
char nibbles = nibbles_to_print;
|
||||
UnityPrint("0x");
|
||||
|
||||
@ -125,10 +125,10 @@ void UnityPrintNumberHex(const unsigned long number, const char nibbles_to_print
|
||||
}
|
||||
}
|
||||
|
||||
void UnityPrintMask(const unsigned long mask, const unsigned long number)
|
||||
void UnityPrintMask(const _UU32 mask, const _UU32 number)
|
||||
{
|
||||
unsigned long bit = 0x80000000;
|
||||
long i;
|
||||
_UU32 bit = 0x80000000;
|
||||
_US32 i;
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
@ -151,6 +151,15 @@ void UnityPrintMask(const unsigned long mask, const unsigned long number)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNITY_FLOAT_VERBOSE
|
||||
void UnityPrintFloat(_UF number)
|
||||
{
|
||||
char TempBuffer[32];
|
||||
sprintf(TempBuffer, "%.6f", number);
|
||||
UnityPrint(TempBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
||||
{
|
||||
UnityPrint(file);
|
||||
@ -200,9 +209,9 @@ void UnityAddMsgIfSpecified(const char* msg)
|
||||
// Assertion Functions
|
||||
//-----------------------------------------------
|
||||
|
||||
void UnityAssertBits(const long mask,
|
||||
const long expected,
|
||||
const long actual,
|
||||
void UnityAssertBits(const _US32 mask,
|
||||
const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
@ -218,8 +227,8 @@ void UnityAssertBits(const long mask,
|
||||
}
|
||||
}
|
||||
|
||||
void UnityAssertEqualNumber(const long expected,
|
||||
const long actual,
|
||||
void UnityAssertEqualNumber(const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style)
|
||||
@ -238,12 +247,12 @@ void UnityAssertEqualNumber(const long expected,
|
||||
|
||||
void UnityAssertEqualIntArray(const int* expected,
|
||||
const int* actual,
|
||||
const unsigned long num_elements,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style)
|
||||
{
|
||||
unsigned long elements = num_elements;
|
||||
_UU32 elements = num_elements;
|
||||
const _US32* ptr_exp32 = (_US32*)expected;
|
||||
const _US16* ptr_exp16 = (_US16*)expected;
|
||||
const _US8* ptr_exp8 = (_US8*)expected;
|
||||
@ -315,15 +324,17 @@ void UnityAssertEqualIntArray(const int* expected,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
const _UF* actual,
|
||||
const unsigned long num_elements,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
unsigned long elements = num_elements;
|
||||
_UU32 elements = num_elements;
|
||||
const _UF* ptr_expected = expected;
|
||||
const _UF* ptr_actual = actual;
|
||||
_UF diff;
|
||||
|
||||
if (elements == 0)
|
||||
{
|
||||
@ -335,12 +346,22 @@ void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
|
||||
while (elements--)
|
||||
{
|
||||
if ((*ptr_expected - *ptr_actual) > (UNITY_FLOAT_PRECISION * *ptr_expected))
|
||||
diff = *ptr_expected - *ptr_actual;
|
||||
if (diff < 0.0)
|
||||
diff = 0.0 - diff;
|
||||
if (diff > (UNITY_FLOAT_PRECISION * *ptr_expected))
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
UnityPrint(UnityStrElement);
|
||||
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
||||
#ifdef UNITY_FLOAT_VERBOSE
|
||||
UnityPrint(UnityStrExpected);
|
||||
UnityPrintFloat(*ptr_expected);
|
||||
UnityPrint(UnityStrWas);
|
||||
UnityPrintFloat(*ptr_actual);
|
||||
#else
|
||||
UnityPrint(UnityStrDelta);
|
||||
#endif
|
||||
UnityAddMsgIfSpecified(msg);
|
||||
UNITY_FAIL_AND_BAIL;
|
||||
}
|
||||
@ -349,7 +370,6 @@ void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
void UnityAssertFloatsWithin(const _UF delta,
|
||||
const _UF expected,
|
||||
const _UF actual,
|
||||
@ -371,16 +391,23 @@ void UnityAssertFloatsWithin(const _UF delta,
|
||||
if (pos_delta < diff)
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
#ifdef UNITY_FLOAT_VERBOSE
|
||||
UnityPrint(UnityStrExpected);
|
||||
UnityPrintFloat(expected);
|
||||
UnityPrint(UnityStrWas);
|
||||
UnityPrintFloat(actual);
|
||||
#else
|
||||
UnityPrint(UnityStrDelta);
|
||||
#endif
|
||||
UnityAddMsgIfSpecified(msg);
|
||||
UNITY_FAIL_AND_BAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void UnityAssertNumbersWithin( const long delta,
|
||||
const long expected,
|
||||
const long actual,
|
||||
void UnityAssertNumbersWithin( const _US32 delta,
|
||||
const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style)
|
||||
@ -394,10 +421,10 @@ void UnityAssertNumbersWithin( const long delta,
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned long)actual > (unsigned long)expected)
|
||||
Unity.CurrentTestFailed = ((unsigned long)(actual - expected) > (unsigned long)delta);
|
||||
if ((_UU32)actual > (_UU32)expected)
|
||||
Unity.CurrentTestFailed = ((_UU32)(actual - expected) > (_UU32)delta);
|
||||
else
|
||||
Unity.CurrentTestFailed = ((unsigned long)(expected - actual) > (unsigned long)delta);
|
||||
Unity.CurrentTestFailed = ((_UU32)(expected - actual) > (_UU32)delta);
|
||||
}
|
||||
|
||||
if (Unity.CurrentTestFailed)
|
||||
@ -419,7 +446,7 @@ void UnityAssertEqualString(const char* expected,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
unsigned long i;
|
||||
_UU32 i;
|
||||
|
||||
// if both pointers not null compare the strings
|
||||
if (expected && actual)
|
||||
@ -458,14 +485,14 @@ void UnityAssertEqualString(const char* expected,
|
||||
|
||||
void UnityAssertEqualMemory( const void* expected,
|
||||
const void* actual,
|
||||
unsigned long length,
|
||||
unsigned long num_elements,
|
||||
_UU32 length,
|
||||
_UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
unsigned char* expected_ptr = (unsigned char*)expected;
|
||||
unsigned char* actual_ptr = (unsigned char*)actual;
|
||||
unsigned long elements = num_elements;
|
||||
_UU32 elements = num_elements;
|
||||
if ((elements == 0) || (length == 0))
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
|
@ -17,6 +17,7 @@
|
||||
// - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
|
||||
// - define UNITY_FLOAT_DELTA to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT
|
||||
// - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats
|
||||
// - define UNITY_FLOAT_VERBOSE to print floating point values in errors (uses sprintf)
|
||||
|
||||
// Output
|
||||
// - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
|
||||
@ -101,7 +102,7 @@
|
||||
//Floating Point (If Enabled)
|
||||
#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Asserts (with additional messages)
|
||||
|
@ -34,14 +34,24 @@
|
||||
// Float Support
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
#ifdef UNITY_EXCLUDE_FLOAT
|
||||
|
||||
//No Floating Point Support
|
||||
#undef UNITY_FLOAT_PRECISION
|
||||
#undef UNITY_FLOAT_TYPE
|
||||
#undef UNITY_FLOAT_VERBOSE
|
||||
|
||||
#else
|
||||
|
||||
//Floating Point Support
|
||||
#ifndef UNITY_FLOAT_PRECISION
|
||||
#define UNITY_FLOAT_PRECISION (0.00001f)
|
||||
#endif
|
||||
#ifndef UNITY_FLOAT_TYPE
|
||||
#define UNITY_FLOAT_TYPE float
|
||||
#endif
|
||||
typedef UNITY_FLOAT_TYPE _UF;
|
||||
typedef UNITY_FLOAT_TYPE _UF;
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
@ -79,7 +89,7 @@ struct _Unity
|
||||
{
|
||||
const char* TestFile;
|
||||
const char* CurrentTestName;
|
||||
unsigned long CurrentTestLineNumber;
|
||||
_UU32 CurrentTestLineNumber;
|
||||
unsigned char NumberOfTests;
|
||||
unsigned char TestFailures;
|
||||
unsigned char TestIgnores;
|
||||
@ -103,11 +113,15 @@ void UnityConcludeTest(void);
|
||||
//-------------------------------------------------------
|
||||
|
||||
void UnityPrint(const char* string);
|
||||
void UnityPrintMask(const unsigned long mask, const unsigned long number);
|
||||
void UnityPrintNumberByStyle(const long number, const UNITY_DISPLAY_STYLE_T style);
|
||||
void UnityPrintNumber(const long number);
|
||||
void UnityPrintNumberUnsigned(const unsigned long number);
|
||||
void UnityPrintNumberHex(const unsigned long number, const char nibbles);
|
||||
void UnityPrintMask(const _UU32 mask, const _UU32 number);
|
||||
void UnityPrintNumberByStyle(const _US32 number, const UNITY_DISPLAY_STYLE_T style);
|
||||
void UnityPrintNumber(const _US32 number);
|
||||
void UnityPrintNumberUnsigned(const _UU32 number);
|
||||
void UnityPrintNumberHex(const _UU32 number, const char nibbles);
|
||||
|
||||
#ifdef UNITY_FLOAT_VERBOSE
|
||||
void UnityPrintFloat(const _UF number);
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Assertion Fuctions
|
||||
@ -117,22 +131,22 @@ void UnityPrintNumberHex(const unsigned long number, const char nibbles);
|
||||
// convention and will pull in file and line information
|
||||
// for you.
|
||||
|
||||
void UnityAssertEqualNumber(const long expected,
|
||||
const long actual,
|
||||
void UnityAssertEqualNumber(const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
|
||||
void UnityAssertEqualIntArray(const int* expected,
|
||||
const int* actual,
|
||||
const unsigned long num_elements,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
|
||||
void UnityAssertBits(const long mask,
|
||||
const long expected,
|
||||
const long actual,
|
||||
void UnityAssertBits(const _US32 mask,
|
||||
const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
@ -144,14 +158,14 @@ void UnityAssertEqualString(const char* expected,
|
||||
|
||||
void UnityAssertEqualMemory( const void* expected,
|
||||
const void* actual,
|
||||
const unsigned long length,
|
||||
const unsigned long num_elements,
|
||||
const _UU32 length,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertNumbersWithin(const long delta,
|
||||
const long expected,
|
||||
const long actual,
|
||||
void UnityAssertNumbersWithin(const _US32 delta,
|
||||
const _US32 expected,
|
||||
const _US32 actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
@ -169,7 +183,7 @@ void UnityAssertFloatsWithin(const _UF delta,
|
||||
|
||||
void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
const _UF* actual,
|
||||
const unsigned long num_elements,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
#endif
|
||||
@ -189,28 +203,28 @@ void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
#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_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((long)(mask), (long)(expected), (long)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((_US32)(mask), (_US32)(expected), (_US32)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_US32)(delta), (_US32)(expected), (_US32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_US32)(delta), (_US32)(expected), (_US32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_US32)(delta), (_US32)(expected), (_US32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_US32)(delta), (_US32)(expected), (_US32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_US32)(delta), (_US32)(expected), (_US32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
|
||||
#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((void*)(expected), (void*)(actual), (unsigned long)(len), 1, (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((void*)(expected), (void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const int*)(expected), (const int*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const int*)(expected), (const int*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const int*)(expected), (const int*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const int*)(expected), (const int*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const int*)(expected), (const int*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((void*)(expected), (void*)(actual), (unsigned long)(len), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _US32*)(expected), (const _US32*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _US32*)(expected), (const _US32*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _US32*)(expected), (const _US32*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _US32*)(expected), (const _US32*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _US32*)(expected), (const _US32*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((void*)(expected), (void*)(actual), (_UU32)(len), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#ifdef UNITY_EXCLUDE_FLOAT
|
||||
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
|
||||
@ -219,7 +233,7 @@ void UnityAssertEqualFloatArray(const _UF* expected,
|
||||
#else
|
||||
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#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)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((_UF*)(expected), (_UF*)(actual), (unsigned long)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
#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)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1250,6 +1250,71 @@ void testNotEqualHEX8Arrays3(void)
|
||||
VERIFY_FAILURE_WAS_CAUGHT
|
||||
}
|
||||
|
||||
void testEqualFloatArrays(void)
|
||||
{
|
||||
float p0[] = {1.0, 8.0, 25.4, 0.123};
|
||||
float p1[] = {1.0, 8.0, 25.4, 0.123};
|
||||
float p2[] = {1.0, 8.0, 25.4, 0.2};
|
||||
float p3[] = {1.0, 23.0, 25.0, 0.26};
|
||||
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 1);
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 4);
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3);
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1);
|
||||
}
|
||||
|
||||
void testNotEqualFloatArrays1(void)
|
||||
{
|
||||
float p0[] = {1.0, 8.0, 25.4, 0.253};
|
||||
float p1[] = {1.0, 8.0, 25.4, 0.252};
|
||||
|
||||
int failed;
|
||||
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
|
||||
EXPECT_ABORT_END
|
||||
|
||||
failed = Unity.CurrentTestFailed;
|
||||
Unity.CurrentTestFailed = 0;
|
||||
|
||||
VERIFY_FAILURE_WAS_CAUGHT
|
||||
}
|
||||
|
||||
void testNotEqualFloatArrays2(void)
|
||||
{
|
||||
float p0[] = {1.0, 8.0, 25.4, 0.253};
|
||||
float p1[] = {2.0, 8.0, 25.4, 0.253};
|
||||
|
||||
int failed;
|
||||
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
|
||||
EXPECT_ABORT_END
|
||||
|
||||
failed = Unity.CurrentTestFailed;
|
||||
Unity.CurrentTestFailed = 0;
|
||||
|
||||
VERIFY_FAILURE_WAS_CAUGHT
|
||||
}
|
||||
|
||||
void testNotEqualFloatArrays3(void)
|
||||
{
|
||||
float p0[] = {1.0, 8.0, 25.4, 0.253};
|
||||
float p1[] = {1.0, 8.0, 25.5, 0.253};
|
||||
|
||||
int failed;
|
||||
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
|
||||
EXPECT_ABORT_END
|
||||
|
||||
failed = Unity.CurrentTestFailed;
|
||||
Unity.CurrentTestFailed = 0;
|
||||
|
||||
VERIFY_FAILURE_WAS_CAUGHT
|
||||
}
|
||||
|
||||
void testEqualMemoryArrays(void)
|
||||
{
|
||||
int p0[] = {1, 8, 987, -2};
|
||||
|
Reference in New Issue
Block a user