Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
f1fdc47e
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,发现更多精彩内容 >>
提交
f1fdc47e
编写于
1月 18, 2017
作者:
M
Mark VanderVoord
提交者:
GitHub
1月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #250 from jsalling/feature/optional-setjmp
Optional UNITY_EXCLUDE_SETJMP_H, different control flow
上级
74f377f0
de6f5163
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
25 deletion
+42
-25
src/unity.c
src/unity.c
+27
-22
src/unity.h
src/unity.h
+1
-1
src/unity_internals.h
src/unity_internals.h
+10
-2
test/tests/testunity.c
test/tests/testunity.c
+4
-0
未找到文件。
src/unity.c
浏览文件 @
f1fdc47e
...
...
@@ -13,8 +13,8 @@ void UNITY_OUTPUT_CHAR(int);
#endif
/* Helpful macros for us to use here in Assert functions */
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1;
longjmp(Unity.AbortFrame, 1
); }
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1;
longjmp(Unity.AbortFrame, 1
); }
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1;
TEST_ABORT(
); }
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1;
TEST_ABORT(
); }
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return
struct
UNITY_STORAGE_T
Unity
;
...
...
@@ -480,32 +480,32 @@ static void UnityPrintExpectedAndActualStringsLen(const char* expected, const ch
* Assertion & Control Helpers
*-----------------------------------------------*/
static
int
UnityCheckArraysForNull
(
UNITY_INTERNAL_PTR
expected
,
UNITY_INTERNAL_PTR
actual
,
const
UNITY_LINE_TYPE
lineNumber
,
const
char
*
msg
)
static
int
UnityIsOneArrayNull
(
UNITY_INTERNAL_PTR
expected
,
UNITY_INTERNAL_PTR
actual
,
const
UNITY_LINE_TYPE
lineNumber
,
const
char
*
msg
)
{
/* return true if they are both NULL */
if
((
expected
==
NULL
)
&&
(
actual
==
NULL
))
return
1
;
if
(
expected
==
actual
)
return
0
;
/* Both are NULL or same pointer */
/*
throw error
if just expected is NULL */
/*
print and return true
if just expected is NULL */
if
(
expected
==
NULL
)
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrNullPointerForExpected
);
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
return
1
;
}
/*
throw error
if just actual is NULL */
/*
print and return true
if just actual is NULL */
if
(
actual
==
NULL
)
{
UnityTestResultsFailBegin
(
lineNumber
);
UnityPrint
(
UnityStrNullPointerForActual
);
UnityAddMsgIfSpecified
(
msg
);
UNITY_FAIL_AND_BAIL
;
return
1
;
}
/* return false if neither is NULL */
return
0
;
return
0
;
/* return false if neither is NULL */
}
/*-----------------------------------------------
...
...
@@ -578,8 +578,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
UnityPrintPointlessAndBail
();
}
if
(
UnityCheckArraysForNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
)
==
1
)
return
;
if
(
expected
==
actual
)
return
;
/* Both are NULL or same pointer */
if
(
UnityIsOneArrayNull
(
expected
,
actual
,
lineNumber
,
msg
))
UNITY_FAIL_AND_BAIL
;
while
(
elements
--
)
{
...
...
@@ -685,8 +686,9 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
UnityPrintPointlessAndBail
();
}
if
(
UnityCheckArraysForNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
)
==
1
)
return
;
if
(
expected
==
actual
)
return
;
/* Both are NULL or same pointer */
if
(
UnityIsOneArrayNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
))
UNITY_FAIL_AND_BAIL
;
while
(
elements
--
)
{
...
...
@@ -810,8 +812,9 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte
UnityPrintPointlessAndBail
();
}
if
(
UnityCheckArraysForNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
)
==
1
)
return
;
if
(
expected
==
actual
)
return
;
/* Both are NULL or same pointer */
if
(
UnityIsOneArrayNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
))
UNITY_FAIL_AND_BAIL
;
while
(
elements
--
)
{
...
...
@@ -1047,8 +1050,9 @@ void UnityAssertEqualStringArray( const char** expected,
UnityPrintPointlessAndBail
();
}
if
(
UnityCheckArraysForNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
)
==
1
)
return
;
if
(
expected
==
actual
)
return
;
/* Both are NULL or same pointer */
if
(
UnityIsOneArrayNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
))
UNITY_FAIL_AND_BAIL
;
do
{
...
...
@@ -1107,8 +1111,9 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
UnityPrintPointlessAndBail
();
}
if
(
UnityCheckArraysForNull
((
UNITY_INTERNAL_PTR
)
expected
,
(
UNITY_INTERNAL_PTR
)
actual
,
lineNumber
,
msg
)
==
1
)
return
;
if
(
expected
==
actual
)
return
;
/* Both are NULL or same pointer */
if
(
UnityIsOneArrayNull
(
expected
,
actual
,
lineNumber
,
msg
))
UNITY_FAIL_AND_BAIL
;
while
(
elements
--
)
{
...
...
src/unity.h
浏览文件 @
f1fdc47e
...
...
@@ -72,7 +72,7 @@ void tearDown(void);
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
#define TEST_PASS()
longjmp(Unity.AbortFrame, 1
)
#define TEST_PASS()
TEST_ABORT(
)
/*-------------------------------------------------------
* Test Asserts (simple)
...
...
src/unity_internals.h
浏览文件 @
f1fdc47e
...
...
@@ -11,7 +11,9 @@
#include "unity_config.h"
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
#include <setjmp.h>
#endif
#ifndef UNITY_EXCLUDE_MATH_H
#include <math.h>
...
...
@@ -374,7 +376,9 @@ struct UNITY_STORAGE_T
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
};
extern
struct
UNITY_STORAGE_T
Unity
;
...
...
@@ -537,9 +541,13 @@ extern const char UnityStrErr64[];
* Test Running Macros
*-------------------------------------------------------*/
#ifndef UNITY_EXCLUDE_SETJMP_H
#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0)
#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);}
#define TEST_ABORT() longjmp(Unity.AbortFrame, 1)
#else
#define TEST_PROTECT() 1
#define TEST_ABORT() return
#endif
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
#ifndef RUN_TEST
...
...
test/tests/testunity.c
浏览文件 @
f1fdc47e
...
...
@@ -99,7 +99,9 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
}
_Expected_Unity
;
#else
struct
{
...
...
@@ -113,7 +115,9 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE
TestIgnores
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
#endif
}
_Expected_Unity
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录