Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
f2fdf1a1
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看板
提交
f2fdf1a1
编写于
5月 13, 2017
作者:
D
Dom Postorivo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Greater than and Less than asserts from other PR
上级
f96c0553
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
622 addition
and
1 deletion
+622
-1
README.md
README.md
+11
-0
docs/UnityAssertionsReference.md
docs/UnityAssertionsReference.md
+54
-0
src/unity.c
src/unity.c
+46
-0
src/unity.h
src/unity.h
+60
-0
src/unity_internals.h
src/unity_internals.h
+40
-0
test/tests/testunity.c
test/tests/testunity.c
+411
-1
未找到文件。
README.md
浏览文件 @
f2fdf1a1
...
...
@@ -118,6 +118,17 @@ Another way of calling TEST_ASSERT_EQUAL_INT
Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
size specific variants.
TEST_ASSERT_GREATER_THAN(threshold, actual)
Asserts that the actual value is greater than the threshold. This also comes in size specific variants.
TEST_ASSERT_LESS_THAN(threshold, actual)
Asserts that the actual value is less than the threshold. This also comes in size specific variants.
Arrays
------
...
...
docs/UnityAssertionsReference.md
浏览文件 @
f2fdf1a1
...
...
@@ -290,6 +290,60 @@ Asserts the specified bit of the `actual` parameter is high.
Asserts the specified bit of the
`actual`
parameter is low.
### Integer Less Than / Greater Than
These assertions verify that the
`actual`
parameter is less than or greater
than
`threshold`
(exclusive). For example, if the threshold value is 0 for the
greater than assertion will fail if it is 0 or less.
##### `TEST_ASSERT_GREATER_THAN (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT32 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT32 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX32 (threshold, actual)`
### Integer Ranges (of all sizes)
...
...
src/unity.c
浏览文件 @
f2fdf1a1
...
...
@@ -27,6 +27,8 @@ static const char UnityStrNull[] = "NULL";
static
const
char
UnityStrSpacer
[]
=
". "
;
static
const
char
UnityStrExpected
[]
=
" Expected "
;
static
const
char
UnityStrWas
[]
=
" Was "
;
static
const
char
UnityStrGt
[]
=
" to be greater than "
;
static
const
char
UnityStrLt
[]
=
" to be less than "
;
static
const
char
UnityStrElement
[]
=
" Element "
;
static
const
char
UnityStrByte
[]
=
" Byte "
;
static
const
char
UnityStrMemory
[]
=
" Memory Mismatch."
;
...
...
@@ -526,6 +528,50 @@ void UnityAssertEqualNumber(const UNITY_INT expected,
}
}
/*-----------------------------------------------*/
void
UnityAssertGreaterNumber
(
const
UNITY_INT
threshold
,
const
UNITY_INT
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_DISPLAY_STYLE_T
style
)
{
RETURN_IF_FAIL_OR_IGNORE
;
if
(
!
(
actual
>
threshold
))
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrExpected
);
UnityPrintNumberByStyle
(
actual
,
style
);
UnityPrint
(
UnityStrGt
);
UnityPrintNumberByStyle
(
threshold
,
style
);
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
/*-----------------------------------------------*/
void
UnityAssertSmallerNumber
(
const
UNITY_INT
threshold
,
const
UNITY_INT
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_DISPLAY_STYLE_T
style
)
{
RETURN_IF_FAIL_OR_IGNORE
;
if
(
!
(
actual
<
threshold
))
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrExpected
);
UnityPrintNumberByStyle
(
actual
,
style
);
UnityPrint
(
UnityStrLt
);
UnityPrintNumberByStyle
(
threshold
,
style
);
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
}
}
#define UnityPrintPointlessAndBail() \
{ \
UnityTestResultsFailBegin(lineNumber); \
...
...
src/unity.h
浏览文件 @
f2fdf1a1
...
...
@@ -114,6 +114,35 @@ void tearDown(void);
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL)
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL)
/* Integer Greater Than/ Less Than (of all sizes) */
#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
/* Integer Ranges (of all sizes) */
#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
...
...
@@ -157,6 +186,8 @@ 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)
...
...
@@ -241,6 +272,35 @@ void tearDown(void);
#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message))
/* Integer Greater Than/ Less Than (of all sizes) */
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message))
/* Integer Ranges (of all sizes) */
#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message))
#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message))
...
...
src/unity_internals.h
浏览文件 @
f2fdf1a1
...
...
@@ -455,6 +455,18 @@ void UnityAssertEqualNumber(const UNITY_INT expected,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_DISPLAY_STYLE_T
style
);
void
UnityAssertGreaterNumber
(
const
UNITY_INT
threshold
,
const
UNITY_INT
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_DISPLAY_STYLE_T
style
);
void
UnityAssertSmallerNumber
(
const
UNITY_INT
threshold
,
const
UNITY_INT
actual
,
const
char
*
msg
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_DISPLAY_STYLE_T
style
);
void
UnityAssertEqualIntArray
(
UNITY_INTERNAL_PTR
expected
,
UNITY_INTERNAL_PTR
actual
,
const
UNITY_UINT32
num_elements
,
...
...
@@ -652,6 +664,34 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32)
#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT)
#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8)
#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16)
#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32)
#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8)
#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16)
#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16)
#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32)
#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT)
#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8)
#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16)
#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32)
#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8)
#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16)
#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertSmallerNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16)
...
...
test/tests/testunity.c
浏览文件 @
f2fdf1a1
...
...
@@ -764,8 +764,9 @@ void testNotEqualBitsLow(void)
EXPECT_ABORT_BEGIN
TEST_ASSERT_BITS_LOW
(
v0
,
v1
);
VERIFY_FAILS_END
}
void
testEqualShorts
(
void
)
{
short
v0
,
v1
;
...
...
@@ -1305,6 +1306,415 @@ void testINT8sNotWithinDeltaAndCustomMessage(void)
VERIFY_FAILS_END
}
//-----------------
void
testGreaterThan
(
void
)
{
UNITY_INT
v0
,
v1
;
UNITY_INT
*
p0
,
*
p1
;
v0
=
0
;
v1
=
1
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN
(
*
p0
,
*
p1
);
}
void
testGreaterThanINT
(
void
)
{
UNITY_INT
v0
,
v1
;
UNITY_INT
*
p0
,
*
p1
;
v0
=
302
;
v1
=
3334
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_INT
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_INT
(
*
p0
,
*
p1
);
}
void
testGreaterThanINT8
(
void
)
{
UNITY_INT8
v0
,
v1
;
UNITY_INT8
*
p0
,
*
p1
;
v0
=
-
128
;
v1
=
127
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_INT8
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT8
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT8
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_INT8
(
*
p0
,
*
p1
);
}
void
testGreaterThanINT16
(
void
)
{
UNITY_INT16
v0
,
v1
;
UNITY_INT16
*
p0
,
*
p1
;
v0
=
-
32768
;
v1
=
32767
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_INT16
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT16
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT16
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_INT16
(
*
p0
,
*
p1
);
}
void
testGreaterThanINT32
(
void
)
{
UNITY_INT32
v0
,
v1
;
UNITY_INT32
*
p0
,
*
p1
;
v0
=
-
214783648
;
v1
=
214783647
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_INT32
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT32
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_INT32
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_INT32
(
*
p0
,
*
p1
);
}
void
testGreaterThanUINT
(
void
)
{
UNITY_UINT
v0
,
v1
;
UNITY_UINT
*
p0
,
*
p1
;
v0
=
0
;
v1
=
1
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_UINT
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_UINT
(
*
p0
,
*
p1
);
}
void
testGreaterThanUINT8
(
void
)
{
UNITY_UINT8
v0
,
v1
;
UNITY_UINT8
*
p0
,
*
p1
;
v0
=
0
;
v1
=
255
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_UINT8
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT8
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT8
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_UINT8
(
*
p0
,
*
p1
);
}
void
testGreaterThanUINT16
(
void
)
{
UNITY_UINT16
v0
,
v1
;
UNITY_UINT16
*
p0
,
*
p1
;
v0
=
0
;
v1
=
65535
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_UINT16
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT16
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT16
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_UINT16
(
*
p0
,
*
p1
);
}
void
testGreaterThanUINT32
(
void
)
{
UNITY_UINT32
v0
,
v1
;
UNITY_UINT32
*
p0
,
*
p1
;
v0
=
0
;
v1
=
4294967295
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_UINT32
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT32
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_UINT32
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_UINT32
(
*
p0
,
*
p1
);
}
void
testGreaterThanHEX8
(
void
)
{
UNITY_UINT8
v0
,
v1
;
UNITY_UINT8
*
p0
,
*
p1
;
v0
=
0x00
;
v1
=
0xFF
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_HEX8
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX8
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX8
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_HEX8
(
*
p0
,
*
p1
);
}
void
testGreaterThanHEX16
(
void
)
{
UNITY_UINT16
v0
,
v1
;
UNITY_UINT16
*
p0
,
*
p1
;
v0
=
0x0000
;
v1
=
0xFFFF
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_HEX16
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX16
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX16
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_HEX16
(
*
p0
,
*
p1
);
}
void
testGreaterThanHEX32
(
void
)
{
UNITY_UINT32
v0
,
v1
;
UNITY_UINT32
*
p0
,
*
p1
;
v0
=
0x00000000
;
v1
=
0xFFFFFFFF
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_GREATER_THAN_HEX32
(
v0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX32
(
*
p0
,
v1
);
TEST_ASSERT_GREATER_THAN_HEX32
(
v0
,
*
p1
);
TEST_ASSERT_GREATER_THAN_HEX32
(
*
p0
,
*
p1
);
}
void
testNotGreaterThan
(
void
)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_GREATER_THAN
(
0
,
-
1
);
VERIFY_FAILS_END
}
void
testLessThan
(
void
)
{
UNITY_INT
v0
,
v1
;
UNITY_INT
*
p0
,
*
p1
;
v0
=
0
;
v1
=
-
1
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN
(
*
p0
,
*
p1
);
}
void
testLessThanINT
(
void
)
{
UNITY_INT
v0
,
v1
;
UNITY_INT
*
p0
,
*
p1
;
v0
=
3334
;
v1
=
302
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_INT
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_INT
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_INT
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_INT
(
*
p0
,
*
p1
);
}
void
testLessThanINT8
(
void
)
{
UNITY_INT8
v0
,
v1
;
UNITY_INT8
*
p0
,
*
p1
;
v0
=
127
;
v1
=
-
128
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_INT8
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_INT8
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_INT8
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_INT8
(
*
p0
,
*
p1
);
}
void
testLessThanINT16
(
void
)
{
UNITY_INT16
v0
,
v1
;
UNITY_INT16
*
p0
,
*
p1
;
v0
=
32767
;
v1
=
-
32768
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_INT16
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_INT16
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_INT16
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_INT16
(
*
p0
,
*
p1
);
}
void
testLessThanINT32
(
void
)
{
UNITY_INT32
v0
,
v1
;
UNITY_INT32
*
p0
,
*
p1
;
v0
=
214783647
;
v1
=
-
214783648
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_INT32
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_INT32
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_INT32
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_INT32
(
*
p0
,
*
p1
);
}
void
testLessThanUINT
(
void
)
{
UNITY_UINT
v0
,
v1
;
UNITY_UINT
*
p0
,
*
p1
;
v0
=
1
;
v1
=
0
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_UINT
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_UINT
(
*
p0
,
*
p1
);
}
void
testLessThanUINT8
(
void
)
{
UNITY_UINT8
v0
,
v1
;
UNITY_UINT8
*
p0
,
*
p1
;
v0
=
255
;
v1
=
0
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_UINT8
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT8
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT8
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_UINT8
(
*
p0
,
*
p1
);
}
void
testLessThanUINT16
(
void
)
{
UNITY_UINT16
v0
,
v1
;
UNITY_UINT16
*
p0
,
*
p1
;
v0
=
65535
;
v1
=
0
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_UINT16
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT16
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT16
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_UINT16
(
*
p0
,
*
p1
);
}
void
testLessThanUINT32
(
void
)
{
UNITY_UINT32
v0
,
v1
;
UNITY_UINT32
*
p0
,
*
p1
;
v0
=
4294967295
;
v1
=
0
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_UINT32
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT32
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_UINT32
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_UINT32
(
*
p0
,
*
p1
);
}
void
testLessThanHEX8
(
void
)
{
UNITY_UINT8
v0
,
v1
;
UNITY_UINT8
*
p0
,
*
p1
;
v0
=
0xFF
;
v1
=
0x00
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_HEX8
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX8
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX8
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_HEX8
(
*
p0
,
*
p1
);
}
void
testLessThanHEX16
(
void
)
{
UNITY_UINT16
v0
,
v1
;
UNITY_UINT16
*
p0
,
*
p1
;
v0
=
0xFFFF
;
v1
=
0x0000
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_HEX16
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX16
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX16
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_HEX16
(
*
p0
,
*
p1
);
}
void
testLessThanHEX32
(
void
)
{
UNITY_UINT32
v0
,
v1
;
UNITY_UINT32
*
p0
,
*
p1
;
v0
=
0xFFFFFFFF
;
v1
=
0x00000000
;
p0
=
&
v0
;
p1
=
&
v1
;
TEST_ASSERT_LESS_THAN_HEX32
(
v0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX32
(
*
p0
,
v1
);
TEST_ASSERT_LESS_THAN_HEX32
(
v0
,
*
p1
);
TEST_ASSERT_LESS_THAN_HEX32
(
*
p0
,
*
p1
);
}
void
testNotLessThan
(
void
)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_LESS_THAN
(
0
,
1
);
VERIFY_FAILS_END
}
//-----------------
void
testEqualStrings
(
void
)
{
const
char
*
testString
=
"foo"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录