Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
a11a1375
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看板
提交
a11a1375
编写于
3月 21, 2017
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added memory each equal assertion
上级
d8d67a70
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
78 addition
and
7 deletion
+78
-7
src/unity.c
src/unity.c
+6
-1
src/unity.h
src/unity.h
+2
-2
src/unity_internals.h
src/unity_internals.h
+5
-4
test/tests/testunity.c
test/tests/testunity.c
+65
-0
未找到文件。
src/unity.c
浏览文件 @
a11a1375
...
...
@@ -1079,7 +1079,8 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
const
UNITY_UINT32
length
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
)
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
)
{
UNITY_PTR_ATTRIBUTE
const
unsigned
char
*
ptr_exp
=
(
UNITY_PTR_ATTRIBUTE
const
unsigned
char
*
)
expected
;
UNITY_PTR_ATTRIBUTE
const
unsigned
char
*
ptr_act
=
(
UNITY_PTR_ATTRIBUTE
const
unsigned
char
*
)
actual
;
...
...
@@ -1123,6 +1124,10 @@ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
ptr_exp
++
;
ptr_act
++
;
}
if
(
flags
==
UNITY_ARRAY_TO_VAL
)
{
ptr_exp
=
(
UNITY_PTR_ATTRIBUTE
const
unsigned
char
*
)
expected
;
}
}
}
...
...
src/unity.h
浏览文件 @
a11a1375
...
...
@@ -175,7 +175,7 @@ void tearDown(void);
#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)
#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)
...
...
@@ -302,7 +302,7 @@ void tearDown(void);
#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))
#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))
...
...
src/unity_internals.h
浏览文件 @
a11a1375
...
...
@@ -491,7 +491,8 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
const
UNITY_UINT32
length
,
const
UNITY_UINT32
num_elements
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
);
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLAGS_T
flags
);
void
UnityAssertNumbersWithin
(
const
UNITY_UINT
delta
,
const
UNITY_INT
expected
,
...
...
@@ -665,7 +666,7 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER)
#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line)
, UNITY_ARRAY_TO_ARRAY
)
#define UNITY_TEST_ASSERT_EQUAL_INT_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_INT, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EQUAL_INT8_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_INT8, UNITY_ARRAY_TO_ARRAY)
...
...
@@ -680,7 +681,7 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_HEX32_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_HEX32, UNITY_ARRAY_TO_ARRAY)
#define UNITY_TEST_ASSERT_EQUAL_PTR_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_POINTER, UNITY_ARRAY_TO_ARRAY)
#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_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)
, UNITY_ARRAY_TO_ARRAY
)
#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)
...
...
@@ -695,7 +696,7 @@ int UnityTestMatches(void);
#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))
#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)
, UNITY_ARRAY_TO_VAL
)
#ifdef UNITY_SUPPORT_64
#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
...
...
test/tests/testunity.c
浏览文件 @
a11a1375
...
...
@@ -2737,6 +2737,71 @@ void testNotEqualMemoryArrays3(void)
VERIFY_FAILS_END
}
void
testEqualMemoryEachEqual
(
void
)
{
int
p0
[]
=
{
1
,
8
,
987
,
-
2
};
int
p1
[]
=
{
1
,
8
,
987
,
-
2
,
1
,
8
,
987
,
-
2
};
int
p2
[]
=
{
8
,
8
,
8
,
2
};
int
p3
[]
=
{
8
,
500
,
600
,
700
};
int
v
=
8
;
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p0
,
sizeof
(
int
)
*
4
,
1
);
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
)
*
4
,
2
);
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
)
*
4
,
1
);
TEST_ASSERT_EACH_EQUAL_MEMORY
(
&
v
,
p2
,
sizeof
(
int
),
3
);
TEST_ASSERT_EACH_EQUAL_MEMORY
(
&
v
,
p3
,
sizeof
(
int
),
1
);
}
void
testNotEqualMemoryEachEqualExpectedNull
(
void
)
{
int
*
p0
=
NULL
;
int
p1
[]
=
{
1
,
8
,
987
,
2
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
),
4
);
VERIFY_FAILS_END
}
void
testNotEqualMemoryEachEqualActualNull
(
void
)
{
int
p0
[]
=
{
1
,
8
,
987
,
-
2
};
int
*
p1
=
NULL
;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
),
4
);
VERIFY_FAILS_END
}
void
testNotEqualMemoryEachEqual1
(
void
)
{
int
p0
[]
=
{
1
,
8
,
987
,
-
2
};
int
p1
[]
=
{
9
,
8
,
987
,
-
2
,
1
,
8
,
987
,
-
2
,
1
,
8
,
987
,
-
2
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
)
*
4
,
3
);
VERIFY_FAILS_END
}
void
testNotEqualMemoryEachEqual2
(
void
)
{
int
p0
[]
=
{
1
,
8
,
987
,
-
2
};
int
p1
[]
=
{
1
,
8
,
987
,
-
2
,
1
,
8
,
987
,
-
2
,
1
,
8
,
987
,
9
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
)
*
4
,
3
);
VERIFY_FAILS_END
}
void
testNotEqualMemoryEachEqual3
(
void
)
{
int
p0
[]
=
{
1
,
8
,
987
,
-
2
};
int
p1
[]
=
{
1
,
8
,
987
,
-
2
,
1
,
9
,
987
,
-
2
,
1
,
8
,
987
,
-
2
};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_MEMORY
(
p0
,
p1
,
sizeof
(
int
)
*
4
,
3
);
VERIFY_FAILS_END
}
void
testProtection
(
void
)
{
volatile
int
mask
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录