Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
7fb81c8e
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
接近 2 年 前同步成功
通知
38
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看板
提交
7fb81c8e
编写于
3月 12, 2015
作者:
G
Greg Williams
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:ThrowTheSwitch/Unity
上级
a24bd455
891775de
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
343 addition
and
146 deletion
+343
-146
.gitignore
.gitignore
+5
-0
auto/unity_test_summary.py
auto/unity_test_summary.py
+135
-0
docs/license.txt
docs/license.txt
+18
-28
examples/example_1/makefile
examples/example_1/makefile
+19
-0
examples/example_1/src/ProductionCode2.c
examples/example_1/src/ProductionCode2.c
+2
-0
examples/example_1/test/test_runners/TestProductionCode2_Runner.c
.../example_1/test/test_runners/TestProductionCode2_Runner.c
+0
-13
examples/example_1/test/test_runners/TestProductionCode_Runner.c
...s/example_1/test/test_runners/TestProductionCode_Runner.c
+0
-13
examples/example_2/makefile
examples/example_2/makefile
+23
-1
examples/example_2/src/ProductionCode2.c
examples/example_2/src/ProductionCode2.c
+2
-0
examples/example_2/test/test_runners/all_tests.c
examples/example_2/test/test_runners/all_tests.c
+2
-2
examples/example_3/makefile
examples/example_3/makefile
+19
-0
examples/example_3/src/ProductionCode2.c
examples/example_3/src/ProductionCode2.c
+2
-0
examples/example_3/test/no_ruby/TestProductionCode2_Runner.c
examples/example_3/test/no_ruby/TestProductionCode2_Runner.c
+0
-13
examples/example_3/test/no_ruby/TestProductionCode_Runner.c
examples/example_3/test/no_ruby/TestProductionCode_Runner.c
+0
-13
extras/fixture/rakefile.rb
extras/fixture/rakefile.rb
+14
-3
extras/fixture/src/unity_fixture.c
extras/fixture/src/unity_fixture.c
+22
-11
extras/fixture/src/unity_fixture.h
extras/fixture/src/unity_fixture.h
+8
-4
extras/fixture/src/unity_fixture_internals.h
extras/fixture/src/unity_fixture_internals.h
+1
-1
extras/fixture/src/unity_fixture_malloc_overrides.h
extras/fixture/src/unity_fixture_malloc_overrides.h
+5
-0
extras/fixture/test/main/AllTests.c
extras/fixture/test/main/AllTests.c
+2
-2
extras/fixture/test/unity_fixture_Test.c
extras/fixture/test/unity_fixture_Test.c
+9
-9
extras/fixture/test/unity_output_Spy.c
extras/fixture/test/unity_output_Spy.c
+2
-2
extras/fixture/test/unity_output_Spy.h
extras/fixture/test/unity_output_Spy.h
+2
-2
src/unity.c
src/unity.c
+26
-17
src/unity_internals.h
src/unity_internals.h
+9
-12
test/targets/gcc_auto_stdint.yml
test/targets/gcc_auto_stdint.yml
+16
-0
未找到文件。
.gitignore
浏览文件 @
7fb81c8e
build/
build/
.DS_Store
.DS_Store
examples/example_1/test1.out
examples/example_1/test2.out
examples/example_2/all_tests.out
examples/example_3/test1.out
examples/example_3/test2.out
auto/unity_test_summary.py
0 → 100644
浏览文件 @
7fb81c8e
#! python3
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de
# [Released under MIT License. Please refer to license.txt for details]
# Based on the ruby script by Mike Karlesky, Mark VanderVoord, Greg Williams
# ==========================================
import
sys
import
os
import
re
from
glob
import
glob
class
UnityTestSummary
:
def
__init__
(
self
):
self
.
report
=
''
self
.
total_tests
=
0
self
.
failures
=
0
self
.
ignored
=
0
def
run
(
self
):
# Clean up result file names
results
=
[]
for
target
in
self
.
targets
:
results
.
append
(
target
.
replace
(
'
\\
'
,
'/'
))
# Dig through each result file, looking for details on pass/fail:
failure_output
=
[]
ignore_output
=
[]
for
result_file
in
results
:
lines
=
list
(
map
(
lambda
line
:
line
.
rstrip
(),
open
(
result_file
,
"r"
).
read
().
split
(
'
\n
'
)))
if
len
(
lines
)
==
0
:
raise
Exception
(
"Empty test result file: %s"
%
result_file
)
details
=
self
.
get_details
(
result_file
,
lines
)
failures
=
details
[
'failures'
]
ignores
=
details
[
'ignores'
]
if
len
(
failures
)
>
0
:
failure_output
.
append
(
'
\n
'
.
join
(
failures
))
if
len
(
ignores
)
>
0
:
ignore_output
.
append
(
'n'
.
join
(
ignores
))
tests
,
failures
,
ignored
=
self
.
parse_test_summary
(
'
\n
'
.
join
(
lines
))
self
.
total_tests
+=
tests
self
.
failures
+=
failures
self
.
ignored
+=
ignored
if
self
.
ignored
>
0
:
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"UNITY IGNORED TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"
\n
"
.
join
(
ignore_output
)
if
self
.
failures
>
0
:
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"UNITY FAILED TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
'
\n
'
.
join
(
failure_output
)
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"OVERALL UNITY TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"{total_tests} TOTAL TESTS {failures} TOTAL FAILURES {ignored} IGNORED
\n
"
.
format
(
total_tests
=
self
.
total_tests
,
failures
=
self
.
failures
,
ignored
=
self
.
ignored
)
self
.
report
+=
"
\n
"
return
self
.
report
def
set_targets
(
self
,
target_array
):
self
.
targets
=
target_array
def
set_root_path
(
self
,
path
):
self
.
root
=
path
def
usage
(
self
,
err_msg
=
None
):
print
(
"
\n
ERROR: "
)
if
err_msg
:
print
(
err_msg
)
print
(
"
\n
Usage: unity_test_summary.rb result_file_directory/ root_path/"
)
print
(
" result_file_directory - The location of your results files."
)
print
(
" Defaults to current directory if not specified."
)
print
(
" Should end in / if specified."
)
print
(
" root_path - Helpful for producing more verbose output if using relative paths."
)
sys
.
exit
(
1
)
def
get_details
(
self
,
result_file
,
lines
):
results
=
{
'failures'
:
[],
'ignores'
:
[],
'successes'
:
[]
}
for
line
in
lines
:
parts
=
line
.
split
(
':'
)
if
len
(
parts
)
!=
5
:
continue
src_file
,
src_line
,
test_name
,
status
,
msg
=
parts
if
len
(
self
.
root
)
>
0
:
line_out
=
"%s%s"
%
(
self
.
root
,
line
)
else
:
line_out
=
line
if
status
==
'IGNORE'
:
results
[
'ignores'
].
append
(
line_out
)
elif
status
==
'FAIL'
:
results
[
'failures'
].
append
(
line_out
)
elif
status
==
'PASS'
:
results
[
'successes'
].
append
(
line_out
)
return
results
def
parse_test_summary
(
self
,
summary
):
m
=
re
.
search
(
r
"([0-9]+) Tests ([0-9]+) Failures ([0-9]+) Ignored"
,
summary
)
if
not
m
:
raise
Exception
(
"Couldn't parse test results: %s"
%
summary
)
return
int
(
m
.
group
(
1
)),
int
(
m
.
group
(
2
)),
int
(
m
.
group
(
3
))
if
__name__
==
'__main__'
:
uts
=
UnityTestSummary
()
try
:
#look in the specified or current directory for result files
if
len
(
sys
.
argv
)
>
1
:
targets_dir
=
sys
.
argv
[
1
]
else
:
targets_dir
=
'./'
targets
=
list
(
map
(
lambda
x
:
x
.
replace
(
'
\\
'
,
'/'
),
glob
(
targets_dir
+
'*.test*'
)))
if
len
(
targets
)
==
0
:
raise
Exception
(
"No *.testpass or *.testfail files found in '%s'"
%
targets_dir
)
uts
.
set_targets
(
targets
)
#set the root path
if
len
(
sys
.
argv
)
>
2
:
root_path
=
sys
.
argv
[
2
]
else
:
root_path
=
os
.
path
.
split
(
__file__
)[
0
]
uts
.
set_root_path
(
root_path
)
#run the summarizer
print
(
uts
.
run
())
except
Exception
as
e
:
uts
.
usage
(
e
)
docs/license.txt
浏览文件 @
7fb81c8e
Copyright (c) 2007-2010 Mike Karlesky, Mark VanderVoord, Greg Williams
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person
Copyright (c) <year> 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
Permission is hereby granted, free of charge, to any person obtaining a copy
included in all copies or substantial portions of the Software.
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The end-user documentation included with the redistribution, if
The above copyright notice and this permission notice shall be included in
any, must include the following acknowledgment: "This product
all copies or substantial portions of the Software.
includes software developed for the Unity Project, by Mike Karlesky,
Mark VanderVoord, and Greg Williams and other contributors", in
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
the same place and form as other third-party acknowledgments.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Alternately, this acknowledgment may appear in the software
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
itself, in the same form and location as other such third-party
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
acknowledgments.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
THE SOFTWARE.
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
examples/example_1/makefile
浏览文件 @
7fb81c8e
...
@@ -21,7 +21,26 @@ endif
...
@@ -21,7 +21,26 @@ endif
UNITY_ROOT
=
../..
UNITY_ROOT
=
../..
C_COMPILER
=
gcc
C_COMPILER
=
gcc
CFLAGS
=
-std
=
c99
CFLAGS
=
-std
=
c99
CFLAGS
+=
-Wall
CFLAGS
+=
-Wextra
CFLAGS
+=
-Werror
CFLAGS
+=
-Wpointer-arith
CFLAGS
+=
-Wcast-align
CFLAGS
+=
-Wwrite-strings
CFLAGS
+=
-Wswitch-default
CFLAGS
+=
-Wunreachable-code
CFLAGS
+=
-Winit-self
CFLAGS
+=
-Wlogical-op
CFLAGS
+=
-Wmissing-field-initializers
CFLAGS
+=
-Wno-unknown-pragmas
CFLAGS
+=
-Wjump-misses-init
CFLAGS
+=
-Wstrict-prototypes
CFLAGS
+=
-Wundef
CFLAGS
+=
-Wunsafe-loop-optimizations
CFLAGS
+=
-Wold-style-definition
TARGET_BASE1
=
test1
TARGET_BASE1
=
test1
TARGET_BASE2
=
test2
TARGET_BASE2
=
test2
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
...
...
examples/example_1/src/ProductionCode2.c
浏览文件 @
7fb81c8e
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
char
*
ThisFunctionHasNotBeenTested
(
int
Poor
,
char
*
LittleFunction
)
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.
//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
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
return
(
char
*
)
0
;
return
(
char
*
)
0
;
...
...
examples/example_1/test/test_runners/TestProductionCode2_Runner.c
浏览文件 @
7fb81c8e
...
@@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
...
@@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
extern
void
test_AnotherIgnoredTest
(
void
);
extern
void
test_AnotherIgnoredTest
(
void
);
extern
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
);
extern
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
);
static
void
runTest
(
UnityTestFunction
test
)
{
if
(
TEST_PROTECT
())
{
setUp
();
test
();
}
if
(
TEST_PROTECT
()
&&
!
TEST_IS_IGNORED
)
{
tearDown
();
}
}
void
resetTest
(
void
);
void
resetTest
(
void
);
void
resetTest
(
void
)
void
resetTest
(
void
)
{
{
...
@@ -36,7 +24,6 @@ int main(void)
...
@@ -36,7 +24,6 @@ int main(void)
{
{
UnityBegin
(
"test/TestProductionCode2.c"
);
UnityBegin
(
"test/TestProductionCode2.c"
);
// RUN_TEST calls runTest
RUN_TEST
(
test_IgnoredTest
,
13
);
RUN_TEST
(
test_IgnoredTest
,
13
);
RUN_TEST
(
test_AnotherIgnoredTest
,
18
);
RUN_TEST
(
test_AnotherIgnoredTest
,
18
);
RUN_TEST
(
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
,
23
);
RUN_TEST
(
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
,
23
);
...
...
examples/example_1/test/test_runners/TestProductionCode_Runner.c
浏览文件 @
7fb81c8e
...
@@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
...
@@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
);
static
void
runTest
(
UnityTestFunction
test
)
{
if
(
TEST_PROTECT
())
{
setUp
();
test
();
}
if
(
TEST_PROTECT
()
&&
!
TEST_IS_IGNORED
)
{
tearDown
();
}
}
void
resetTest
(
void
);
void
resetTest
(
void
);
void
resetTest
(
void
)
void
resetTest
(
void
)
{
{
...
@@ -38,7 +26,6 @@ int main(void)
...
@@ -38,7 +26,6 @@ int main(void)
{
{
UnityBegin
(
"test/TestProductionCode.c"
);
UnityBegin
(
"test/TestProductionCode.c"
);
// RUN_TEST calls runTest
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
,
20
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
,
20
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken
,
30
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken
,
30
);
RUN_TEST
(
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue
,
41
);
RUN_TEST
(
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue
,
41
);
...
...
examples/example_2/makefile
浏览文件 @
7fb81c8e
...
@@ -21,6 +21,28 @@ endif
...
@@ -21,6 +21,28 @@ endif
UNITY_ROOT
=
../..
UNITY_ROOT
=
../..
C_COMPILER
=
gcc
C_COMPILER
=
gcc
CFLAGS
=
-std
=
c99
CFLAGS
+=
-Wall
CFLAGS
+=
-Wextra
CFLAGS
+=
-Werror
CFLAGS
+=
-Wpointer-arith
CFLAGS
+=
-Wcast-align
CFLAGS
+=
-Wwrite-strings
CFLAGS
+=
-Wswitch-default
CFLAGS
+=
-Wunreachable-code
CFLAGS
+=
-Winit-self
CFLAGS
+=
-Wlogical-op
CFLAGS
+=
-Wmissing-field-initializers
CFLAGS
+=
-Wno-unknown-pragmas
CFLAGS
+=
-Wjump-misses-init
CFLAGS
+=
-Wstrict-prototypes
CFLAGS
+=
-Wundef
CFLAGS
+=
-Wunsafe-loop-optimizations
CFLAGS
+=
-Wold-style-definition
CFLAGS
+=
-Wmissing-prototypes
CFLAGS
+=
-Wmissing-declarations
TARGET_BASE1
=
all_tests
TARGET_BASE1
=
all_tests
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
SRC_FILES1
=
\
SRC_FILES1
=
\
...
@@ -41,7 +63,7 @@ all: clean default
...
@@ -41,7 +63,7 @@ all: clean default
default
:
default
:
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
$(C_COMPILER)
$(INC_DIRS)
$(SYMBOLS)
$(SRC_FILES1)
-o
$(TARGET1)
$(C_COMPILER)
$(
CFLAGS)
$(
INC_DIRS)
$(SYMBOLS)
$(SRC_FILES1)
-o
$(TARGET1)
./$(TARGET1)
./$(TARGET1)
clean
:
clean
:
...
...
examples/example_2/src/ProductionCode2.c
浏览文件 @
7fb81c8e
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
char
*
ThisFunctionHasNotBeenTested
(
int
Poor
,
char
*
LittleFunction
)
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.
//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
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
return
(
char
*
)
0
;
return
(
char
*
)
0
;
...
...
examples/example_2/test/test_runners/all_tests.c
浏览文件 @
7fb81c8e
...
@@ -6,7 +6,7 @@ static void RunAllTests(void)
...
@@ -6,7 +6,7 @@ static void RunAllTests(void)
RUN_TEST_GROUP
(
ProductionCode2
);
RUN_TEST_GROUP
(
ProductionCode2
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
c
onst
c
har
*
argv
[])
{
{
return
UnityMain
(
argc
,
argv
,
RunAllTests
);
return
UnityMain
(
argc
,
argv
,
RunAllTests
);
}
}
\ No newline at end of file
examples/example_3/makefile
浏览文件 @
7fb81c8e
...
@@ -21,7 +21,26 @@ endif
...
@@ -21,7 +21,26 @@ endif
UNITY_ROOT
=
../..
UNITY_ROOT
=
../..
C_COMPILER
=
gcc
C_COMPILER
=
gcc
CFLAGS
=
-std
=
c99
CFLAGS
=
-std
=
c99
CFLAGS
+=
-Wall
CFLAGS
+=
-Wextra
CFLAGS
+=
-Werror
CFLAGS
+=
-Wpointer-arith
CFLAGS
+=
-Wcast-align
CFLAGS
+=
-Wwrite-strings
CFLAGS
+=
-Wswitch-default
CFLAGS
+=
-Wunreachable-code
CFLAGS
+=
-Winit-self
CFLAGS
+=
-Wlogical-op
CFLAGS
+=
-Wmissing-field-initializers
CFLAGS
+=
-Wno-unknown-pragmas
CFLAGS
+=
-Wjump-misses-init
CFLAGS
+=
-Wstrict-prototypes
CFLAGS
+=
-Wundef
CFLAGS
+=
-Wunsafe-loop-optimizations
CFLAGS
+=
-Wold-style-definition
TARGET_BASE1
=
test1
TARGET_BASE1
=
test1
TARGET_BASE2
=
test2
TARGET_BASE2
=
test2
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
TARGET1
=
$(TARGET_BASE1)$(TARGET_EXTENSION)
...
...
examples/example_3/src/ProductionCode2.c
浏览文件 @
7fb81c8e
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
char
*
ThisFunctionHasNotBeenTested
(
int
Poor
,
char
*
LittleFunction
)
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.
//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
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
return
(
char
*
)
0
;
return
(
char
*
)
0
;
...
...
examples/example_3/test/no_ruby/TestProductionCode2_Runner.c
浏览文件 @
7fb81c8e
...
@@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
...
@@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
extern
void
test_AnotherIgnoredTest
(
void
);
extern
void
test_AnotherIgnoredTest
(
void
);
extern
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
);
extern
void
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
(
void
);
static
void
runTest
(
UnityTestFunction
test
)
{
if
(
TEST_PROTECT
())
{
setUp
();
test
();
}
if
(
TEST_PROTECT
()
&&
!
TEST_IS_IGNORED
)
{
tearDown
();
}
}
void
resetTest
(
void
);
void
resetTest
(
void
);
void
resetTest
(
void
)
void
resetTest
(
void
)
{
{
...
@@ -36,7 +24,6 @@ int main(void)
...
@@ -36,7 +24,6 @@ int main(void)
{
{
UnityBegin
(
"test/TestProductionCode2.c"
);
UnityBegin
(
"test/TestProductionCode2.c"
);
// RUN_TEST calls runTest
RUN_TEST
(
test_IgnoredTest
,
13
);
RUN_TEST
(
test_IgnoredTest
,
13
);
RUN_TEST
(
test_AnotherIgnoredTest
,
18
);
RUN_TEST
(
test_AnotherIgnoredTest
,
18
);
RUN_TEST
(
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
,
23
);
RUN_TEST
(
test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented
,
23
);
...
...
examples/example_3/test/no_ruby/TestProductionCode_Runner.c
浏览文件 @
7fb81c8e
...
@@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
...
@@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
);
extern
void
test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed
(
void
);
static
void
runTest
(
UnityTestFunction
test
)
{
if
(
TEST_PROTECT
())
{
setUp
();
test
();
}
if
(
TEST_PROTECT
()
&&
!
TEST_IS_IGNORED
)
{
tearDown
();
}
}
void
resetTest
(
void
);
void
resetTest
(
void
);
void
resetTest
(
void
)
void
resetTest
(
void
)
{
{
...
@@ -38,7 +26,6 @@ int main(void)
...
@@ -38,7 +26,6 @@ int main(void)
{
{
UnityBegin
(
"test/TestProductionCode.c"
);
UnityBegin
(
"test/TestProductionCode.c"
);
// RUN_TEST calls runTest
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
,
20
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode
,
20
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken
,
30
);
RUN_TEST
(
test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken
,
30
);
RUN_TEST
(
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue
,
41
);
RUN_TEST
(
test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue
,
41
);
...
...
extras/fixture/rakefile.rb
浏览文件 @
7fb81c8e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# Unity Project - A Test Framework for C
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
# ==========================================
HERE
=
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
+
'/'
HERE
=
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
+
'/'
...
@@ -11,13 +11,24 @@ require 'rake/clean'
...
@@ -11,13 +11,24 @@ require 'rake/clean'
require
'rake/testtask'
require
'rake/testtask'
require
HERE
+
'rakefile_helper'
require
HERE
+
'rakefile_helper'
TEMP_DIRS
=
[
File
.
join
(
HERE
,
'build'
)
]
TEMP_DIRS
.
each
do
|
dir
|
directory
(
dir
)
CLOBBER
.
include
(
dir
)
end
task
:prepare_for_tests
=>
TEMP_DIRS
include
RakefileHelpers
include
RakefileHelpers
# Load default configuration, for now
# Load default configuration, for now
DEFAULT_CONFIG_FILE
=
'gcc_
32
.yml'
DEFAULT_CONFIG_FILE
=
'gcc_
auto_stdint
.yml'
configure_toolchain
(
DEFAULT_CONFIG_FILE
)
configure_toolchain
(
DEFAULT_CONFIG_FILE
)
task
:unit
do
task
:unit
=>
[
:prepare_for_tests
]
do
run_tests
run_tests
end
end
...
...
extras/fixture/src/unity_fixture.c
浏览文件 @
7fb81c8e
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
========================================== */
========================================== */
#include <string.h>
#include <string.h>
#include <stdio.h>
#include "unity_fixture.h"
#include "unity_fixture.h"
#include "unity_internals.h"
#include "unity_internals.h"
...
@@ -16,10 +17,12 @@ int (*outputChar)(int) = putchar;
...
@@ -16,10 +17,12 @@ int (*outputChar)(int) = putchar;
int
verbose
=
0
;
int
verbose
=
0
;
void
setUp
(
void
);
void
tearDown
(
void
);
void
setUp
(
void
)
{
/*does nothing*/
}
void
setUp
(
void
)
{
/*does nothing*/
}
void
tearDown
(
void
)
{
/*does nothing*/
}
void
tearDown
(
void
)
{
/*does nothing*/
}
void
announceTestRun
(
unsigned
int
runNumber
)
static
void
announceTestRun
(
unsigned
int
runNumber
)
{
{
UnityPrint
(
"Unity test run "
);
UnityPrint
(
"Unity test run "
);
UnityPrintNumber
(
runNumber
+
1
);
UnityPrintNumber
(
runNumber
+
1
);
...
@@ -28,7 +31,7 @@ void announceTestRun(unsigned int runNumber)
...
@@ -28,7 +31,7 @@ void announceTestRun(unsigned int runNumber)
UNITY_OUTPUT_CHAR
(
'\n'
);
UNITY_OUTPUT_CHAR
(
'\n'
);
}
}
int
UnityMain
(
int
argc
,
char
*
argv
[],
void
(
*
runAllTests
)(
void
))
int
UnityMain
(
int
argc
,
c
onst
c
har
*
argv
[],
void
(
*
runAllTests
)(
void
))
{
{
int
result
=
UnityGetCommandLineOptions
(
argc
,
argv
);
int
result
=
UnityGetCommandLineOptions
(
argc
,
argv
);
unsigned
int
r
;
unsigned
int
r
;
...
@@ -37,8 +40,8 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void))
...
@@ -37,8 +40,8 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void))
for
(
r
=
0
;
r
<
UnityFixture
.
RepeatCount
;
r
++
)
for
(
r
=
0
;
r
<
UnityFixture
.
RepeatCount
;
r
++
)
{
{
announceTestRun
(
r
);
UnityBegin
(
argv
[
0
]);
UnityBegin
(
argv
[
0
]);
announceTestRun
(
r
);
runAllTests
();
runAllTests
();
UNITY_OUTPUT_CHAR
(
'\n'
);
UNITY_OUTPUT_CHAR
(
'\n'
);
UnityEnd
();
UnityEnd
();
...
@@ -64,7 +67,7 @@ static int groupSelected(const char* group)
...
@@ -64,7 +67,7 @@ static int groupSelected(const char* group)
return
selected
(
UnityFixture
.
GroupFilter
,
group
);
return
selected
(
UnityFixture
.
GroupFilter
,
group
);
}
}
static
void
runTestCase
()
static
void
runTestCase
(
void
)
{
{
}
}
...
@@ -131,13 +134,13 @@ void UnityIgnoreTest(const char * printableName)
...
@@ -131,13 +134,13 @@ void UnityIgnoreTest(const char * printableName)
static
int
malloc_count
;
static
int
malloc_count
;
static
int
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
static
int
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
void
UnityMalloc_StartTest
()
void
UnityMalloc_StartTest
(
void
)
{
{
malloc_count
=
0
;
malloc_count
=
0
;
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
}
}
void
UnityMalloc_EndTest
()
void
UnityMalloc_EndTest
(
void
)
{
{
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
if
(
malloc_count
!=
0
)
if
(
malloc_count
!=
0
)
...
@@ -159,6 +162,14 @@ void UnityMalloc_MakeMallocFailAfterCount(int countdown)
...
@@ -159,6 +162,14 @@ void UnityMalloc_MakeMallocFailAfterCount(int countdown)
#undef free
#undef free
#endif
#endif
#ifdef calloc
#undef calloc
#endif
#ifdef realloc
#undef realloc
#endif
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
...
@@ -273,7 +284,7 @@ enum {MAX_POINTERS=50};
...
@@ -273,7 +284,7 @@ enum {MAX_POINTERS=50};
static
PointerPair
pointer_store
[
MAX_POINTERS
];
static
PointerPair
pointer_store
[
MAX_POINTERS
];
static
int
pointer_index
=
0
;
static
int
pointer_index
=
0
;
void
UnityPointer_Init
()
void
UnityPointer_Init
(
void
)
{
{
pointer_index
=
0
;
pointer_index
=
0
;
}
}
...
@@ -289,7 +300,7 @@ void UnityPointer_Set(void ** pointer, void * newValue)
...
@@ -289,7 +300,7 @@ void UnityPointer_Set(void ** pointer, void * newValue)
pointer_index
++
;
pointer_index
++
;
}
}
void
UnityPointer_UndoAllSets
()
void
UnityPointer_UndoAllSets
(
void
)
{
{
while
(
pointer_index
>
0
)
while
(
pointer_index
>
0
)
{
{
...
@@ -300,12 +311,12 @@ void UnityPointer_UndoAllSets()
...
@@ -300,12 +311,12 @@ void UnityPointer_UndoAllSets()
}
}
}
}
int
UnityFailureCount
()
int
UnityFailureCount
(
void
)
{
{
return
Unity
.
TestFailures
;
return
Unity
.
TestFailures
;
}
}
int
UnityGetCommandLineOptions
(
int
argc
,
char
*
argv
[])
int
UnityGetCommandLineOptions
(
int
argc
,
c
onst
c
har
*
argv
[])
{
{
int
i
;
int
i
;
UnityFixture
.
Verbose
=
0
;
UnityFixture
.
Verbose
=
0
;
...
@@ -359,7 +370,7 @@ int UnityGetCommandLineOptions(int argc, char* argv[])
...
@@ -359,7 +370,7 @@ int UnityGetCommandLineOptions(int argc, char* argv[])
return
0
;
return
0
;
}
}
void
UnityConcludeFixtureTest
()
void
UnityConcludeFixtureTest
(
void
)
{
{
if
(
Unity
.
CurrentTestIgnored
)
if
(
Unity
.
CurrentTestIgnored
)
{
{
...
...
extras/fixture/src/unity_fixture.h
浏览文件 @
7fb81c8e
...
@@ -13,19 +13,22 @@
...
@@ -13,19 +13,22 @@
#include "unity_fixture_malloc_overrides.h"
#include "unity_fixture_malloc_overrides.h"
#include "unity_fixture_internals.h"
#include "unity_fixture_internals.h"
int
UnityMain
(
int
argc
,
char
*
argv
[],
void
(
*
runAllTests
)(
void
));
int
UnityMain
(
int
argc
,
c
onst
c
har
*
argv
[],
void
(
*
runAllTests
)(
void
));
#define TEST_GROUP(group)\
#define TEST_GROUP(group)\
static const char* TEST_GROUP_##group = #group
static const char* TEST_GROUP_##group = #group
#define TEST_SETUP(group) void TEST_##group##_SETUP(void)
#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\
void TEST_##group##_SETUP(void)
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void)
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\
void TEST_##group##_TEAR_DOWN(void)
#define TEST(group, name) \
#define TEST(group, name) \
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_run(void);\
void TEST_##group##_##name##_run(void)\
void TEST_##group##_##name##_run(void)\
{\
{\
UnityTestRunner(TEST_##group##_SETUP,\
UnityTestRunner(TEST_##group##_SETUP,\
...
@@ -39,6 +42,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
...
@@ -39,6 +42,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
#define IGNORE_TEST(group, name) \
#define IGNORE_TEST(group, name) \
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_run(void);\
void TEST_##group##_##name##_run(void)\
void TEST_##group##_##name##_run(void)\
{\
{\
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\
...
@@ -60,7 +64,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
...
@@ -60,7 +64,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
{\
{\
TEST_##group##_GROUP_RUNNER_runAll();\
TEST_##group##_GROUP_RUNNER_runAll();\
}\
}\
void TEST_##group##_GROUP_RUNNER_runAll()
void TEST_##group##_GROUP_RUNNER_runAll(
void
)
//Call this from main
//Call this from main
#define RUN_TEST_GROUP(group)\
#define RUN_TEST_GROUP(group)\
...
...
extras/fixture/src/unity_fixture_internals.h
浏览文件 @
7fb81c8e
...
@@ -29,7 +29,7 @@ void UnityIgnoreTest(const char * printableName);
...
@@ -29,7 +29,7 @@ void UnityIgnoreTest(const char * printableName);
void
UnityMalloc_StartTest
(
void
);
void
UnityMalloc_StartTest
(
void
);
void
UnityMalloc_EndTest
(
void
);
void
UnityMalloc_EndTest
(
void
);
int
UnityFailureCount
(
void
);
int
UnityFailureCount
(
void
);
int
UnityGetCommandLineOptions
(
int
argc
,
char
*
argv
[]);
int
UnityGetCommandLineOptions
(
int
argc
,
c
onst
c
har
*
argv
[]);
void
UnityConcludeFixtureTest
(
void
);
void
UnityConcludeFixtureTest
(
void
);
void
UnityPointer_Set
(
void
**
ptr
,
void
*
newValue
);
void
UnityPointer_Set
(
void
**
ptr
,
void
*
newValue
);
...
...
extras/fixture/src/unity_fixture_malloc_overrides.h
浏览文件 @
7fb81c8e
...
@@ -13,4 +13,9 @@
...
@@ -13,4 +13,9 @@
#define realloc unity_realloc
#define realloc unity_realloc
#define free unity_free
#define free unity_free
void
*
unity_malloc
(
size_t
size
);
void
*
unity_calloc
(
size_t
num
,
size_t
size
);
void
*
unity_realloc
(
void
*
oldMem
,
size_t
size
);
void
unity_free
(
void
*
mem
);
#endif
/* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */
#endif
/* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */
extras/fixture/test/main/AllTests.c
浏览文件 @
7fb81c8e
...
@@ -7,14 +7,14 @@
...
@@ -7,14 +7,14 @@
#include "unity_fixture.h"
#include "unity_fixture.h"
static
void
runAllTests
()
static
void
runAllTests
(
void
)
{
{
RUN_TEST_GROUP
(
UnityFixture
);
RUN_TEST_GROUP
(
UnityFixture
);
RUN_TEST_GROUP
(
UnityCommandOptions
);
RUN_TEST_GROUP
(
UnityCommandOptions
);
RUN_TEST_GROUP
(
LeakDetection
)
RUN_TEST_GROUP
(
LeakDetection
)
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
c
onst
c
har
*
argv
[])
{
{
return
UnityMain
(
argc
,
argv
,
runAllTests
);
return
UnityMain
(
argc
,
argv
,
runAllTests
);
}
}
...
...
extras/fixture/test/unity_fixture_Test.c
浏览文件 @
7fb81c8e
...
@@ -122,7 +122,7 @@ TEST(UnityFixture, PointerSet)
...
@@ -122,7 +122,7 @@ TEST(UnityFixture, PointerSet)
p1
=
&
c1
;
p1
=
&
c1
;
p2
=
&
c2
;
p2
=
&
c2
;
UnityPointer_Init
(
10
);
UnityPointer_Init
();
UT_PTR_SET
(
p1
,
&
newC1
);
UT_PTR_SET
(
p1
,
&
newC1
);
UT_PTR_SET
(
p2
,
&
newC2
);
UT_PTR_SET
(
p2
,
&
newC2
);
TEST_ASSERT_POINTERS_EQUAL
(
&
newC1
,
p1
);
TEST_ASSERT_POINTERS_EQUAL
(
&
newC1
,
p1
);
...
@@ -158,7 +158,7 @@ TEST_TEAR_DOWN(UnityCommandOptions)
...
@@ -158,7 +158,7 @@ TEST_TEAR_DOWN(UnityCommandOptions)
}
}
static
char
*
noOptions
[]
=
{
static
c
onst
c
har
*
noOptions
[]
=
{
"testrunner.exe"
"testrunner.exe"
};
};
...
@@ -171,7 +171,7 @@ TEST(UnityCommandOptions, DefaultOptions)
...
@@ -171,7 +171,7 @@ TEST(UnityCommandOptions, DefaultOptions)
TEST_ASSERT_EQUAL
(
1
,
UnityFixture
.
RepeatCount
);
TEST_ASSERT_EQUAL
(
1
,
UnityFixture
.
RepeatCount
);
}
}
static
char
*
verbose
[]
=
{
static
c
onst
c
har
*
verbose
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-v"
"-v"
};
};
...
@@ -182,7 +182,7 @@ TEST(UnityCommandOptions, OptionVerbose)
...
@@ -182,7 +182,7 @@ TEST(UnityCommandOptions, OptionVerbose)
TEST_ASSERT_EQUAL
(
1
,
UnityFixture
.
Verbose
);
TEST_ASSERT_EQUAL
(
1
,
UnityFixture
.
Verbose
);
}
}
static
char
*
group
[]
=
{
static
c
onst
c
har
*
group
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-g"
,
"groupname"
"-g"
,
"groupname"
};
};
...
@@ -193,7 +193,7 @@ TEST(UnityCommandOptions, OptionSelectTestByGroup)
...
@@ -193,7 +193,7 @@ TEST(UnityCommandOptions, OptionSelectTestByGroup)
STRCMP_EQUAL
(
"groupname"
,
UnityFixture
.
GroupFilter
);
STRCMP_EQUAL
(
"groupname"
,
UnityFixture
.
GroupFilter
);
}
}
static
char
*
name
[]
=
{
static
c
onst
c
har
*
name
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-n"
,
"testname"
"-n"
,
"testname"
};
};
...
@@ -204,7 +204,7 @@ TEST(UnityCommandOptions, OptionSelectTestByName)
...
@@ -204,7 +204,7 @@ TEST(UnityCommandOptions, OptionSelectTestByName)
STRCMP_EQUAL
(
"testname"
,
UnityFixture
.
NameFilter
);
STRCMP_EQUAL
(
"testname"
,
UnityFixture
.
NameFilter
);
}
}
static
char
*
repeat
[]
=
{
static
c
onst
c
har
*
repeat
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-r"
,
"99"
"-r"
,
"99"
};
};
...
@@ -221,7 +221,7 @@ TEST(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount)
...
@@ -221,7 +221,7 @@ TEST(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount)
TEST_ASSERT_EQUAL
(
99
,
UnityFixture
.
RepeatCount
);
TEST_ASSERT_EQUAL
(
99
,
UnityFixture
.
RepeatCount
);
}
}
static
char
*
multiple
[]
=
{
static
c
onst
c
har
*
multiple
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-v"
,
"-v"
,
"-g"
,
"groupname"
,
"-g"
,
"groupname"
,
...
@@ -238,7 +238,7 @@ TEST(UnityCommandOptions, MultipleOptions)
...
@@ -238,7 +238,7 @@ TEST(UnityCommandOptions, MultipleOptions)
TEST_ASSERT_EQUAL
(
98
,
UnityFixture
.
RepeatCount
);
TEST_ASSERT_EQUAL
(
98
,
UnityFixture
.
RepeatCount
);
}
}
static
char
*
dashRNotLast
[]
=
{
static
c
onst
c
har
*
dashRNotLast
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-v"
,
"-v"
,
"-g"
,
"gggg"
,
"-g"
,
"gggg"
,
...
@@ -255,7 +255,7 @@ TEST(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified)
...
@@ -255,7 +255,7 @@ TEST(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified)
TEST_ASSERT_EQUAL
(
2
,
UnityFixture
.
RepeatCount
);
TEST_ASSERT_EQUAL
(
2
,
UnityFixture
.
RepeatCount
);
}
}
static
char
*
unknownCommand
[]
=
{
static
c
onst
c
har
*
unknownCommand
[]
=
{
"testrunner.exe"
,
"testrunner.exe"
,
"-v"
,
"-v"
,
"-g"
,
"groupname"
,
"-g"
,
"groupname"
,
...
...
extras/fixture/test/unity_output_Spy.c
浏览文件 @
7fb81c8e
...
@@ -25,7 +25,7 @@ void UnityOutputCharSpy_Create(int s)
...
@@ -25,7 +25,7 @@ void UnityOutputCharSpy_Create(int s)
memset
(
buffer
,
0
,
size
);
memset
(
buffer
,
0
,
size
);
}
}
void
UnityOutputCharSpy_Destroy
()
void
UnityOutputCharSpy_Destroy
(
void
)
{
{
size
=
0
;
size
=
0
;
free
(
buffer
);
free
(
buffer
);
...
@@ -45,7 +45,7 @@ int UnityOutputCharSpy_OutputChar(int c)
...
@@ -45,7 +45,7 @@ int UnityOutputCharSpy_OutputChar(int c)
return
c
;
return
c
;
}
}
const
char
*
UnityOutputCharSpy_Get
()
const
char
*
UnityOutputCharSpy_Get
(
void
)
{
{
return
buffer
;
return
buffer
;
}
}
...
...
extras/fixture/test/unity_output_Spy.h
浏览文件 @
7fb81c8e
...
@@ -9,9 +9,9 @@
...
@@ -9,9 +9,9 @@
#define D_unity_output_Spy_H
#define D_unity_output_Spy_H
void
UnityOutputCharSpy_Create
(
int
s
);
void
UnityOutputCharSpy_Create
(
int
s
);
void
UnityOutputCharSpy_Destroy
();
void
UnityOutputCharSpy_Destroy
(
void
);
int
UnityOutputCharSpy_OutputChar
(
int
c
);
int
UnityOutputCharSpy_OutputChar
(
int
c
);
const
char
*
UnityOutputCharSpy_Get
();
const
char
*
UnityOutputCharSpy_Get
(
void
);
void
UnityOutputCharSpy_Enable
(
int
enable
);
void
UnityOutputCharSpy_Enable
(
int
enable
);
#endif
#endif
src/unity.c
浏览文件 @
7fb81c8e
...
@@ -271,9 +271,8 @@ void UnityPrintOk(void)
...
@@ -271,9 +271,8 @@ void UnityPrintOk(void)
}
}
//-----------------------------------------------
//-----------------------------------------------
void
UnityTestResultsBegin
(
const
char
*
file
,
const
UNITY_LINE_TYPE
line
)
static
void
UnityTestResultsBegin
(
const
char
*
file
,
const
UNITY_LINE_TYPE
line
)
{
{
UNITY_PRINT_EOL
;
UnityPrint
(
file
);
UnityPrint
(
file
);
UNITY_OUTPUT_CHAR
(
':'
);
UNITY_OUTPUT_CHAR
(
':'
);
UnityPrintNumber
((
_U_SINT
)
line
);
UnityPrintNumber
((
_U_SINT
)
line
);
...
@@ -283,7 +282,7 @@ void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
...
@@ -283,7 +282,7 @@ void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
}
}
//-----------------------------------------------
//-----------------------------------------------
void
UnityTestResultsFailBegin
(
const
UNITY_LINE_TYPE
line
)
static
void
UnityTestResultsFailBegin
(
const
UNITY_LINE_TYPE
line
)
{
{
UnityTestResultsBegin
(
Unity
.
TestFile
,
line
);
UnityTestResultsBegin
(
Unity
.
TestFile
,
line
);
UnityPrint
(
UnityStrFail
);
UnityPrint
(
UnityStrFail
);
...
@@ -309,10 +308,11 @@ void UnityConcludeTest(void)
...
@@ -309,10 +308,11 @@ void UnityConcludeTest(void)
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
UNITY_PRINT_EOL
;
}
}
//-----------------------------------------------
//-----------------------------------------------
void
UnityAddMsgIfSpecified
(
const
char
*
msg
)
static
void
UnityAddMsgIfSpecified
(
const
char
*
msg
)
{
{
if
(
msg
)
if
(
msg
)
{
{
...
@@ -322,7 +322,7 @@ void UnityAddMsgIfSpecified(const char* msg)
...
@@ -322,7 +322,7 @@ void UnityAddMsgIfSpecified(const char* msg)
}
}
//-----------------------------------------------
//-----------------------------------------------
void
UnityPrintExpectedAndActualStrings
(
const
char
*
expected
,
const
char
*
actual
)
static
void
UnityPrintExpectedAndActualStrings
(
const
char
*
expected
,
const
char
*
actual
)
{
{
UnityPrint
(
UnityStrExpected
);
UnityPrint
(
UnityStrExpected
);
if
(
expected
!=
NULL
)
if
(
expected
!=
NULL
)
...
@@ -352,7 +352,7 @@ void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual
...
@@ -352,7 +352,7 @@ void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual
// Assertion & Control Helpers
// Assertion & Control Helpers
//-----------------------------------------------
//-----------------------------------------------
int
UnityCheckArraysForNull
(
UNITY_PTR_ATTRIBUTE
const
void
*
expected
,
UNITY_PTR_ATTRIBUTE
const
void
*
actual
,
const
UNITY_LINE_TYPE
lineNumber
,
const
char
*
msg
)
static
int
UnityCheckArraysForNull
(
UNITY_PTR_ATTRIBUTE
const
void
*
expected
,
UNITY_PTR_ATTRIBUTE
const
void
*
actual
,
const
UNITY_LINE_TYPE
lineNumber
,
const
char
*
msg
)
{
{
//return true if they are both NULL
//return true if they are both NULL
if
((
expected
==
NULL
)
&&
(
actual
==
NULL
))
if
((
expected
==
NULL
)
&&
(
actual
==
NULL
))
...
@@ -643,13 +643,13 @@ void UnityAssertFloatSpecial(const _UF actual,
...
@@ -643,13 +643,13 @@ void UnityAssertFloatSpecial(const _UF actual,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLOAT_TRAIT_T
style
)
const
UNITY_FLOAT_TRAIT_T
style
)
{
{
UNITY_SKIP_EXECUTION
;
const
char
*
trait_names
[]
=
{
UnityStrInf
,
UnityStrNegInf
,
UnityStrNaN
,
UnityStrDet
};
const
char
*
trait_names
[]
=
{
UnityStrInf
,
UnityStrNegInf
,
UnityStrNaN
,
UnityStrDet
};
_U_SINT
should_be_trait
=
((
_U_SINT
)
style
&
1
);
_U_SINT
should_be_trait
=
((
_U_SINT
)
style
&
1
);
_U_SINT
is_trait
=
!
should_be_trait
;
_U_SINT
is_trait
=
!
should_be_trait
;
_U_SINT
trait_index
=
style
>>
1
;
_U_SINT
trait_index
=
style
>>
1
;
UNITY_SKIP_EXECUTION
;
switch
(
style
)
switch
(
style
)
{
{
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
...
@@ -677,6 +677,8 @@ void UnityAssertFloatSpecial(const _UF actual,
...
@@ -677,6 +677,8 @@ void UnityAssertFloatSpecial(const _UF actual,
else
else
is_trait
=
1
;
is_trait
=
1
;
break
;
break
;
default:
;
}
}
if
(
is_trait
!=
should_be_trait
)
if
(
is_trait
!=
should_be_trait
)
...
@@ -803,13 +805,13 @@ void UnityAssertDoubleSpecial(const _UD actual,
...
@@ -803,13 +805,13 @@ void UnityAssertDoubleSpecial(const _UD actual,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_LINE_TYPE
lineNumber
,
const
UNITY_FLOAT_TRAIT_T
style
)
const
UNITY_FLOAT_TRAIT_T
style
)
{
{
UNITY_SKIP_EXECUTION
;
const
char
*
trait_names
[]
=
{
UnityStrInf
,
UnityStrNegInf
,
UnityStrNaN
,
UnityStrDet
};
const
char
*
trait_names
[]
=
{
UnityStrInf
,
UnityStrNegInf
,
UnityStrNaN
,
UnityStrDet
};
_U_SINT
should_be_trait
=
((
_U_SINT
)
style
&
1
);
_U_SINT
should_be_trait
=
((
_U_SINT
)
style
&
1
);
_U_SINT
is_trait
=
!
should_be_trait
;
_U_SINT
is_trait
=
!
should_be_trait
;
_U_SINT
trait_index
=
style
>>
1
;
_U_SINT
trait_index
=
style
>>
1
;
UNITY_SKIP_EXECUTION
;
switch
(
style
)
switch
(
style
)
{
{
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
...
@@ -837,6 +839,8 @@ void UnityAssertDoubleSpecial(const _UD actual,
...
@@ -837,6 +839,8 @@ void UnityAssertDoubleSpecial(const _UD actual,
else
else
is_trait
=
1
;
is_trait
=
1
;
break
;
break
;
default:
;
}
}
if
(
is_trait
!=
should_be_trait
)
if
(
is_trait
!=
should_be_trait
)
...
@@ -1097,12 +1101,19 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
...
@@ -1097,12 +1101,19 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
}
}
//-----------------------------------------------
//-----------------------------------------------
#ifdef UNITY_SUPPORT_WEAK
#if defined(UNITY_WEAK_ATTRIBUTE)
UNITY_WEAK
void
setUp
(
void
)
{
}
void
setUp
(
void
);
UNITY_WEAK
void
tearDown
(
void
)
{
}
void
tearDown
(
void
);
UNITY_WEAK_ATTRIBUTE
void
setUp
(
void
)
{
}
UNITY_WEAK_ATTRIBUTE
void
tearDown
(
void
)
{
}
#elif defined(UNITY_WEAK_PRAGMA)
# pragma weak setUp
void
setUp
(
void
);
# pragma weak tearDown
void
tearDown
(
void
);
#else
#else
void
setUp
(
void
);
void
setUp
(
void
);
void
tearDown
(
void
);
void
tearDown
(
void
);
#endif
#endif
//-----------------------------------------------
//-----------------------------------------------
void
UnityDefaultTestRun
(
UnityTestFunction
Func
,
const
char
*
FuncName
,
const
int
FuncLineNum
)
void
UnityDefaultTestRun
(
UnityTestFunction
Func
,
const
char
*
FuncName
,
const
int
FuncLineNum
)
...
@@ -1164,5 +1175,3 @@ int UnityEnd(void)
...
@@ -1164,5 +1175,3 @@ int UnityEnd(void)
}
}
//-----------------------------------------------
//-----------------------------------------------
src/unity_internals.h
浏览文件 @
7fb81c8e
...
@@ -292,22 +292,19 @@ extern int UNITY_OUTPUT_CHAR(int);
...
@@ -292,22 +292,19 @@ extern int UNITY_OUTPUT_CHAR(int);
//-------------------------------------------------------
//-------------------------------------------------------
// Language Features Available
// Language Features Available
//-------------------------------------------------------
//-------------------------------------------------------
#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
#ifdef __GNUC__
# ifdef __GNUC__ // includes clang
#define UNITY_SUPPORT_WEAK __attribute__((weak))
# if !(defined(__WIN32__) && defined(__clang__))
# define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
# endif
# endif
#endif
#endif
#ifdef __clang__
#ifdef UNITY_NO_WEAK
#define UNITY_SUPPORT_WEAK __attribute__((weak))
# undef UNITY_WEAK_ATTRIBUTE
# undef UNITY_WEAK_PRAGMA
#endif
#endif
#ifndef UNITY_WEAK
#ifdef UNITY_SUPPORT_WEAK
#define UNITY_WEAK UNITY_SUPPORT_WEAK
#else
#define UNITY_WEAK
#endif
#endif
//-------------------------------------------------------
//-------------------------------------------------------
// Internal Structs Needed
// Internal Structs Needed
...
...
test/targets/gcc_auto_stdint.yml
浏览文件 @
7fb81c8e
...
@@ -10,6 +10,22 @@ compiler:
...
@@ -10,6 +10,22 @@ compiler:
-
'
-Wno-address'
-
'
-Wno-address'
-
'
-std=c99'
-
'
-std=c99'
-
'
-pedantic'
-
'
-pedantic'
-
'
-Wextra'
-
'
-Werror'
-
'
-Wpointer-arith'
-
'
-Wcast-align'
-
'
-Wwrite-strings'
-
'
-Wswitch-default'
-
'
-Wunreachable-code'
-
'
-Winit-self'
-
'
-Wlogical-op'
-
'
-Wmissing-field-initializers'
-
'
-Wno-unknown-pragmas'
-
'
-Wjump-misses-init'
-
'
-Wstrict-prototypes'
-
'
-Wundef'
-
'
-Wunsafe-loop-optimizations'
-
'
-Wold-style-definition'
includes
:
includes
:
prefix
:
'
-I'
prefix
:
'
-I'
items
:
items
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录