Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
bcf65153
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看板
提交
bcf65153
编写于
2月 25, 2016
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Protect test runner generator against characters in strings that look like comments or functions
上级
915e3fb9
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
72 addition
and
12 deletion
+72
-12
auto/generate_test_runner.rb
auto/generate_test_runner.rb
+4
-2
test/expectdata/testsample_cmd.c
test/expectdata/testsample_cmd.c
+4
-0
test/expectdata/testsample_def.c
test/expectdata/testsample_def.c
+4
-0
test/expectdata/testsample_head1.c
test/expectdata/testsample_head1.c
+4
-0
test/expectdata/testsample_head1.h
test/expectdata/testsample_head1.h
+7
-4
test/expectdata/testsample_mock_head1.h
test/expectdata/testsample_mock_head1.h
+6
-4
test/expectdata/testsample_new1.c
test/expectdata/testsample_new1.c
+4
-0
test/expectdata/testsample_new2.c
test/expectdata/testsample_new2.c
+4
-0
test/expectdata/testsample_param.c
test/expectdata/testsample_param.c
+4
-0
test/expectdata/testsample_run1.c
test/expectdata/testsample_run1.c
+4
-0
test/expectdata/testsample_run2.c
test/expectdata/testsample_run2.c
+4
-0
test/expectdata/testsample_yaml.c
test/expectdata/testsample_yaml.c
+4
-0
test/testdata/testsample.c
test/testdata/testsample.c
+19
-2
未找到文件。
auto/generate_test_runner.rb
浏览文件 @
bcf65153
...
...
@@ -91,7 +91,9 @@ class UnityTestRunnerGenerator
def
find_tests
(
source
)
tests_and_line_numbers
=
[]
source_scrubbed
=
source
.
gsub
(
/\/\/.*$/
,
''
)
# remove line comments
source_scrubbed
=
source
.
clone
source_scrubbed
=
source_scrubbed
.
gsub
(
/"[^"]*"/
,
''
)
# remove things in 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
| (;|\{|\}) /x
)
# Match ;, {, and } as end of lines
...
...
@@ -329,7 +331,7 @@ class UnityTestRunnerGenerator
output
.
puts
(
"#include
#{
inc
.
include?
(
'<'
)
?
inc
:
"
\"
#{
inc
.
gsub
(
'.h'
,
''
)
}
.h
\"
"
}
"
)
end
output
.
puts
"
\n
"
tests
.
each
do
|
test
|
tests
.
each
do
|
test
|
if
((
test
[
:params
].
nil?
)
or
(
test
[
:params
].
empty?
))
output
.
puts
(
"void
#{
test
[
:test
]
}
(void);"
)
else
...
...
test/expectdata/testsample_cmd.c
浏览文件 @
bcf65153
...
...
@@ -35,6 +35,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -52,6 +54,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/expectdata/testsample_def.c
浏览文件 @
bcf65153
...
...
@@ -31,6 +31,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -48,6 +50,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/expectdata/testsample_head1.c
浏览文件 @
bcf65153
...
...
@@ -29,6 +29,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -46,6 +48,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/expectdata/testsample_head1.h
浏览文件 @
bcf65153
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _
_B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___H_E_A_D_1__H_
#define _
_B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___H_E_A_D_1__H_
#ifndef _
TESTSAMPLE_HEAD1_H
#define _
TESTSAMPLE_HEAD1_H
#include "unity.h"
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
void
test_TheFirstThingToTest
();
void
test_TheSecondThingToTest
();
void
test_TheFirstThingToTest
(
void
);
void
test_TheSecondThingToTest
(
void
);
void
test_TheThirdThingToTest
(
void
);
void
test_TheFourthThingToTest
(
void
);
#endif
test/expectdata/testsample_mock_head1.h
浏览文件 @
bcf65153
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _
_B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___M_O_C_K___H_E_A_D_1__H_
#define _
_B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___M_O_C_K___H_E_A_D_1__H_
#ifndef _
TESTSAMPLE_MOCK_HEAD1_H
#define _
TESTSAMPLE_MOCK_HEAD1_H
#include "unity.h"
#include "cmock.h"
#include "funky.h"
#include <setjmp.h>
void
test_TheFirstThingToTest
();
void
test_TheSecondThingToTest
();
void
test_TheFirstThingToTest
(
void
);
void
test_TheSecondThingToTest
(
void
);
#endif
test/expectdata/testsample_new1.c
浏览文件 @
bcf65153
...
...
@@ -41,6 +41,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -58,6 +60,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/expectdata/testsample_new2.c
浏览文件 @
bcf65153
...
...
@@ -31,6 +31,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Suite Setup=====
...
...
@@ -61,6 +63,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
suite_teardown
(
UnityEnd
());
}
test/expectdata/testsample_param.c
浏览文件 @
bcf65153
...
...
@@ -32,6 +32,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -49,6 +51,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
,
RUN_TEST_NO_ARGS
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
,
RUN_TEST_NO_ARGS
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
,
RUN_TEST_NO_ARGS
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
,
RUN_TEST_NO_ARGS
);
return
(
UnityEnd
());
}
test/expectdata/testsample_run1.c
浏览文件 @
bcf65153
...
...
@@ -41,6 +41,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Test Reset Option=====
...
...
@@ -58,6 +60,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/expectdata/testsample_run2.c
浏览文件 @
bcf65153
...
...
@@ -31,6 +31,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Suite Setup=====
...
...
@@ -61,6 +63,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
suite_teardown
(
UnityEnd
());
}
test/expectdata/testsample_yaml.c
浏览文件 @
bcf65153
...
...
@@ -38,6 +38,8 @@ extern void setUp(void);
extern
void
tearDown
(
void
);
extern
void
test_TheFirstThingToTest
(
void
);
extern
void
test_TheSecondThingToTest
(
void
);
extern
void
test_TheThirdThingToTest
(
void
);
extern
void
test_TheFourthThingToTest
(
void
);
//=======Suite Setup=====
...
...
@@ -62,6 +64,8 @@ int main(void)
UnityBegin
(
"testdata/testsample.c"
);
RUN_TEST
(
test_TheFirstThingToTest
,
21
);
RUN_TEST
(
test_TheSecondThingToTest
,
43
);
RUN_TEST
(
test_TheThirdThingToTest
,
53
);
RUN_TEST
(
test_TheFourthThingToTest
,
58
);
return
(
UnityEnd
());
}
test/testdata/testsample.c
浏览文件 @
bcf65153
...
...
@@ -35,15 +35,32 @@ void test_ShouldBeIgnored(void)
//void test_ShouldAlsoNotBeTested(void)
//{
// Call_An_Expect();
//
//
// CallAFunction();
// test_CallAFunctionThatLooksLikeATest();
//}
void
test_TheSecondThingToTest
(
void
)
{
uint8_t
*
crazyString
=
"GET / HTTP/1.1
\r\n
Host: 127.0.0.1:8081
\r\n
Connection: keep-alive
\r\n
Cache-Control: no-cache
\r\n
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
\r\n
Postman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2
\r\n
Accept: */*
\r\n
Accept-Encoding: gzip, deflate, sdch
\r\n
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
\r\n\r\n
"
;
Call_An_Expect
();
CallAFunction
();
test_CallAFunctionThatLooksLikeATest
();
}
void
test_TheThirdThingToTest
(
void
)
{
CallAFunction
();
}
void
test_TheFourthThingToTest
(
void
)
{
uint8_t
*
anotherString
=
"GET / HTTP/1.1
\r\n
Host: 127.0.0.1:8081
\r\n
Connection: keep-alive
\r\n
Cache-Control: no-cache
\r\n
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
\r\n
Postman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2
\r\n
Accept: */*
\r\n
Accept-Encoding: gzip, deflate, sdch
\r\n
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
\r\n\r\n
"
;
Call_An_Expect
();
CallAFunction
();
test_CallAFunctionThatLooksLikeATest
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录