Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
d8d67a70
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看板
提交
d8d67a70
编写于
3月 21, 2017
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added each_equal assertions for float and double
上级
b7956ea9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
346 addition
and
8 deletion
+346
-8
src/unity.c
src/unity.c
+34
-4
src/unity.h
src/unity.h
+4
-0
src/unity_internals.h
src/unity_internals.h
+20
-4
test/tests/testunity.c
test/tests/testunity.c
+288
-0
未找到文件。
src/unity.c
浏览文件 @
d8d67a70
...
...
@@ -649,7 +649,8 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
UNITY_PTR_ATTRIBUTE
const
UNITY_FLOAT
*
actual
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
)
{
UNITY_UINT32
elements
=
num_elements
;
UNITY_PTR_ATTRIBUTE
const
UNITY_FLOAT
*
ptr_expected
=
expected
;
...
...
@@ -677,7 +678,10 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
ptr_expected
++
;
if
(
flags
==
UNITY_ARRAY_TO_ARRAY
)
{
ptr_expected
++
;
}
ptr_actual
++
;
}
}
...
...
@@ -775,7 +779,8 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte
UNITY_PTR_ATTRIBUTE
const
UNITY_DOUBLE
*
actual
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
)
{
UNITY_UINT32
elements
=
num_elements
;
UNITY_PTR_ATTRIBUTE
const
UNITY_DOUBLE
*
ptr_expected
=
expected
;
...
...
@@ -803,7 +808,10 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
ptr_expected
++
;
if
(
flags
==
UNITY_ARRAY_TO_ARRAY
)
{
ptr_expected
++
;
}
ptr_actual
++
;
}
}
...
...
@@ -1128,6 +1136,12 @@ static union
#ifdef UNITY_SUPPORT_64
UNITY_INT64
i64
;
#endif
#ifndef UNITY_EXCLUDE_FLOAT
float
f
;
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
double
d
;
#endif
}
UnityQuickCompare
;
UNITY_INTERNAL_PTR
UnityNumToPtr
(
const
UNITY_INT
num
,
const
UNITY_UINT8
size
)
...
...
@@ -1153,6 +1167,22 @@ UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size)
}
}
#ifndef UNITY_EXCLUDE_FLOAT
UNITY_INTERNAL_PTR
UnityFloatToPtr
(
const
float
num
)
{
UnityQuickCompare
.
f
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
f
);
}
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
UNITY_INTERNAL_PTR
UnityDoubleToPtr
(
const
double
num
)
{
UnityQuickCompare
.
d
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
d
);
}
#endif
/*-----------------------------------------------
* Control Functions
*-----------------------------------------------*/
...
...
src/unity.h
浏览文件 @
d8d67a70
...
...
@@ -181,6 +181,7 @@ void tearDown(void);
#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) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((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)
...
...
@@ -194,6 +195,7 @@ void tearDown(void);
#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)
#define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((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)
...
...
@@ -306,6 +308,7 @@ void tearDown(void);
#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))
#define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((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))
...
...
@@ -319,6 +322,7 @@ void tearDown(void);
#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))
#define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((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))
...
...
src/unity_internals.h
浏览文件 @
d8d67a70
...
...
@@ -515,7 +515,8 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
UNITY_PTR_ATTRIBUTE
const
UNITY_FLOAT
*
actual
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
);
void
UnityAssertFloatSpecial
(
const
UNITY_FLOAT
actual
,
const
char
*
msg
,
...
...
@@ -534,7 +535,8 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte
UNITY_PTR_ATTRIBUTE
const
UNITY_DOUBLE
*
actual
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
);
void
UnityAssertDoubleSpecial
(
const
UNITY_DOUBLE
actual
,
const
char
*
msg
,
...
...
@@ -542,7 +544,17 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
const
UNITY_FLOAT_TRAIT_T
style
);
#endif
/*-------------------------------------------------------
* Helpers
*-------------------------------------------------------*/
UNITY_INTERNAL_PTR
UnityNumToPtr
(
const
UNITY_INT
num
,
const
UNITY_UINT8
size
);
#ifndef UNITY_EXCLUDE_FLOAT
UNITY_INTERNAL_PTR
UnityFloatToPtr
(
const
float
num
);
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
UNITY_INTERNAL_PTR
UnityDoubleToPtr
(
const
double
num
);
#endif
/*-------------------------------------------------------
* Error Strings We Might Need
...
...
@@ -714,6 +726,7 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat)
...
...
@@ -725,7 +738,8 @@ int UnityTestMatches(void);
#else
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF)
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF)
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN)
...
...
@@ -740,6 +754,7 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
...
...
@@ -751,7 +766,8 @@ int UnityTestMatches(void);
#else
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual, (UNITY_LINE_TYPE)(line), message)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF)
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN)
...
...
test/tests/testunity.c
浏览文件 @
d8d67a70
...
...
@@ -3782,6 +3782,150 @@ void testNotEqualFloatArraysLengthZero(void)
#endif
}
void
testEqualFloatEachEqual
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
};
float
p1
[]
=
{
-
0
.
123
f
,
-
0
.
123
f
,
-
0
.
123
f
,
-
0
.
123
f
};
float
p2
[]
=
{
25
.
4
f
,
25
.
4
f
,
25
.
4
f
,
-
0
.
2
f
};
float
p3
[]
=
{
1
.
0
f
,
-
23
.
0
f
,
25
.
0
f
,
-
0
.
26
f
};
TEST_ASSERT_EACH_EQUAL_FLOAT
(
1
.
0
f
,
p0
,
1
);
TEST_ASSERT_EACH_EQUAL_FLOAT
(
1
.
0
f
,
p0
,
4
);
TEST_ASSERT_EACH_EQUAL_FLOAT
(
-
0
.
123
f
,
p1
,
4
);
TEST_ASSERT_EACH_EQUAL_FLOAT
(
25
.
4
f
,
p2
,
3
);
TEST_ASSERT_EACH_EQUAL_FLOAT
(
1
.
0
f
,
p3
,
1
);
#endif
}
void
testNotEqualFloatEachEqualActualNull
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
*
p0
=
NULL
;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
5
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqual1
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
0
.
253
f
,
8
.
0
f
,
0
.
253
f
,
0
.
253
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
0
.
253
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqual2
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
8
.
0
f
,
8
.
0
f
,
8
.
0
f
,
0
.
253
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
8
.
0
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqual3
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
0
.
253
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
1
.
0
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqualNegative1
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
-
1
.
0
f
,
-
0
.
253
f
,
-
0
.
253
f
,
-
0
.
253
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
-
0
.
253
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqualNegative2
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
-
25
.
4
f
,
-
8
.
0
f
,
-
25
.
4
f
,
-
25
.
4
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
-
25
.
4
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualFloatEachEqualNegative3
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
-
8
.
0
f
,
-
8
.
0
f
,
-
8
.
0
f
,
-
0
.
253
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
-
8
.
0
f
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testEqualFloatEachEqualNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
0
.
0
f
/
f_zero
,
0
.
0
f
/
f_zero
,
0
.
0
f
/
f_zero
,
0
.
0
f
/
f_zero
};
TEST_ASSERT_EACH_EQUAL_FLOAT
(
0
.
0
f
/
f_zero
,
p0
,
4
);
#endif
}
void
testEqualFloatEachEqualInf
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[]
=
{
1
.
0
f
/
f_zero
,
1
.
0
f
/
f_zero
,
25
.
4
f
,
0
.
253
f
};
TEST_ASSERT_EACH_EQUAL_FLOAT
(
1
.
0
f
/
f_zero
,
p0
,
2
);
#endif
}
void
testNotEqualFloatEachEqualLengthZero
(
void
)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE
();
#else
float
p0
[
1
]
=
{
0
.
0
f
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT
(
0
.
0
f
,
p0
,
0
);
VERIFY_FAILS_END
#endif
}
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \
startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
...
...
@@ -4480,6 +4624,150 @@ void testNotEqualDoubleArraysLengthZero(void)
#endif
}
void
testEqualDoubleEachEqual
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
1
.
0
,
1
.
0
,
1
.
0
,
1
.
0
};
double
p1
[]
=
{
-
0
.
123
,
-
0
.
123
,
-
0
.
123
,
-
0
.
123
};
double
p2
[]
=
{
25
.
4
,
25
.
4
,
25
.
4
,
-
0
.
2
};
double
p3
[]
=
{
1
.
0
,
-
23
.
0
,
25
.
0
,
-
0
.
26
};
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
1
.
0
,
p0
,
1
);
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
1
.
0
,
p0
,
4
);
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
-
0
.
123
,
p1
,
4
);
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
25
.
4
,
p2
,
3
);
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
1
.
0
,
p3
,
1
);
#endif
}
void
testNotEqualDoubleEachEqualActualNull
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
*
p0
=
NULL
;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
5
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqual1
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
0
.
253
,
8
.
0
,
0
.
253
,
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
0
.
253
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqual2
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
8
.
0
,
8
.
0
,
8
.
0
,
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
8
.
0
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqual3
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
1
.
0
,
1
.
0
,
1
.
0
,
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
1
.
0
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqualNegative1
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
-
1
.
0
,
-
0
.
253
,
-
0
.
253
,
-
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
-
0
.
253
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqualNegative2
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
-
25
.
4
,
-
8
.
0
,
-
25
.
4
,
-
25
.
4
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
-
25
.
4
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testNotEqualDoubleEachEqualNegative3
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
-
8
.
0
,
-
8
.
0
,
-
8
.
0
,
-
0
.
253
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
-
8
.
0
,
p0
,
4
);
VERIFY_FAILS_END
#endif
}
void
testEqualDoubleEachEqualNaN
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
0
.
0
/
d_zero
,
0
.
0
/
d_zero
,
0
.
0
/
d_zero
,
0
.
0
/
d_zero
};
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
0
.
0
/
d_zero
,
p0
,
4
);
#endif
}
void
testEqualDoubleEachEqualInf
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[]
=
{
1
.
0
/
d_zero
,
1
.
0
/
d_zero
,
25
.
4
,
0
.
253
};
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
1
.
0
/
d_zero
,
p0
,
2
);
#endif
}
void
testNotEqualDoubleEachEqualLengthZero
(
void
)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE
();
#else
double
p0
[
1
]
=
{
0
.
0
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE
(
0
.
0
,
p0
,
0
);
VERIFY_FAILS_END
#endif
}
void
testDoublePrinting
(
void
)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录