Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
b723c9f2
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看板
提交
b723c9f2
编写于
1月 30, 2019
作者:
F
Fabian Zahn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added braces to avoid implementation solely based on operator precedence.
上级
d4511489
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
31 deletion
+32
-31
src/unity.c
src/unity.c
+26
-25
src/unity_internals.h
src/unity_internals.h
+6
-6
未找到文件。
src/unity.c
浏览文件 @
b723c9f2
...
@@ -105,7 +105,7 @@ static UNITY_UINT UnityPrintAnsiEscapeString(const char* string)
...
@@ -105,7 +105,7 @@ static UNITY_UINT UnityPrintAnsiEscapeString(const char* string)
const
char
*
pch
=
string
;
const
char
*
pch
=
string
;
UNITY_UINT
count
=
0
;
UNITY_UINT
count
=
0
;
while
(
*
pch
&&
*
pch
!=
'm'
)
while
(
*
pch
&&
(
*
pch
!=
'm'
)
)
{
{
UNITY_OUTPUT_CHAR
(
*
pch
);
UNITY_OUTPUT_CHAR
(
*
pch
);
pch
++
;
pch
++
;
...
@@ -129,7 +129,7 @@ void UnityPrint(const char* string)
...
@@ -129,7 +129,7 @@ void UnityPrint(const char* string)
{
{
#ifdef UNITY_OUTPUT_COLOR
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
/* print ANSI escape code */
if
(
*
pch
==
27
&&
*
(
pch
+
1
)
==
'['
)
if
(
(
*
pch
==
27
)
&&
(
*
(
pch
+
1
)
==
'['
)
)
{
{
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
continue
;
continue
;
...
@@ -232,7 +232,7 @@ void UnityPrintFormatted(const char* format, ...)
...
@@ -232,7 +232,7 @@ void UnityPrintFormatted(const char* format, ...)
}
}
#ifdef UNITY_OUTPUT_COLOR
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
/* print ANSI escape code */
else
if
(
*
pch
==
27
&&
*
(
pch
+
1
)
==
'['
)
else
if
(
(
*
pch
==
27
)
&&
(
*
(
pch
+
1
)
==
'['
)
)
{
{
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
continue
;
continue
;
...
@@ -262,7 +262,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length)
...
@@ -262,7 +262,7 @@ void UnityPrintLen(const char* string, const UNITY_UINT32 length)
if
(
pch
!=
NULL
)
if
(
pch
!=
NULL
)
{
{
while
(
*
pch
&&
(
UNITY_UINT32
)(
pch
-
string
)
<
length
)
while
(
*
pch
&&
(
(
UNITY_UINT32
)(
pch
-
string
)
<
length
)
)
{
{
/* printable characters plus CR & LF are printed */
/* printable characters plus CR & LF are printed */
if
((
*
pch
<=
126
)
&&
(
*
pch
>=
32
))
if
((
*
pch
<=
126
)
&&
(
*
pch
>=
32
))
...
@@ -351,6 +351,7 @@ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
...
@@ -351,6 +351,7 @@ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
{
{
int
nibble
;
int
nibble
;
char
nibbles
=
nibbles_to_print
;
char
nibbles
=
nibbles_to_print
;
if
((
unsigned
)
nibbles
>
(
2
*
sizeof
(
number
)))
if
((
unsigned
)
nibbles
>
(
2
*
sizeof
(
number
)))
{
{
nibbles
=
2
*
sizeof
(
number
);
nibbles
=
2
*
sizeof
(
number
);
...
@@ -422,7 +423,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -422,7 +423,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
UNITY_DOUBLE
number
=
input_number
;
UNITY_DOUBLE
number
=
input_number
;
/* print minus sign (including for negative zero) */
/* print minus sign (including for negative zero) */
if
(
number
<
0
.
0
f
||
(
number
==
0
.
0
f
&&
1
.
0
f
/
number
<
0
.
0
f
))
if
(
(
number
<
0
.
0
f
)
||
((
number
==
0
.
0
f
)
&&
((
1
.
0
f
/
number
)
<
0
.
0
f
)
))
{
{
UNITY_OUTPUT_CHAR
(
'-'
);
UNITY_OUTPUT_CHAR
(
'-'
);
number
=
-
number
;
number
=
-
number
;
...
@@ -459,7 +460,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -459,7 +460,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
{
{
UNITY_DOUBLE
factor
=
1
.
0
f
;
UNITY_DOUBLE
factor
=
1
.
0
f
;
while
(
number
<
(
UNITY_DOUBLE
)
max_scaled
/
1e10
f
)
{
number
*=
1e10
f
;
exponent
-=
10
;
}
while
(
number
<
(
UNITY_DOUBLE
)
max_scaled
/
1e10
f
)
{
number
*=
1e10
f
;
exponent
-=
10
;
}
while
(
number
*
factor
<
(
UNITY_DOUBLE
)
min_scaled
)
{
factor
*=
10
.
0
f
;
exponent
--
;
}
while
(
number
*
factor
<
(
UNITY_DOUBLE
)
min_scaled
)
{
factor
*=
10
.
0
f
;
exponent
--
;
}
number
*=
factor
;
number
*=
factor
;
...
@@ -468,7 +469,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -468,7 +469,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
{
{
UNITY_DOUBLE
divisor
=
1
.
0
f
;
UNITY_DOUBLE
divisor
=
1
.
0
f
;
while
(
number
>
(
UNITY_DOUBLE
)
min_scaled
*
1e10
f
)
{
number
/=
1e10
f
;
exponent
+=
10
;
}
while
(
number
>
(
UNITY_DOUBLE
)
min_scaled
*
1e10
f
)
{
number
/=
1e10
f
;
exponent
+=
10
;
}
while
(
number
/
divisor
>
(
UNITY_DOUBLE
)
max_scaled
)
{
divisor
*=
10
.
0
f
;
exponent
++
;
}
while
(
number
/
divisor
>
(
UNITY_DOUBLE
)
max_scaled
)
{
divisor
*=
10
.
0
f
;
exponent
++
;
}
number
/=
divisor
;
number
/=
divisor
;
...
@@ -494,7 +495,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -494,7 +495,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
/* round to even if exactly between two integers */
/* round to even if exactly between two integers */
if
((
n
&
1
)
&&
((
UNITY_DOUBLE
)
n
-
number
==
0
.
5
f
))
if
((
n
&
1
)
&&
((
(
UNITY_DOUBLE
)
n
-
number
)
==
0
.
5
f
))
n
--
;
n
--
;
#endif
#endif
...
@@ -507,11 +508,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -507,11 +508,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
}
}
/* determine where to place decimal point */
/* determine where to place decimal point */
decimals
=
(
exponent
<=
0
&&
exponent
>=
-
(
sig_digits
+
3
))
?
-
exponent
:
(
sig_digits
-
1
);
decimals
=
(
(
exponent
<=
0
)
&&
(
exponent
>=
-
(
sig_digits
+
3
)))
?
(
-
exponent
)
:
(
sig_digits
-
1
);
exponent
+=
decimals
;
exponent
+=
decimals
;
/* truncate trailing zeroes after decimal point */
/* truncate trailing zeroes after decimal point */
while
(
decimals
>
0
&&
n
%
10
==
0
)
while
(
(
decimals
>
0
)
&&
((
n
%
10
)
==
0
)
)
{
{
n
/=
10
;
n
/=
10
;
decimals
--
;
decimals
--
;
...
@@ -519,14 +520,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -519,14 +520,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
/* build up buffer in reverse order */
/* build up buffer in reverse order */
digits
=
0
;
digits
=
0
;
while
(
n
!=
0
||
digits
<
decimals
+
1
)
while
(
(
n
!=
0
)
||
(
digits
<
(
decimals
+
1
))
)
{
{
buf
[
digits
++
]
=
(
char
)(
'0'
+
n
%
10
);
buf
[
digits
++
]
=
(
char
)(
'0'
+
n
%
10
);
n
/=
10
;
n
/=
10
;
}
}
while
(
digits
>
0
)
while
(
digits
>
0
)
{
{
if
(
digits
==
decimals
)
UNITY_OUTPUT_CHAR
(
'.'
);
if
(
digits
==
decimals
)
{
UNITY_OUTPUT_CHAR
(
'.'
);
}
UNITY_OUTPUT_CHAR
(
buf
[
--
digits
]);
UNITY_OUTPUT_CHAR
(
buf
[
--
digits
]);
}
}
...
@@ -535,7 +536,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -535,7 +536,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
{
{
UNITY_OUTPUT_CHAR
(
'e'
);
UNITY_OUTPUT_CHAR
(
'e'
);
if
(
exponent
<
0
)
if
(
exponent
<
0
)
{
{
UNITY_OUTPUT_CHAR
(
'-'
);
UNITY_OUTPUT_CHAR
(
'-'
);
exponent
=
-
exponent
;
exponent
=
-
exponent
;
...
@@ -546,7 +547,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
...
@@ -546,7 +547,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
}
}
digits
=
0
;
digits
=
0
;
while
(
exponent
!=
0
||
digits
<
2
)
while
(
(
exponent
!=
0
)
||
(
digits
<
2
)
)
{
{
buf
[
digits
++
]
=
(
char
)(
'0'
+
exponent
%
10
);
buf
[
digits
++
]
=
(
char
)(
'0'
+
exponent
%
10
);
exponent
/=
10
;
exponent
/=
10
;
...
@@ -772,18 +773,18 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
...
@@ -772,18 +773,18 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
int
failed
=
0
;
int
failed
=
0
;
RETURN_IF_FAIL_OR_IGNORE
;
RETURN_IF_FAIL_OR_IGNORE
;
if
(
threshold
==
actual
&&
compare
&
UNITY_EQUAL_TO
)
return
;
if
(
(
threshold
==
actual
)
&&
(
compare
&
UNITY_EQUAL_TO
))
{
return
;
}
if
(
threshold
==
actual
)
failed
=
1
;
if
(
(
threshold
==
actual
))
{
failed
=
1
;
}
if
((
style
&
UNITY_DISPLAY_RANGE_INT
)
==
UNITY_DISPLAY_RANGE_INT
)
if
((
style
&
UNITY_DISPLAY_RANGE_INT
)
==
UNITY_DISPLAY_RANGE_INT
)
{
{
if
(
actual
>
threshold
&&
compare
&
UNITY_SMALLER_THAN
)
failed
=
1
;
if
(
(
actual
>
threshold
)
&&
(
compare
&
UNITY_SMALLER_THAN
))
{
failed
=
1
;
}
if
(
actual
<
threshold
&&
compare
&
UNITY_GREATER_THAN
)
failed
=
1
;
if
(
(
actual
<
threshold
)
&&
(
compare
&
UNITY_GREATER_THAN
))
{
failed
=
1
;
}
}
}
else
/* UINT or HEX */
else
/* UINT or HEX */
{
{
if
((
UNITY_UINT
)
actual
>
(
UNITY_UINT
)
threshold
&&
compare
&
UNITY_SMALLER_THAN
)
failed
=
1
;
if
((
(
UNITY_UINT
)
actual
>
(
UNITY_UINT
)
threshold
)
&&
(
compare
&
UNITY_SMALLER_THAN
))
{
failed
=
1
;
}
if
((
UNITY_UINT
)
actual
<
(
UNITY_UINT
)
threshold
&&
compare
&
UNITY_GREATER_THAN
)
failed
=
1
;
if
((
(
UNITY_UINT
)
actual
<
(
UNITY_UINT
)
threshold
)
&&
(
compare
&
UNITY_GREATER_THAN
))
{
failed
=
1
;
}
}
}
if
(
failed
)
if
(
failed
)
...
@@ -791,9 +792,9 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
...
@@ -791,9 +792,9 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
UnityTestResultsFailBegin
(
lineNumber
);
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrExpected
);
UnityPrintNumberByStyle
(
actual
,
style
);
UnityPrintNumberByStyle
(
actual
,
style
);
if
(
compare
&
UNITY_GREATER_THAN
)
UnityPrint
(
UnityStrGt
);
if
(
compare
&
UNITY_GREATER_THAN
)
{
UnityPrint
(
UnityStrGt
);
}
if
(
compare
&
UNITY_SMALLER_THAN
)
UnityPrint
(
UnityStrLt
);
if
(
compare
&
UNITY_SMALLER_THAN
)
{
UnityPrint
(
UnityStrLt
);
}
if
(
compare
&
UNITY_EQUAL_TO
)
UnityPrint
(
UnityStrOrEqual
);
if
(
compare
&
UNITY_EQUAL_TO
)
{
UnityPrint
(
UnityStrOrEqual
);
}
UnityPrintNumberByStyle
(
threshold
,
style
);
UnityPrintNumberByStyle
(
threshold
,
style
);
UnityAddMsgIfSpecified
(
msg
);
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
UNITY_FAIL_AND_BAIL
;
...
@@ -836,7 +837,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
...
@@ -836,7 +837,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
UNITY_FAIL_AND_BAIL
;
UNITY_FAIL_AND_BAIL
;
}
}
while
((
elements
>
0
)
&&
elements
--
)
while
((
elements
>
0
)
&&
(
elements
--
)
)
{
{
UNITY_INT
expect_val
;
UNITY_INT
expect_val
;
UNITY_INT
actual_val
;
UNITY_INT
actual_val
;
...
@@ -865,7 +866,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
...
@@ -865,7 +866,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
if
(
expect_val
!=
actual_val
)
if
(
expect_val
!=
actual_val
)
{
{
if
(
style
&
UNITY_DISPLAY_RANGE_UINT
&&
length
<
sizeof
(
expect_val
))
if
(
(
style
&
UNITY_DISPLAY_RANGE_UINT
)
&&
(
length
<
sizeof
(
expect_val
)
))
{
/* For UINT, remove sign extension (padding 1's) from signed type casts above */
{
/* For UINT, remove sign extension (padding 1's) from signed type casts above */
UNITY_INT
mask
=
1
;
UNITY_INT
mask
=
1
;
mask
=
(
mask
<<
8
*
length
)
-
1
;
mask
=
(
mask
<<
8
*
length
)
-
1
;
...
...
src/unity_internals.h
浏览文件 @
b723c9f2
...
@@ -403,12 +403,12 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT,
...
@@ -403,12 +403,12 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT,
typedef
enum
typedef
enum
{
{
UNITY_WITHIN
=
0
,
UNITY_WITHIN
=
0
x0
,
UNITY_EQUAL_TO
=
1
,
UNITY_EQUAL_TO
=
0x
1
,
UNITY_GREATER_THAN
=
2
,
UNITY_GREATER_THAN
=
0x
2
,
UNITY_GREATER_OR_EQUAL
=
2
+
UNITY_EQUAL_TO
,
UNITY_GREATER_OR_EQUAL
=
0x
2
+
UNITY_EQUAL_TO
,
UNITY_SMALLER_THAN
=
4
,
UNITY_SMALLER_THAN
=
0x
4
,
UNITY_SMALLER_OR_EQUAL
=
4
+
UNITY_EQUAL_TO
,
UNITY_SMALLER_OR_EQUAL
=
0x
4
+
UNITY_EQUAL_TO
,
UNITY_UNKNOWN
UNITY_UNKNOWN
}
UNITY_COMPARISON_T
;
}
UNITY_COMPARISON_T
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录