Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
e8d585b9
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
1 年多 前同步成功
通知
36
Star
144
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Unity
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e8d585b9
编写于
11月 19, 2012
作者:
J
John Van Enk
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12 from rryles/master
Improved support for special floating point values
上级
7b9b7d6a
2ab2fef6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
589 addition
and
7 deletion
+589
-7
src/unity.c
src/unity.c
+151
-5
src/unity.h
src/unity.h
+12
-2
src/unity_internals.h
src/unity_internals.h
+36
-0
test/testunity.c
test/testunity.c
+390
-0
未找到文件。
src/unity.c
浏览文件 @
e8d585b9
...
@@ -28,6 +28,9 @@ const char* UnityStrDelta = " Values Not Within Delta ";
...
@@ -28,6 +28,9 @@ const char* UnityStrDelta = " Values Not Within Delta ";
const
char
*
UnityStrPointless
=
" You Asked Me To Compare Nothing, Which Was Pointless."
;
const
char
*
UnityStrPointless
=
" You Asked Me To Compare Nothing, Which Was Pointless."
;
const
char
*
UnityStrNullPointerForExpected
=
" Expected pointer to be NULL"
;
const
char
*
UnityStrNullPointerForExpected
=
" Expected pointer to be NULL"
;
const
char
*
UnityStrNullPointerForActual
=
" Actual pointer was NULL"
;
const
char
*
UnityStrNullPointerForActual
=
" Actual pointer was NULL"
;
const
char
*
UnityStrInf
=
"Infinity"
;
const
char
*
UnityStrNegInf
=
"Negative Infinity"
;
const
char
*
UnityStrNaN
=
"NaN"
;
// compiler-generic print formatting masks
// compiler-generic print formatting masks
const
_U_UINT
UnitySizeMask
[]
=
const
_U_UINT
UnitySizeMask
[]
=
...
@@ -536,7 +539,9 @@ void UnityAssertEqualFloatArray(const _UF* expected,
...
@@ -536,7 +539,9 @@ void UnityAssertEqualFloatArray(const _UF* expected,
tol
=
UNITY_FLOAT_PRECISION
*
*
ptr_expected
;
tol
=
UNITY_FLOAT_PRECISION
*
*
ptr_expected
;
if
(
tol
<
0
.
0
)
if
(
tol
<
0
.
0
)
tol
=
0
.
0
-
tol
;
tol
=
0
.
0
-
tol
;
if
(
diff
>
tol
)
//This first part of this condition will catch any NaN or Infinite values
if
((
diff
*
0
.
0
f
!=
0
.
0
f
)
||
(
diff
>
tol
))
{
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrElement
);
UnityPrint
(
UnityStrElement
);
...
@@ -578,8 +583,8 @@ void UnityAssertFloatsWithin(const _UF delta,
...
@@ -578,8 +583,8 @@ void UnityAssertFloatsWithin(const _UF delta,
pos_delta
=
0
.
0
f
-
pos_delta
;
pos_delta
=
0
.
0
f
-
pos_delta
;
}
}
//
NOTE: This comparison is deliberately this way round so that NaNs fail.
//
This first part of this condition will catch any NaN or Infinite values
if
(
!
(
pos_delta
>=
diff
)
)
if
(
(
diff
*
0
.
0
f
!=
0
.
0
f
)
||
(
pos_delta
<
diff
)
)
{
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_FLOAT_VERBOSE
#ifdef UNITY_FLOAT_VERBOSE
...
@@ -595,6 +600,75 @@ void UnityAssertFloatsWithin(const _UF delta,
...
@@ -595,6 +600,75 @@ void UnityAssertFloatsWithin(const _UF delta,
}
}
}
}
//-----------------------------------------------
void
UnityAssertFloatIsInf
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
((
1
.
0
f
/
0
.
0
f
)
!=
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_FLOAT_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrInf
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
(
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
//-----------------------------------------------
void
UnityAssertFloatIsNegInf
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
((
-
1
.
0
f
/
0
.
0
f
)
!=
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_FLOAT_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrNegInf
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
(
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
//-----------------------------------------------
void
UnityAssertFloatIsNaN
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
(
actual
==
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_FLOAT_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrNaN
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
(
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
#endif //not UNITY_EXCLUDE_FLOAT
#endif //not UNITY_EXCLUDE_FLOAT
//-----------------------------------------------
//-----------------------------------------------
...
@@ -631,7 +705,9 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
...
@@ -631,7 +705,9 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
tol
=
UNITY_DOUBLE_PRECISION
*
*
ptr_expected
;
tol
=
UNITY_DOUBLE_PRECISION
*
*
ptr_expected
;
if
(
tol
<
0
.
0
)
if
(
tol
<
0
.
0
)
tol
=
0
.
0
-
tol
;
tol
=
0
.
0
-
tol
;
if
(
diff
>
tol
)
//This first part of this condition will catch any NaN or Infinite values
if
((
diff
*
0
.
0
f
!=
0
.
0
f
)
||
(
diff
>
tol
))
{
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrElement
);
UnityPrint
(
UnityStrElement
);
...
@@ -673,7 +749,8 @@ void UnityAssertDoublesWithin(const _UD delta,
...
@@ -673,7 +749,8 @@ void UnityAssertDoublesWithin(const _UD delta,
pos_delta
=
0
.
0
f
-
pos_delta
;
pos_delta
=
0
.
0
f
-
pos_delta
;
}
}
if
(
pos_delta
<
diff
)
//This first part of this condition will catch any NaN or Infinite values
if
((
diff
*
0
.
0
f
!=
0
.
0
f
)
||
(
pos_delta
<
diff
))
{
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_DOUBLE_VERBOSE
#ifdef UNITY_DOUBLE_VERBOSE
...
@@ -689,6 +766,75 @@ void UnityAssertDoublesWithin(const _UD delta,
...
@@ -689,6 +766,75 @@ void UnityAssertDoublesWithin(const _UD delta,
}
}
}
}
//-----------------------------------------------
void
UnityAssertDoubleIsInf
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
((
1
.
0
/
0
.
0
)
!=
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_DOUBLE_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrInf
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
((
float
)
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
//-----------------------------------------------
void
UnityAssertDoubleIsNegInf
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
((
-
1
.
0
/
0
.
0
)
!=
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_DOUBLE_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrNegInf
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
((
float
)
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
//-----------------------------------------------
void
UnityAssertDoubleIsNaN
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
{
UNITY_SKIP_EXECUTION
;
if
(
actual
==
actual
)
{
UnityTestResultsFailBegin
(
lineNumber
);
#ifdef UNITY_DOUBLE_VERBOSE
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrNaN
);
UnityPrint
(
UnityStrWas
);
UnityPrintFloat
((
float
)
actual
);
#else
UnityPrint
(
UnityStrDelta
);
#endif
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
#endif // not UNITY_EXCLUDE_DOUBLE
#endif // not UNITY_EXCLUDE_DOUBLE
//-----------------------------------------------
//-----------------------------------------------
...
...
src/unity.h
浏览文件 @
e8d585b9
...
@@ -142,12 +142,17 @@
...
@@ -142,12 +142,17 @@
#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, NULL)
#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(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)
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, NULL)
#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, NULL)
#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, NULL)
//Double (If Enabled)
//Double (If Enabled)
#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, NULL)
#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(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)
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, NULL)
#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, NULL)
#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, NULL)
#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, NULL)
//-------------------------------------------------------
//-------------------------------------------------------
// Test Asserts (with additional messages)
// Test Asserts (with additional messages)
...
@@ -223,10 +228,15 @@
...
@@ -223,10 +228,15 @@
#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, message)
#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_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)
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, message)
#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, message)
#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, message)
#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, message)
//Double (If Enabled)
//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_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_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)
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, message)
#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, message)
#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, message)
#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, message)
#endif
#endif
src/unity_internals.h
浏览文件 @
e8d585b9
...
@@ -410,6 +410,18 @@ void UnityAssertEqualFloatArray(const _UF* expected,
...
@@ -410,6 +410,18 @@ void UnityAssertEqualFloatArray(const _UF* expected,
const
_UU32
num_elements
,
const
_UU32
num_elements
,
const
char
*
msg
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertFloatIsInf
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertFloatIsNegInf
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertFloatIsNaN
(
const
_UF
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
#endif
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
#ifndef UNITY_EXCLUDE_DOUBLE
...
@@ -424,6 +436,18 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
...
@@ -424,6 +436,18 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
const
_UU32
num_elements
,
const
_UU32
num_elements
,
const
char
*
msg
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertDoubleIsInf
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertDoubleIsNegInf
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
void
UnityAssertDoubleIsNaN
(
const
_UD
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
#endif
#endif
//-------------------------------------------------------
//-------------------------------------------------------
...
@@ -493,20 +517,32 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
...
@@ -493,20 +517,32 @@ void UnityAssertEqualDoubleArray(const _UD* expected,
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Floating Point Disabled")
#else
#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_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(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), (_UU32)(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)
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatIsInf((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatIsNegInf((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatIsNaN((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#endif
#endif
#ifdef UNITY_EXCLUDE_DOUBLE
#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_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(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")
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, "Unity Double Precision Disabled")
#else
#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_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(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)
#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)
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertFloatIsInf((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertFloatIsNegInf((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertFloatIsNaN((_UF)(actual), (message), (UNITY_LINE_TYPE)line)
#endif
#endif
#endif
#endif
test/testunity.c
浏览文件 @
e8d585b9
...
@@ -2237,6 +2237,168 @@ void testFloatsNotEqualActualNaN(void)
...
@@ -2237,6 +2237,168 @@ void testFloatsNotEqualActualNaN(void)
#endif
#endif
}
}
void
testFloatsNotEqualExpectedNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
0
.
0
f
/
0
.
0
f
,
85
.
963
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualBothNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
0
.
0
f
/
0
.
0
f
,
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualInfNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
1
.
0
f
/
0
.
0
f
,
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualNaNInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
0
.
0
f
/
0
.
0
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualActualInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
321
.
642
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualExpectedInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
1
.
0
f
/
0
.
0
f
,
321
.
642
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualBothInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
1
.
0
f
/
0
.
0
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatsNotEqualPlusMinusInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT
(
1
.
0
f
/
0
.
0
f
,
-
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatIsInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
TEST_ASSERT_FLOAT_IS_INF
(
2
.
0
f
/
0
.
0
f
);
TEST_ASSERT_FLOAT_IS_NEG_INF
(
-
3
.
0
f
/
0
.
0
f
);
#endif
}
void
testFloatIsNotInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_INF
(
2
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatIsNotNegInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NEG_INF
(
-
999
.
876
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatIsNan
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
TEST_ASSERT_FLOAT_IS_NAN
(
0
.
0
f
/
0
.
0
f
);
#endif
}
void
testFloatIsNotNan
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NAN
(
234
.
9
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatInfIsNotNan
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NAN
(
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testFloatNanIsNotInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_INF
(
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testEqualFloatArrays
(
void
)
void
testEqualFloatArrays
(
void
)
{
{
#ifdef UNITY_EXCLUDE_FLOAT
#ifdef UNITY_EXCLUDE_FLOAT
...
@@ -2367,6 +2529,34 @@ void testNotEqualFloatArraysNegative3(void)
...
@@ -2367,6 +2529,34 @@ void testNotEqualFloatArraysNegative3(void)
#endif
#endif
}
}
void
testNotEqualFloatArraysNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
1
.
0
,
0
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
float
p1
[]
=
{
1
.
0
,
0
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY
(
p0
,
p1
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatArraysInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
1
.
0
,
1
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
float
p1
[]
=
{
1
.
0
,
1
.
0
/
0
.
0
,
25
.
4
,
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 ==================
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ==================
void
testDoublesWithinDelta
(
void
)
void
testDoublesWithinDelta
(
void
)
...
@@ -2438,6 +2628,179 @@ void testDoublesNotEqualNegative2(void)
...
@@ -2438,6 +2628,179 @@ void testDoublesNotEqualNegative2(void)
#endif
#endif
}
}
void
testDoublesNotEqualActualNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
85
.
963
f
,
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualExpectedNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
0
.
0
f
/
0
.
0
f
,
85
.
963
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualBothNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
0
.
0
f
/
0
.
0
f
,
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualInfNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
1
.
0
f
/
0
.
0
f
,
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualNaNInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
0
.
0
f
/
0
.
0
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualActualInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
321
.
642
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualExpectedInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
1
.
0
f
/
0
.
0
f
,
321
.
642
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualBothInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
1
.
0
f
/
0
.
0
f
,
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoublesNotEqualPlusMinusInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE
(
1
.
0
f
/
0
.
0
f
,
-
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoubleIsInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
TEST_ASSERT_DOUBLE_IS_INF
(
2
.
0
f
/
0
.
0
f
);
TEST_ASSERT_DOUBLE_IS_NEG_INF
(
-
3
.
0
f
/
0
.
0
f
);
#endif
}
void
testDoubleIsNotInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_INF
(
2
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoubleIsNotNegInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NEG_INF
(
-
999
.
876
f
);
VERIFY_FAILS_END
#endif
}
void
testDoubleIsNan
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
TEST_ASSERT_DOUBLE_IS_NAN
(
0
.
0
f
/
0
.
0
f
);
#endif
}
void
testDoubleIsNotNan
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NAN
(
234
.
9
f
);
VERIFY_FAILS_END
#endif
}
void
testDoubleInfIsNotNan
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NAN
(
1
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testDoubleNanIsNotInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_INF
(
0
.
0
f
/
0
.
0
f
);
VERIFY_FAILS_END
#endif
}
void
testEqualDoubleArrays
(
void
)
void
testEqualDoubleArrays
(
void
)
{
{
#ifdef UNITY_EXCLUDE_DOUBLE
#ifdef UNITY_EXCLUDE_DOUBLE
...
@@ -2568,3 +2931,30 @@ void testNotEqualDoubleArraysNegative3(void)
...
@@ -2568,3 +2931,30 @@ void testNotEqualDoubleArraysNegative3(void)
#endif
#endif
}
}
void
testNotEqualDoubleArraysNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
1
.
0
,
0
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
double
p1
[]
=
{
1
.
0
,
0
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY
(
p0
,
p1
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleArraysInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
1
.
0
,
1
.
0
/
0
.
0
,
25
.
4
,
0
.
253
};
double
p1
[]
=
{
1
.
0
,
1
.
0
/
0
.
0
,
25
.
4
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录