提交 504bf2ed 编写于 作者: M mvandervoord

- fixed conditional self-tests

- rolled in DOUBLE support from Mark Vismer (thanks!)

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@134 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 7deba787
......@@ -578,7 +578,102 @@ void UnityAssertFloatsWithin(const _UF delta,
UNITY_FAIL_AND_BAIL;
}
}
#endif //not UNITY_EXCLUDE_FLOAT
//-----------------------------------------------
#ifndef UNITY_EXCLUDE_DOUBLE
void UnityAssertEqualDoubleArray(const _UD* expected,
const _UD* actual,
const _UU32 num_elements,
const char* msg,
const UNITY_LINE_TYPE lineNumber)
{
_UU32 elements = num_elements;
const _UD* ptr_expected = expected;
const _UD* ptr_actual = actual;
_UD diff, tol;
UNITY_SKIP_EXECUTION;
if (elements == 0)
{
UnityTestResultsFailBegin(lineNumber);
UnityPrint(UnityStrPointless);
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
}
if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
return;
while (elements--)
{
diff = *ptr_expected - *ptr_actual;
if (diff < 0.0)
diff = 0.0 - diff;
tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
if (tol < 0.0)
tol = 0.0 - tol;
if (diff > tol)
{
UnityTestResultsFailBegin(lineNumber);
UnityPrint(UnityStrElement);
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
#ifdef UNITY_DOUBLE_VERBOSE
UnityPrint(UnityStrExpected);
UnityPrintFloat((float)(*ptr_expected));
UnityPrint(UnityStrWas);
UnityPrintFloat((float)(*ptr_actual));
#else
UnityPrint(UnityStrDelta);
#endif
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
}
ptr_expected++;
ptr_actual++;
}
}
//-----------------------------------------------
void UnityAssertDoublesWithin(const _UD delta,
const _UD expected,
const _UD actual,
const char* msg,
const UNITY_LINE_TYPE lineNumber)
{
_UD diff = actual - expected;
_UD pos_delta = delta;
UNITY_SKIP_EXECUTION;
if (diff < 0)
{
diff = 0.0f - diff;
}
if (pos_delta < 0)
{
pos_delta = 0.0f - pos_delta;
}
if (pos_delta < diff)
{
UnityTestResultsFailBegin(lineNumber);
#ifdef UNITY_DOUBLE_VERBOSE
UnityPrint(UnityStrExpected);
UnityPrintFloat((float)expected);
UnityPrint(UnityStrWas);
UnityPrintFloat((float)actual);
#else
UnityPrint(UnityStrDelta);
#endif
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
}
}
#endif // not UNITY_EXCLUDE_DOUBLE
//-----------------------------------------------
void UnityAssertNumbersWithin( const _U_SINT delta,
......
......@@ -24,6 +24,11 @@
// - define UNITY_FLOAT_PRECISION 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)
// - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons
// - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default)
// - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
// - define UNITY_DOUBLE_TYPE to specify something other than double
// - define UNITY_DOUBLE_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
......@@ -137,6 +142,12 @@
#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) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
//Double (If Enabled)
#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, NULL)
#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, NULL)
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, NULL)
//-------------------------------------------------------
// Test Asserts (with additional messages)
//-------------------------------------------------------
......@@ -210,4 +221,10 @@
#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, message)
#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, message)
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, message)
//Double (If Enabled)
#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, message)
#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, message)
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, message)
#endif
......@@ -112,6 +112,37 @@ typedef UNITY_FLOAT_TYPE _UF;
#endif
//-------------------------------------------------------
// Double Float Support
//-------------------------------------------------------
//unlike FLOAT, we DON'T include by default
#ifndef UNITY_EXCLUDE_DOUBLE
#ifndef UNITY_INCLUDE_DOUBLE
#define UNITY_EXCLUDE_DOUBLE
#endif
#endif
#ifdef UNITY_EXCLUDE_DOUBLE
//No Floating Point Support
#undef UNITY_DOUBLE_PRECISION
#undef UNITY_DOUBLE_TYPE
#undef UNITY_DOUBLE_VERBOSE
#else
//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
//-------------------------------------------------------
// Output Method
//-------------------------------------------------------
......@@ -280,6 +311,20 @@ void UnityAssertEqualFloatArray(const _UF* expected,
const UNITY_LINE_TYPE lineNumber);
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
void UnityAssertDoublesWithin(const _UD delta,
const _UD expected,
const _UD actual,
const char* msg,
const UNITY_LINE_TYPE lineNumber);
void UnityAssertEqualDoubleArray(const _UD* expected,
const _UD* actual,
const _UU32 num_elements,
const char* msg,
const UNITY_LINE_TYPE lineNumber);
#endif
//-------------------------------------------------------
// Basic Fail and Ignore
//-------------------------------------------------------
......@@ -352,4 +397,14 @@ void UnityAssertEqualFloatArray(const _UF* expected,
#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
#ifdef UNITY_EXCLUDE_DOUBLE
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#else
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((_UF)(expected) * (_UD)UNITY_DOUBLE_PRECISION, (_UD)expected, (_UD)actual, (UNITY_LINE_TYPE)line, message)
#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)
#endif
#endif
......@@ -19,6 +19,7 @@ compiler:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
object_files:
prefix: '-o'
......
......@@ -19,6 +19,7 @@ compiler:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- 'UNITY_POINTER_WIDTH=64'
object_files:
......
......@@ -1406,10 +1406,12 @@ void testIgnoredAndThenFailInTearDown(void)
}
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ==================
#ifdef UNITY_SUPPORT_64
void testEqualHex64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_UU64 v0, v1;
_UU64 *p0, *p1;
......@@ -1425,10 +1427,14 @@ void testEqualHex64s(void)
TEST_ASSERT_EQUAL_HEX64(*p0, v1);
TEST_ASSERT_EQUAL_HEX64(*p0, *p1);
TEST_ASSERT_EQUAL_HEX64(*p0, 0x9876543201234567);
#endif
}
void testNotEqualHex64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_UU64 v0, v1;
v0 = 9000000000;
......@@ -1437,10 +1443,14 @@ void testNotEqualHex64s(void)
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testNotEqualHex64sIfSigned(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_US64 v0, v1;
v0 = -9000000000;
......@@ -1449,31 +1459,47 @@ void testNotEqualHex64sIfSigned(void)
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testHEX64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
TEST_ASSERT_HEX64_WITHIN(5, 5000, 4996);
TEST_ASSERT_HEX64_WITHIN(5, 5000, 5005);
#endif
}
void testHEX64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
VERIFY_FAILS_END
#endif
}
void testHEX64sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_WITHIN(5, 1, -1);
VERIFY_FAILS_END
#endif
}
void testEqualHEX64Arrays(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_UU64 p0[] = {1, 8, 987, 65132u};
_UU64 p1[] = {1, 8, 987, 65132u};
_UU64 p2[] = {1, 8, 987, 2};
......@@ -1484,79 +1510,112 @@ void testEqualHEX64Arrays(void)
TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p2, 3);
TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p3, 1);
#endif
}
void testNotEqualHEX64Arrays1(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_UU64 p0[] = {1, 8, 987, 65132u};
_UU64 p1[] = {1, 8, 987, 65131u};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualHEX64Arrays2(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
_UU64 p0[] = {1, 8, 987, 65132u};
_UU64 p1[] = {2, 8, 987, 65132u};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
#endif //64-bit SUPPORT
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES FLOAT SUPPORT ==================
#ifndef UNITY_EXCLUDE_FLOAT
void testFloatsWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_WITHIN(0.00003f, 187245.03485f, 187245.03488f);
TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f);
TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f);
TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f);
#endif
}
void testFloatsNotWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f);
VERIFY_FAILS_END
#endif
}
void testFloatsEqual(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_FLOAT(187245.0f, 187246.0f);
TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f);
TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f);
TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f);
#endif
}
void testFloatsNotEqual(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f);
VERIFY_FAILS_END
#endif
}
void testEqualFloatArrays(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
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};
......@@ -1567,86 +1626,319 @@ void testEqualFloatArrays(void)
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1);
#endif
}
void testNotEqualFloatArraysExpectedNull(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float* p0 = NULL;
float p1[] = {1.0, 8.0, 25.4, 0.252};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysActualNull(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0, 8.0, 25.4, 0.253};
float* p1 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0, 8.0, 25.4, 0.253};
float p1[] = {1.0, 8.0, 25.4, 0.252};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0, 8.0, 25.4, 0.253};
float p1[] = {2.0, 8.0, 25.4, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0, 8.0, 25.4, 0.253};
float p1[] = {1.0, 8.0, 25.5, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0, -8.0, -25.4, -0.253};
float p1[] = {-1.0, -8.0, -25.4, -0.252};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0, -8.0, -25.4, -0.253};
float p1[] = {-2.0, -8.0, -25.4, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0, -8.0, -25.4, -0.253};
float p1[] = {-1.0, -8.0, -25.5, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ==================
void testDoublesWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488);
TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0);
TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049);
TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424);
#endif
}
void testDoublesNotWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049);
VERIFY_FAILS_END
#endif
}
void testDoublesEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0);
TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6);
TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699);
TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374);
#endif
}
void testDoublesNotEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049);
VERIFY_FAILS_END
#endif
}
#endif //FLOAT SUPPORT
void testDoublesNotEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649);
VERIFY_FAILS_END
#endif
}
void testEqualDoubleArrays(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, -8.0, 25.4, -0.123};
double p1[] = {1.0, -8.0, 25.4, -0.123};
double p2[] = {1.0, -8.0, 25.4, -0.2};
double p3[] = {1.0, -23.0, 25.0, -0.26};
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1);
#endif
}
void testNotEqualDoubleArraysExpectedNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double* p0 = NULL;
double p1[] = {1.0, 8.0, 25.4, 0.252};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysActualNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double* p1 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.25666666667};
double p1[] = {1.0, 8.0, 25.4, 0.25666666666};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double p1[] = {2.0, 8.0, 25.4, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double p1[] = {1.0, 8.0, 25.5, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.2566666667};
double p1[] = {-1.0, -8.0, -25.4, -0.2566666666};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.253};
double p1[] = {-2.0, -8.0, -25.4, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.253};
double p1[] = {-1.0, -8.0, -25.5, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册