Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
7fe31915
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看板
提交
7fe31915
编写于
3月 21, 2017
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added some tests to prove this works. Still work in progress
上级
56eeacd0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
228 addition
and
17 deletion
+228
-17
src/unity.c
src/unity.c
+41
-5
src/unity.h
src/unity.h
+40
-0
src/unity_internals.h
src/unity_internals.h
+17
-12
test/tests/testunity.c
test/tests/testunity.c
+130
-0
未找到文件。
src/unity.c
浏览文件 @
7fe31915
...
...
@@ -570,17 +570,17 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
expect_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT16
*
)
expected
;
actual_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT16
*
)
actual
;
break
;
default:
/* length 4 bytes */
expect_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT32
*
)
expected
;
actual_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT32
*
)
actual
;
length
=
4
;
break
;
#ifdef UNITY_SUPPORT_64
case
8
:
expect_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT64
*
)
expected
;
actual_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT64
*
)
actual
;
break
;
#endif
default:
/* length 4 bytes */
expect_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT32
*
)
expected
;
actual_val
=
*
(
UNITY_PTR_ATTRIBUTE
const
UNITY_INT32
*
)
actual
;
length
=
4
;
break
;
}
if
(
expect_val
!=
actual_val
)
...
...
@@ -1118,6 +1118,41 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
}
}
/*-----------------------------------------------*/
static
union
{
UNITY_INT8
i8
;
UNITY_INT16
i16
;
UNITY_INT32
i32
;
#ifdef UNITY_SUPPORT_64
UNITY_INT64
i64
;
#endif
}
UnityQuickCompare
;
UNITY_INTERNAL_PTR
UnityNumToPtr
(
const
UNITY_INT
num
,
const
UNITY_UINT8
size
)
{
switch
(
size
)
{
case
1
:
UnityQuickCompare
.
i8
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
i8
);
case
2
:
UnityQuickCompare
.
i16
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
i16
);
#ifdef UNITY_SUPPORT_64
case
8
:
UnityQuickCompare
.
i64
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
i64
);
#endif
default:
//4 bytes
UnityQuickCompare
.
i32
=
num
;
return
(
UNITY_INTERNAL_PTR
)(
&
UnityQuickCompare
.
i32
);
}
}
/*-----------------------------------------------
* Control Functions
*-----------------------------------------------*/
...
...
@@ -1181,6 +1216,7 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
#pragma weak tearDown
void
tearDown
(
void
)
{
}
#endif
/*-----------------------------------------------*/
void
UnityDefaultTestRun
(
UnityTestFunction
Func
,
const
char
*
FuncName
,
const
int
FuncLineNum
)
{
...
...
src/unity.h
浏览文件 @
7fe31915
...
...
@@ -157,6 +157,26 @@ void tearDown(void);
#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL)
/* Arrays Compared To Single Value */
#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL)
#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL)
//#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL)
//#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL)
/* 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)
...
...
@@ -262,6 +282,26 @@ void tearDown(void);
#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message))
/* Arrays Compared To Single Value*/
#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message))
#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message))
//#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message))
//#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message))
/* Floating Point (If Enabled) */
#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))
...
...
src/unity_internals.h
浏览文件 @
7fe31915
...
...
@@ -542,6 +542,8 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
const
UNITY_FLOAT_TRAIT_T
style
);
#endif
UNITY_INTERNAL_PTR
UnityNumToPtr
(
const
UNITY_INT
num
,
const
UNITY_UINT8
size
);
/*-------------------------------------------------------
* Error Strings We Might Need
*-------------------------------------------------------*/
...
...
@@ -668,18 +670,18 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((const char**)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected
), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
(UNITY_INTERNAL_PTR)(expected
), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT) expected, sizeof(int)),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT) expected, sizeof(uint)
), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )expected, 1),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_UINT16)expected, 2),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_UINT32)expected, 4),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4),
(UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(
UnityNumToPtr((UNITY_INT) expected, sizeof(int*)
), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL)
#define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((const char**)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line))
...
...
@@ -690,6 +692,9 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
...
...
test/tests/testunity.c
浏览文件 @
7fe31915
...
...
@@ -1641,6 +1641,65 @@ void testNotEqualIntArraysLengthZero(void)
VERIFY_FAILS_END
}
void
testEqualIntEachEqual
(
void
)
{
int
p0
[]
=
{
1
,
1
,
1
,
1
};
int
p1
[]
=
{
987
,
987
,
987
,
987
};
int
p2
[]
=
{
-
2
,
-
2
,
-
2
,
-
3
};
int
p3
[]
=
{
1
,
5
,
600
,
700
};
TEST_ASSERT_EACH_EQUAL_INT
(
1
,
p0
,
1
);
TEST_ASSERT_EACH_EQUAL_INT
(
1
,
p0
,
4
);
TEST_ASSERT_EACH_EQUAL_INT
(
987
,
p1
,
4
);
TEST_ASSERT_EACH_EQUAL_INT
(
-
2
,
p2
,
3
);
TEST_ASSERT_EACH_EQUAL_INT
(
1
,
p3
,
1
);
}
void
testNotEqualIntEachEqualNullActual
(
void
)
{
int
*
p1
=
NULL
;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_INT
(
1
,
p1
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualIntEachEqual1
(
void
)
{
int
p0
[]
=
{
1
,
1
,
1
,
-
2
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_INT
(
1
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualIntEachEqual2
(
void
)
{
int
p0
[]
=
{
-
5
,
-
5
,
-
1
,
-
5
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_INT
(
-
5
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualIntEachEqual3
(
void
)
{
int
p0
[]
=
{
1
,
88
,
88
,
88
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_INT
(
88
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualEachEqualLengthZero
(
void
)
{
UNITY_UINT32
p0
[
1
]
=
{
1
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_INT
(
0
,
p0
,
0
);
VERIFY_FAILS_END
}
void
testEqualPtrArrays
(
void
)
{
char
A
=
1
;
...
...
@@ -1721,6 +1780,77 @@ void testNotEqualPtrArrays3(void)
VERIFY_FAILS_END
}
void
testEqualPtrEachEqual
(
void
)
{
char
A
=
1
;
char
B
=
2
;
char
C
=
3
;
char
*
p0
[]
=
{
&
A
,
&
A
,
&
A
};
char
*
p1
[]
=
{
&
A
,
&
B
,
&
C
,
&
A
};
char
*
p2
[]
=
{
&
B
,
&
B
};
char
*
p3
[]
=
{
&
C
};
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p0
,
1
);
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p0
,
3
);
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p1
,
1
);
TEST_ASSERT_EACH_EQUAL_PTR
(
&
B
,
p2
,
2
);
TEST_ASSERT_EACH_EQUAL_PTR
(
&
C
,
p3
,
1
);
}
void
testNotEqualPtrEachEqualNullExpected
(
void
)
{
char
A
=
1
;
char
B
=
1
;
char
*
p0
[]
=
{
&
A
,
&
B
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p0
,
2
);
VERIFY_FAILS_END
}
void
testNotEqualPtrEachEqualNullActual
(
void
)
{
char
A
=
1
;
char
**
p0
=
NULL
;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p0
,
2
);
VERIFY_FAILS_END
}
void
testNotEqualPtrEachEqual1
(
void
)
{
char
A
=
1
;
char
B
=
1
;
char
*
p0
[]
=
{
&
A
,
&
A
,
&
A
,
&
B
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_PTR
(
&
A
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualPtrEachEqual2
(
void
)
{
char
A
=
1
;
char
B
=
1
;
char
*
p0
[]
=
{
&
B
,
&
B
,
&
A
,
&
B
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_PTR
(
&
B
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testNotEqualPtrEachEqual3
(
void
)
{
char
A
=
1
;
char
B
=
1
;
char
*
p0
[]
=
{
&
A
,
&
B
,
&
B
,
&
B
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_PTR
(
&
B
,
p0
,
4
);
VERIFY_FAILS_END
}
void
testEqualInt8Arrays
(
void
)
{
UNITY_INT8
p0
[]
=
{
1
,
8
,
117
,
-
2
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录