Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
f2d826c7
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看板
提交
f2d826c7
编写于
7月 03, 2019
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Added options for how to handle TEST_ASSERT_EQUAL shorthand
- Tweak a couple style problems with Ruby scripts.
上级
10f10b5e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
86 addition
and
16 deletion
+86
-16
auto/generate_test_runner.rb
auto/generate_test_runner.rb
+2
-3
docs/UnityAssertionsReference.md
docs/UnityAssertionsReference.md
+3
-7
docs/UnityConfigurationGuide.md
docs/UnityConfigurationGuide.md
+23
-1
release/version.info
release/version.info
+1
-1
src/unity.c
src/unity.c
+1
-0
src/unity.h
src/unity.h
+46
-4
src/unity_internals.h
src/unity_internals.h
+10
-0
未找到文件。
auto/generate_test_runner.rb
浏览文件 @
f2d826c7
...
...
@@ -103,8 +103,7 @@ class UnityTestRunnerGenerator
source_scrubbed
=
source
.
clone
source_scrubbed
=
source_scrubbed
.
gsub
(
/\\"/
,
'@quote@'
)
# hide escaped quotes to allow capture of the full string/char
source_scrubbed
=
source_scrubbed
.
gsub
(
/\\'/
,
'@apos@'
)
# hide escaped apostrophes to allow capture of the full string/char
source_scrubbed
=
source_scrubbed
.
gsub
(
/("[^"\n]*")|('[^'\n]*')/
)
{
|
s
|
s
.
gsub
(
substring_re
,
substring_subs
)
}
# temporarily hide problematic
# characters within strings
source_scrubbed
=
source_scrubbed
.
gsub
(
/("[^"\n]*")|('[^'\n]*')/
)
{
|
s
|
s
.
gsub
(
substring_re
,
substring_subs
)
}
# temporarily hide problematic characters within strings
source_scrubbed
=
source_scrubbed
.
gsub
(
/\/\/.*$/
,
''
)
# remove line comments
source_scrubbed
=
source_scrubbed
.
gsub
(
/\/\*.*?\*\//m
,
''
)
# remove block comments
lines
=
source_scrubbed
.
split
(
/(^\s*\#.*$) # Treat preprocessor directives as a logical line
...
...
@@ -472,4 +471,4 @@ if $0 == __FILE__
ARGV
[
1
]
=
ARGV
[
0
].
gsub
(
'.c'
,
'_Runner.c'
)
unless
ARGV
[
1
]
UnityTestRunnerGenerator
.
new
(
options
).
run
(
ARGV
[
0
],
ARGV
[
1
])
end
\ No newline at end of file
end
docs/UnityAssertionsReference.md
浏览文件 @
f2d826c7
...
...
@@ -105,12 +105,12 @@ becomes messageified like thus...
TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message )
Notes:
-
The
`_MESSAGE`
variants intentionally do not support
`printf`
style formatting
-
The
`_MESSAGE`
variants intentionally do not support
`printf`
style formatting
since many embedded projects don't support or avoid
`printf`
for various reasons.
It is possible to use
`sprintf`
before the assertion to assemble a complex fail
message, if necessary.
-
If you want to output a counter value within an assertion fail message (e.g. from
a loop) , building up an array of results and then using one of the
`_ARRAY`
-
If you want to output a counter value within an assertion fail message (e.g. from
a loop) , building up an array of results and then using one of the
`_ARRAY`
assertions (see below) might be a handy alternative to
`sprintf`
.
...
...
@@ -237,10 +237,6 @@ sizes.
##### `TEST_ASSERT_EQUAL_INT64 (expected, actual)`
##### `TEST_ASSERT_EQUAL (expected, actual)`
##### `TEST_ASSERT_NOT_EQUAL (expected, actual)`
##### `TEST_ASSERT_EQUAL_UINT (expected, actual)`
##### `TEST_ASSERT_EQUAL_UINT8 (expected, actual)`
...
...
docs/UnityConfigurationGuide.md
浏览文件 @
f2d826c7
...
...
@@ -420,12 +420,34 @@ _Example:_
##### `UNITY_OUTPUT_COLOR`
If you want to add color using ANSI escape codes you can use this define.
t
_Example:_
```
C
#define UNITY_OUTPUT_COLOR
```
##### `UNITY_SHORTHAND_AS_INT`
##### `UNITY_SHORTHAND_AS_MEM`
##### `UNITY_SHORTHAND_AS_RAW`
##### `UNITY_SHORTHAND_AS_NONE`
These options give you control of the
`TEST_ASSERT_EQUAL`
and the
`TEST_ASSERT_NOT_EQUAL`
shorthand assertions. Historically, Unity treated the
former as an alias for an integer comparison. It treated the latter as a direct
comparison using
`!=`
. This assymetry was confusing, but there was much
disagreement as to how best to treat this pair of assertions. These four options
will allow you to specify how Unity will treat these assertions.
-
AS INT - the values will be cast to integers and directly compared. Arguments
that don't cast easily to integers will cause compiler errors.
-
AS MEM - the address of both values will be taken and the entire object's
memory footprint will be compared byte by byte. Directly placing
constant numbers like
`456`
as expected values will cause errors.
-
AS_RAW - Unity assumes that you can compare the two values using
`==`
and
`!=`
and will do so. No details are given about mismatches, because it
doesn't really know what type it's dealing with.
-
AS_NONE - Unity will disallow the use of these shorthand macros altogether,
insisting that developers choose a more descriptive option.
## Getting Into The Guts
...
...
release/version.info
浏览文件 @
f2d826c7
2.4.
3
2.4.
4
src/unity.c
浏览文件 @
f2d826c7
...
...
@@ -53,6 +53,7 @@ static const char UnityStrNaN[] = "NaN";
static
const
char
UnityStrDet
[]
=
"Determinate"
;
static
const
char
UnityStrInvalidFloatTrait
[]
=
"Invalid Float Trait"
;
#endif
const
char
UnityStrErrShorthand
[]
=
"Unity Shorthand Support Disabled"
;
const
char
UnityStrErrFloat
[]
=
"Unity Floating Point Disabled"
;
const
char
UnityStrErrDouble
[]
=
"Unity Double Precision Disabled"
;
const
char
UnityStrErr64
[]
=
"Unity 64-bit Support Disabled"
;
...
...
src/unity.h
浏览文件 @
f2d826c7
...
...
@@ -130,8 +130,6 @@ int suiteTearDown(int num_failures);
#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL)
...
...
@@ -322,6 +320,29 @@ int suiteTearDown(int num_failures);
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL)
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL)
/* Shorthand */
#ifdef UNITY_SHORTHAND_AS_OLD
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
#endif
#ifdef UNITY_SHORTHAND_AS_INT
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
#ifdef UNITY_SHORTHAND_AS_MEM
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
#ifdef UNITY_SHORTHAND_AS_RAW
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal")
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
#endif
#ifdef UNITY_SHORTHAND_AS_NONE
const
char
UnityStrErrShorthand
[];
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
/*-------------------------------------------------------
* Test Asserts (with additional messages)
*-------------------------------------------------------*/
...
...
@@ -340,8 +361,6 @@ int suiteTearDown(int num_failures);
#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message))
#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message))
...
...
@@ -532,6 +551,29 @@ int suiteTearDown(int num_failures);
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message))
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message))
/* Shorthand */
#ifdef UNITY_SHORTHAND_AS_OLD
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message))
#endif
#ifdef UNITY_SHORTHAND_AS_INT
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
#ifdef UNITY_SHORTHAND_AS_MEM
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message)
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
#ifdef UNITY_SHORTHAND_AS_RAW
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message)
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
#endif
#ifdef UNITY_SHORTHAND_AS_NONE
const
char
UnityStrErrShorthand
[];
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
#endif
/* end of UNITY_FRAMEWORK_H */
#ifdef __cplusplus
}
...
...
src/unity_internals.h
浏览文件 @
f2d826c7
...
...
@@ -729,6 +729,16 @@ extern const char UnityStrErr64[];
#define UNITY_END() UnityEnd()
#endif
#ifndef UNITY_SHORTHAND_AS_INT
#ifndef UNITY_SHORTHAND_AS_MEM
#ifndef UNITY_SHORTHAND_AS_NONE
#ifndef UNITY_SHORTHAND_AS_RAW
#define UNITY_SHORTHAND_AS_OLD
#endif
#endif
#endif
#endif
/*-----------------------------------------------
* Command Line Argument Support
*-----------------------------------------------*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录