Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
cc909efe
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
大约 1 年 前同步成功
通知
34
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cc909efe
编写于
4月 10, 2017
作者:
B
balaksh
提交者:
Shreyas Balakrishna
9月 10, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement optional printing of execution time for each test
上级
05daf95d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
75 addition
and
1 deletion
+75
-1
examples/unity_config.h
examples/unity_config.h
+8
-0
extras/fixture/src/unity_fixture.c
extras/fixture/src/unity_fixture.c
+4
-0
src/unity.c
src/unity.c
+3
-1
src/unity_internals.h
src/unity_internals.h
+52
-0
test/tests/testunity.c
test/tests/testunity.c
+8
-0
未找到文件。
examples/unity_config.h
浏览文件 @
cc909efe
...
...
@@ -236,4 +236,12 @@
/* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */
/* #define UNITY_PTR_ATTRIBUTE near */
/* Print execution time of each test when executed in verbose mode
*
* Example:
*
* TEST - PASS (10 ms)
*/
/* #define UNITY_INCLUDE_EXEC_TIME */
#endif
/* UNITY_CONFIG_H */
extras/fixture/src/unity_fixture.c
浏览文件 @
cc909efe
...
...
@@ -93,6 +93,8 @@ void UnityTestRunner(unityfunction* setup,
UnityMalloc_StartTest
();
UnityPointer_Init
();
UNITY_EXEC_TIME_START
();
if
(
TEST_PROTECT
())
{
setup
();
...
...
@@ -418,6 +420,8 @@ void UnityConcludeFixtureTest(void)
if
(
UnityFixture
.
Verbose
)
{
UnityPrint
(
" PASS"
);
UNITY_EXEC_TIME_STOP
();
UNITY_PRINT_EXEC_TIME
();
UNITY_PRINT_EOL
();
}
}
...
...
src/unity.c
浏览文件 @
cc909efe
...
...
@@ -370,6 +370,7 @@ void UnityConcludeTest(void)
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
UNITY_EXEC_TIME_RESET
();
UNITY_PRINT_EOL
();
UNITY_FLUSH_CALL
();
}
...
...
@@ -958,7 +959,7 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta,
if
((
style
&
UNITY_DISPLAY_RANGE_INT
)
==
UNITY_DISPLAY_RANGE_INT
)
{
if
(
actual
>
expected
)
Unity
.
CurrentTestFailed
=
(
UNITY_UINT
)((
UNITY_UINT
)(
actual
-
expected
)
>
delta
);
Unity
.
CurrentTestFailed
=
(
UNITY_UINT
)((
UNITY_UINT
)(
actual
-
expected
)
>
delta
);
else
Unity
.
CurrentTestFailed
=
(
UNITY_UINT
)((
UNITY_UINT
)(
expected
-
actual
)
>
delta
);
}
...
...
@@ -1351,6 +1352,7 @@ void UnityBegin(const char* filename)
Unity
.
TestIgnores
=
0
;
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
UNITY_EXEC_TIME_RESET
();
UNITY_CLR_DETAILS
();
UNITY_OUTPUT_START
();
...
...
src/unity_internals.h
浏览文件 @
cc909efe
...
...
@@ -32,6 +32,10 @@
#include <limits.h>
#endif
#ifndef UNITY_EXCLUDE_TIME_H
#include <time.h>
#endif
/*-------------------------------------------------------
* Guess Widths If Not Specified
*-------------------------------------------------------*/
...
...
@@ -285,6 +289,44 @@ extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION;
#define UNITY_OUTPUT_COMPLETE()
#endif
#ifndef UNITY_EXEC_TIME_RESET
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_RESET()\
Unity.CurrentTestStartTime = 0;\
Unity.CurrentTestStopTime = 0;
#else
#define UNITY_EXEC_TIME_RESET()
#endif
#endif
#ifndef UNITY_EXEC_TIME_START
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS();
#else
#define UNITY_EXEC_TIME_START()
#endif
#endif
#ifndef UNITY_EXEC_TIME_START
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS();
#else
#define UNITY_EXEC_TIME_STOP()
#endif
#endif
#ifndef UNITY_PRINT_EXEC_TIME
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_PRINT_EXEC_TIME() \
UnityPrint(" (");\
UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime);
UnityPrintNumberUnsigned
(
execTimeMs
);
\
UnityPrint
(
" ms)"
);
#else
#define UNITY_PRINT_EXEC_TIME()
#endif
#endif
/*-------------------------------------------------------
* Footprint
*-------------------------------------------------------*/
...
...
@@ -387,6 +429,10 @@ struct UNITY_STORAGE_T
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_COUNTER_TYPE
CurrentTestStartTime
;
UNITY_COUNTER_TYPE
CurrentTestStopTime
;
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
...
...
@@ -590,6 +636,12 @@ extern const char UnityStrErr64[];
#define TEST_ABORT() return
#endif
#ifndef UNITY_EXCLUDE_TIME_H
#define UNITY_CLOCK_MS() (UNITY_COUNTER_TYPE)((clock() * 1000) / CLOCKS_PER_SEC)
#else
#define UNITY_CLOCK_MS()
#endif
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
#ifndef RUN_TEST
#ifdef __STDC_VERSION__
...
...
test/tests/testunity.c
浏览文件 @
cc909efe
...
...
@@ -99,6 +99,10 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_COUNTER_TYPE
CurrentTestStartTime
;
UNITY_COUNTER_TYPE
CurrentTestStopTime
;
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
...
...
@@ -115,6 +119,10 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_COUNTER_TYPE
CurrentTestStartTime
;
UNITY_COUNTER_TYPE
CurrentTestStopTime
;
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录