Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
83f7d523
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
9 个月 前同步成功
通知
29
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,体验更适合开发者的 AI 搜索 >>
提交
83f7d523
编写于
9月 09, 2015
作者:
A
Andrzej Bieniek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change example_1 to compile with std=c89
上级
61dd3f18
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
36 deletion
+36
-36
examples/example_1/makefile
examples/example_1/makefile
+1
-1
examples/example_1/src/ProductionCode.c
examples/example_1/src/ProductionCode.c
+7
-7
examples/example_1/src/ProductionCode2.c
examples/example_1/src/ProductionCode2.c
+2
-2
examples/example_1/test/TestProductionCode.c
examples/example_1/test/TestProductionCode.c
+14
-14
examples/example_1/test/TestProductionCode2.c
examples/example_1/test/TestProductionCode2.c
+2
-2
examples/example_1/test/test_runners/TestProductionCode2_Runner.c
.../example_1/test/test_runners/TestProductionCode2_Runner.c
+5
-5
examples/example_1/test/test_runners/TestProductionCode_Runner.c
...s/example_1/test/test_runners/TestProductionCode_Runner.c
+5
-5
未找到文件。
examples/example_1/makefile
浏览文件 @
83f7d523
...
...
@@ -26,7 +26,7 @@ endif
UNITY_ROOT
=
../..
C_COMPILER
=
gcc
CFLAGS
=
-std
=
c
9
9
CFLAGS
=
-std
=
c
8
9
CFLAGS
+=
-Wall
CFLAGS
+=
-Wextra
CFLAGS
+=
-Werror
...
...
examples/example_1/src/ProductionCode.c
浏览文件 @
83f7d523
...
...
@@ -2,18 +2,18 @@
#include "ProductionCode.h"
int
Counter
=
0
;
int
NumbersToFind
[
9
]
=
{
0
,
34
,
55
,
66
,
32
,
11
,
1
,
77
,
888
};
/
/some obnoxious array to search that is 1-based indexing instead of 0.
int
NumbersToFind
[
9
]
=
{
0
,
34
,
55
,
66
,
32
,
11
,
1
,
77
,
888
};
/
* some obnoxious array to search that is 1-based indexing instead of 0. */
/
/
This function is supposed to search through NumbersToFind and find a particular number.
//
If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since
//
NumbersToFind is indexed from 1. Unfortunately it's broken
// (and should therefore be caught by our tests)
/
*
This function is supposed to search through NumbersToFind and find a particular number.
*
If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since
*
NumbersToFind is indexed from 1. Unfortunately it's broken
* (and should therefore be caught by our tests) */
int
FindFunction_WhichIsBroken
(
int
NumberToFind
)
{
int
i
=
0
;
while
(
i
<=
8
)
/
/Notice I should have been in braces
while
(
i
<=
8
)
/
* Notice I should have been in braces */
i
++
;
if
(
NumbersToFind
[
i
]
==
NumberToFind
)
/
/Yikes! I'm getting run after the loop finishes instead of during it!
if
(
NumbersToFind
[
i
]
==
NumberToFind
)
/
* Yikes! I'm getting run after the loop finishes instead of during it! */
return
i
;
return
0
;
}
...
...
examples/example_1/src/ProductionCode2.c
浏览文件 @
83f7d523
...
...
@@ -5,7 +5,7 @@ char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
{
(
void
)
Poor
;
(
void
)
LittleFunction
;
/
/
Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
/
*
Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
* Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget */
return
(
char
*
)
0
;
}
examples/example_1/test/TestProductionCode.c
浏览文件 @
83f7d523
...
...
@@ -2,14 +2,14 @@
#include "ProductionCode.h"
#include "unity.h"
/
/
sometimes you may want to get at local data in a module.
//
for example: If you plan to pass by reference, this could be useful
//however, it should often be avoided
/
*
sometimes you may want to get at local data in a module.
*
for example: If you plan to pass by reference, this could be useful
* however, it should often be avoided */
extern
int
Counter
;
void
setUp
(
void
)
{
/
/This is run before EACH TEST
/
* This is run before EACH TEST */
Counter
=
0x5a5a
;
}
...
...
@@ -19,7 +19,7 @@ void tearDown(void)
void
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
(
void
)
{
/
/All of these should pass
/
* All of these should pass */
TEST_ASSERT_EQUAL
(
0
,
FindFunction_WhichIsBroken
(
78
));
TEST_ASSERT_EQUAL
(
0
,
FindFunction_WhichIsBroken
(
1
));
TEST_ASSERT_EQUAL
(
0
,
FindFunction_WhichIsBroken
(
33
));
...
...
@@ -29,34 +29,34 @@ void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWork
void
test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken
(
void
)
{
/
/ You should see this line fail in your test summary
/
* You should see this line fail in your test summary */
TEST_ASSERT_EQUAL
(
1
,
FindFunction_WhichIsBroken
(
34
));
/
/
Notice the rest of these didn't get a chance to run because the line above failed.
//
Unit tests abort each test function on the first sign of trouble.
// Then NEXT test function runs as normal.
/
*
Notice the rest of these didn't get a chance to run because the line above failed.
*
Unit tests abort each test function on the first sign of trouble.
* Then NEXT test function runs as normal. */
TEST_ASSERT_EQUAL
(
8
,
FindFunction_WhichIsBroken
(
8888
));
}
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue
(
void
)
{
/
/This should be true because setUp set this up for us before this test
/
* This should be true because setUp set this up for us before this test */
TEST_ASSERT_EQUAL_HEX
(
0x5a5a
,
FunctionWhichReturnsLocalVariable
());
/
/This should be true because we can still change our answer
/
* This should be true because we can still change our answer */
Counter
=
0x1234
;
TEST_ASSERT_EQUAL_HEX
(
0x1234
,
FunctionWhichReturnsLocalVariable
());
}
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain
(
void
)
{
/
/This should be true again because setup was rerun before this test (and after we changed it to 0x1234)
/
* This should be true again because setup was rerun before this test (and after we changed it to 0x1234) */
TEST_ASSERT_EQUAL_HEX
(
0x5a5a
,
FunctionWhichReturnsLocalVariable
());
}
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
)
{
/
/
Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell
// you what actually happened...which in this case was a failure to setup the initial condition.
/
*
Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell
* you what actually happened...which in this case was a failure to setup the initial condition. */
TEST_ASSERT_EQUAL_HEX
(
0x1234
,
FunctionWhichReturnsLocalVariable
());
}
examples/example_1/test/TestProductionCode2.c
浏览文件 @
83f7d523
...
...
@@ -4,8 +4,8 @@
/* These should be ignored because they are commented out in various ways:
#include "whatever.h"
#include "somethingelse.h"
*/
//#include "somethingelse.h"
void
setUp
(
void
)
{
...
...
@@ -27,5 +27,5 @@ void test_AnotherIgnoredTest(void)
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
)
{
TEST_IGNORE
();
/
/Like This
TEST_IGNORE
();
/
* Like This */
}
examples/example_1/test/test_runners/TestProductionCode2_Runner.c
浏览文件 @
83f7d523
/* AUTOGENERATED FILE. DO NOT EDIT. */
/
/=======Test Runner Used To Run Each Test Below=====
/
*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
...
...
@@ -18,13 +18,13 @@
UnityConcludeTest(); \
}
/
/=======Automagically Detected Files To Include=====
/
*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "ProductionCode2.h"
/
/=======External Functions This Runner Calls=====
/
*=======External Functions This Runner Calls=====*/
extern
void
setUp
(
void
);
extern
void
tearDown
(
void
);
extern
void
test_IgnoredTest
(
void
);
...
...
@@ -32,7 +32,7 @@ extern void test_AnotherIgnoredTest(void);
extern
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
);
/
/=======Test Reset Option=====
/
*=======Test Reset Option=====*/
void
resetTest
(
void
);
void
resetTest
(
void
)
{
...
...
@@ -41,7 +41,7 @@ void resetTest(void)
}
/
/=======MAIN=====
/
*=======MAIN=====*/
int
main
(
void
)
{
UnityBegin
(
"test/TestProductionCode2.c"
);
...
...
examples/example_1/test/test_runners/TestProductionCode_Runner.c
浏览文件 @
83f7d523
/* AUTOGENERATED FILE. DO NOT EDIT. */
/
/=======Test Runner Used To Run Each Test Below=====
/
*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
...
...
@@ -18,13 +18,13 @@
UnityConcludeTest(); \
}
/
/=======Automagically Detected Files To Include=====
/
*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "ProductionCode.h"
/
/=======External Functions This Runner Calls=====
/
*=======External Functions This Runner Calls=====*/
extern
void
setUp
(
void
);
extern
void
tearDown
(
void
);
extern
void
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
(
void
);
...
...
@@ -34,7 +34,7 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
);
/
/=======Test Reset Option=====
/
*=======Test Reset Option=====*/
void
resetTest
(
void
);
void
resetTest
(
void
)
{
...
...
@@ -43,7 +43,7 @@ void resetTest(void)
}
/
/=======MAIN=====
/
*=======MAIN=====*/
int
main
(
void
)
{
UnityBegin
(
"test/TestProductionCode.c"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录