Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
de7627f0
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看板
提交
de7627f0
编写于
8月 31, 2016
作者:
M
Mark VanderVoord
提交者:
GitHub
8月 31, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #212 from jsalling/feature/C89-comments
Fixture C89 comments
上级
a74920d1
da7e375c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
109 addition
and
108 deletion
+109
-108
.travis.yml
.travis.yml
+1
-0
extras/fixture/src/unity_fixture.c
extras/fixture/src/unity_fixture.c
+21
-22
extras/fixture/src/unity_fixture.h
extras/fixture/src/unity_fixture.h
+9
-9
extras/fixture/src/unity_fixture_internals.h
extras/fixture/src/unity_fixture_internals.h
+6
-6
extras/fixture/src/unity_fixture_malloc_overrides.h
extras/fixture/src/unity_fixture_malloc_overrides.h
+15
-15
extras/fixture/test/Makefile
extras/fixture/test/Makefile
+5
-4
extras/fixture/test/main/AllTests.c
extras/fixture/test/main/AllTests.c
+6
-6
extras/fixture/test/template_fixture_tests.c
extras/fixture/test/template_fixture_tests.c
+6
-6
extras/fixture/test/unity_fixture_Test.c
extras/fixture/test/unity_fixture_Test.c
+22
-22
extras/fixture/test/unity_fixture_TestRunner.c
extras/fixture/test/unity_fixture_TestRunner.c
+6
-6
extras/fixture/test/unity_output_Spy.c
extras/fixture/test/unity_output_Spy.c
+6
-6
extras/fixture/test/unity_output_Spy.h
extras/fixture/test/unity_output_Spy.h
+6
-6
未找到文件。
.travis.yml
浏览文件 @
de7627f0
...
@@ -7,3 +7,4 @@ script:
...
@@ -7,3 +7,4 @@ script:
-
make -s
-
make -s
-
cd ../extras/fixture/test && rake ci
-
cd ../extras/fixture/test && rake ci
-
make -s default noStdlibMalloc
-
make -s default noStdlibMalloc
-
make -s C89
extras/fixture/src/unity_fixture.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include <string.h>
#include <string.h>
#include "unity_fixture.h"
#include "unity_fixture.h"
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
struct
_UnityFixture
UnityFixture
;
struct
_UnityFixture
UnityFixture
;
/
/
If you decide to use the function pointer approach.
/
*
If you decide to use the function pointer approach.
//
Build with -D UNITY_OUTPUT_CHAR=outputChar and include <stdio.h>
*
Build with -D UNITY_OUTPUT_CHAR=outputChar and include <stdio.h>
//int (*outputChar)(int) = putchar;
* int (*outputChar)(int) = putchar; */
#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
void
setUp
(
void
)
{
/*does nothing*/
}
void
setUp
(
void
)
{
/*does nothing*/
}
...
@@ -123,9 +123,8 @@ void UnityIgnoreTest(const char* printableName, const char* group, const char* n
...
@@ -123,9 +123,8 @@ void UnityIgnoreTest(const char* printableName, const char* group, const char* n
}
}
//-------------------------------------------------
/*------------------------------------------------- */
//Malloc and free stuff
/* Malloc and free stuff */
//
#define MALLOC_DONT_FAIL -1
#define MALLOC_DONT_FAIL -1
static
int
malloc_count
;
static
int
malloc_count
;
static
int
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
static
int
malloc_fail_countdown
=
MALLOC_DONT_FAIL
;
...
@@ -150,8 +149,8 @@ void UnityMalloc_MakeMallocFailAfterCount(int countdown)
...
@@ -150,8 +149,8 @@ void UnityMalloc_MakeMallocFailAfterCount(int countdown)
malloc_fail_countdown
=
countdown
;
malloc_fail_countdown
=
countdown
;
}
}
/
/ These definitions are always included from unity_fixture_malloc_overrides.h
/
* These definitions are always included from unity_fixture_malloc_overrides.h */
/
/ We undef to use them or avoid conflict with <stdlib.h> per the C standard
/
* We undef to use them or avoid conflict with <stdlib.h> per the C standard */
#undef malloc
#undef malloc
#undef free
#undef free
#undef calloc
#undef calloc
...
@@ -282,24 +281,24 @@ void* unity_realloc(void* oldMem, size_t size)
...
@@ -282,24 +281,24 @@ void* unity_realloc(void* oldMem, size_t size)
if
(
guard
->
size
>=
size
)
return
oldMem
;
if
(
guard
->
size
>=
size
)
return
oldMem
;
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC /
/ Optimization if memory is expandable
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
/
* Optimization if memory is expandable */
if
(
oldMem
==
unity_heap
+
heap_index
-
guard
->
size
-
sizeof
(
end
)
&&
if
(
oldMem
==
unity_heap
+
heap_index
-
guard
->
size
-
sizeof
(
end
)
&&
heap_index
+
size
-
guard
->
size
<=
UNITY_INTERNAL_HEAP_SIZE_BYTES
)
heap_index
+
size
-
guard
->
size
<=
UNITY_INTERNAL_HEAP_SIZE_BYTES
)
{
{
release_memory
(
oldMem
);
/
/ Not thread-safe, like unity_heap generally
release_memory
(
oldMem
);
/
* Not thread-safe, like unity_heap generally */
return
unity_malloc
(
size
);
/
/ No memcpy since data is in place
return
unity_malloc
(
size
);
/
* No memcpy since data is in place */
}
}
#endif
#endif
newMem
=
unity_malloc
(
size
);
newMem
=
unity_malloc
(
size
);
if
(
newMem
==
NULL
)
return
NULL
;
/
/ Do not release old memory
if
(
newMem
==
NULL
)
return
NULL
;
/
* Do not release old memory */
memcpy
(
newMem
,
oldMem
,
guard
->
size
);
memcpy
(
newMem
,
oldMem
,
guard
->
size
);
release_memory
(
oldMem
);
release_memory
(
oldMem
);
return
newMem
;
return
newMem
;
}
}
/
/--------------------------------------------------------
/
*-------------------------------------------------------- */
/
/Automatic pointer restoration functions
/
*Automatic pointer restoration functions */
struct
PointerPair
struct
PointerPair
{
{
void
**
pointer
;
void
**
pointer
;
...
@@ -393,7 +392,7 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
...
@@ -393,7 +392,7 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
}
}
}
}
}
else
{
}
else
{
/
/ ignore unknown parameter
/
* ignore unknown parameter */
i
++
;
i
++
;
}
}
}
}
...
@@ -415,7 +414,7 @@ void UnityConcludeFixtureTest(void)
...
@@ -415,7 +414,7 @@ void UnityConcludeFixtureTest(void)
UNITY_PRINT_EOL
();
UNITY_PRINT_EOL
();
}
}
}
}
else
/
/ Unity.CurrentTestFailed
else
/
* Unity.CurrentTestFailed */
{
{
Unity
.
TestFailures
++
;
Unity
.
TestFailures
++
;
UNITY_PRINT_EOL
();
UNITY_PRINT_EOL
();
...
...
extras/fixture/src/unity_fixture.h
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#ifndef UNITY_FIXTURE_H_
#ifndef UNITY_FIXTURE_H_
#define UNITY_FIXTURE_H_
#define UNITY_FIXTURE_H_
...
@@ -53,17 +53,17 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
...
@@ -53,17 +53,17 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
{ void TEST_##group##_##name##_run(void);\
{ void TEST_##group##_##name##_run(void);\
TEST_##group##_##name##_run(); }
TEST_##group##_##name##_run(); }
/
/This goes at the bottom of each test file or in a separate c file
/
* This goes at the bottom of each test file or in a separate c file */
#define TEST_GROUP_RUNNER(group)\
#define TEST_GROUP_RUNNER(group)\
void TEST_##group##_GROUP_RUNNER(void);\
void TEST_##group##_GROUP_RUNNER(void);\
void TEST_##group##_GROUP_RUNNER(void)
void TEST_##group##_GROUP_RUNNER(void)
/
/Call this from main
/
* Call this from main */
#define RUN_TEST_GROUP(group)\
#define RUN_TEST_GROUP(group)\
{ void TEST_##group##_GROUP_RUNNER(void);\
{ void TEST_##group##_GROUP_RUNNER(void);\
TEST_##group##_GROUP_RUNNER(); }
TEST_##group##_GROUP_RUNNER(); }
/
/CppUTest Compatibility Macros
/
* CppUTest Compatibility Macros */
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__)
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual))
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual))
...
...
extras/fixture/src/unity_fixture_internals.h
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#ifndef UNITY_FIXTURE_INTERNALS_H_
#ifndef UNITY_FIXTURE_INTERNALS_H_
#define UNITY_FIXTURE_INTERNALS_H_
#define UNITY_FIXTURE_INTERNALS_H_
...
...
extras/fixture/src/unity_fixture_malloc_overrides.h
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_
#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_
...
@@ -11,20 +11,20 @@
...
@@ -11,20 +11,20 @@
#include <stddef.h>
#include <stddef.h>
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
/
/
Define this macro to remove the use of stdlib.h, malloc, and free.
/
*
Define this macro to remove the use of stdlib.h, malloc, and free.
//
Many embedded systems do not have a heap or malloc/free by default.
*
Many embedded systems do not have a heap or malloc/free by default.
//
This internal unity_malloc() provides allocated memory deterministically from
*
This internal unity_malloc() provides allocated memory deterministically from
//
the end of an array only, unity_free() only releases from end-of-array,
*
the end of an array only, unity_free() only releases from end-of-array,
// blocks are not coalesced, and memory not freed in LIFO order is stranded.
* blocks are not coalesced, and memory not freed in LIFO order is stranded. */
#ifndef UNITY_INTERNAL_HEAP_SIZE_BYTES
#ifndef UNITY_INTERNAL_HEAP_SIZE_BYTES
#define UNITY_INTERNAL_HEAP_SIZE_BYTES 256
#define UNITY_INTERNAL_HEAP_SIZE_BYTES 256
#endif
#endif
#endif
#endif
/
/
These functions are used by the Unity Fixture to allocate and release memory
/
*
These functions are used by the Unity Fixture to allocate and release memory
//
on the heap and can be overridden with platform-specific implementations.
*
on the heap and can be overridden with platform-specific implementations.
//
For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc()
*
For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc()
// and UNITY_FIXTURE_FREE becomes vPortFree().
* and UNITY_FIXTURE_FREE becomes vPortFree(). */
#if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE)
#if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE)
#define UNITY_FIXTURE_MALLOC(size) malloc(size)
#define UNITY_FIXTURE_MALLOC(size) malloc(size)
#define UNITY_FIXTURE_FREE(ptr) free(ptr)
#define UNITY_FIXTURE_FREE(ptr) free(ptr)
...
...
extras/fixture/test/Makefile
浏览文件 @
de7627f0
...
@@ -38,10 +38,11 @@ noStdlibMalloc: $(BUILD_DIR)
...
@@ -38,10 +38,11 @@ noStdlibMalloc: $(BUILD_DIR)
@
echo
"build with noStdlibMalloc"
@
echo
"build with noStdlibMalloc"
./
$(TARGET)
./
$(TARGET)
clang89
:
../build/
C89
:
CFLAGS += -D UNITY_EXCLUDE_STDINT_H
#
C89 did not have type 'long long'
,
<stdint.h>
clang
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-m32
-std
=
c89
-Wno-comment
C89
:
$(BUILD_DIR)
clang
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-m32
\
$(CC)
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-std
=
c89
&&
./
$(TARGET)
-D
UNITY_EXCLUDE_STDLIB_MALLOC
-std
=
c89
-Wno-comment
;
./
$(TARGET)
$(CC)
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-D
UNITY_EXCLUDE_STDLIB_MALLOC
-std
=
c89
./
$(TARGET)
clangEverything
:
clangEverything
:
clang
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-Weverything
clang
$(CFLAGS)
$(DEFINES)
$(SRC)
$(INC_DIR)
-o
$(TARGET)
-Weverything
...
...
extras/fixture/test/main/AllTests.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include "unity_fixture.h"
#include "unity_fixture.h"
...
...
extras/fixture/test/template_fixture_tests.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include "unity_fixture.h"
#include "unity_fixture.h"
...
...
extras/fixture/test/unity_fixture_Test.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include "unity_fixture.h"
#include "unity_fixture.h"
#include "unity_output_Spy.h"
#include "unity_output_Spy.h"
...
@@ -79,7 +79,7 @@ TEST(UnityFixture, ReallocLargerNeeded)
...
@@ -79,7 +79,7 @@ TEST(UnityFixture, ReallocLargerNeeded)
CHECK
(
m1
);
CHECK
(
m1
);
strcpy
((
char
*
)
m1
,
"123456789"
);
strcpy
((
char
*
)
m1
,
"123456789"
);
m2
=
realloc
(
m1
,
15
);
m2
=
realloc
(
m1
,
15
);
/
/ CHECK(m1 != m2); //Depends on implementation
/
* CHECK(m1 != m2); //Depends on implementation */
STRCMP_EQUAL
(
"123456789"
,
m2
);
STRCMP_EQUAL
(
"123456789"
,
m2
);
free
(
m2
);
free
(
m2
);
}
}
...
@@ -142,9 +142,9 @@ TEST(UnityFixture, ConcludeTestIncrementsFailCount)
...
@@ -142,9 +142,9 @@ TEST(UnityFixture, ConcludeTestIncrementsFailCount)
_U_UINT
savedIgnores
=
Unity
.
TestIgnores
;
_U_UINT
savedIgnores
=
Unity
.
TestIgnores
;
UnityOutputCharSpy_Enable
(
1
);
UnityOutputCharSpy_Enable
(
1
);
Unity
.
CurrentTestFailed
=
1
;
Unity
.
CurrentTestFailed
=
1
;
UnityConcludeFixtureTest
();
/
/ Resets TestFailed for this test to pass
UnityConcludeFixtureTest
();
/
* Resets TestFailed for this test to pass */
Unity
.
CurrentTestIgnored
=
1
;
Unity
.
CurrentTestIgnored
=
1
;
UnityConcludeFixtureTest
();
/
/ Resets TestIgnored
UnityConcludeFixtureTest
();
/
* Resets TestIgnored */
UnityOutputCharSpy_Enable
(
0
);
UnityOutputCharSpy_Enable
(
0
);
TEST_ASSERT_EQUAL
(
savedFails
+
1
,
Unity
.
TestFailures
);
TEST_ASSERT_EQUAL
(
savedFails
+
1
,
Unity
.
TestFailures
);
TEST_ASSERT_EQUAL
(
savedIgnores
+
1
,
Unity
.
TestIgnores
);
TEST_ASSERT_EQUAL
(
savedIgnores
+
1
,
Unity
.
TestIgnores
);
...
@@ -152,7 +152,7 @@ TEST(UnityFixture, ConcludeTestIncrementsFailCount)
...
@@ -152,7 +152,7 @@ TEST(UnityFixture, ConcludeTestIncrementsFailCount)
Unity
.
TestIgnores
=
savedIgnores
;
Unity
.
TestIgnores
=
savedIgnores
;
}
}
/
/------------------------------------------------------------
/
*------------------------------------------------------------ */
TEST_GROUP
(
UnityCommandOptions
);
TEST_GROUP
(
UnityCommandOptions
);
...
@@ -312,7 +312,7 @@ IGNORE_TEST(UnityCommandOptions, TestShouldBeIgnored)
...
@@ -312,7 +312,7 @@ IGNORE_TEST(UnityCommandOptions, TestShouldBeIgnored)
TEST_FAIL_MESSAGE
(
"This test should not run!"
);
TEST_FAIL_MESSAGE
(
"This test should not run!"
);
}
}
/
/------------------------------------------------------------
/
*------------------------------------------------------------ */
TEST_GROUP
(
LeakDetection
);
TEST_GROUP
(
LeakDetection
);
...
@@ -342,7 +342,7 @@ TEST_TEAR_DOWN(LeakDetection)
...
@@ -342,7 +342,7 @@ TEST_TEAR_DOWN(LeakDetection)
memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \
memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \
}
}
/
/ This tricky set of defines lets us see if we are using the Spy, returns 1 if true
/
* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */
#ifdef __STDC_VERSION__
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ >= 199901L
#if __STDC_VERSION__ >= 199901L
...
@@ -352,17 +352,17 @@ TEST_TEAR_DOWN(LeakDetection)
...
@@ -352,17 +352,17 @@ TEST_TEAR_DOWN(LeakDetection)
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
#define SECOND_PARAM(a, b, ...) b
#define SECOND_PARAM(a, b, ...) b
#if USING_SPY_AS(UNITY_OUTPUT_CHAR)
#if USING_SPY_AS(UNITY_OUTPUT_CHAR)
#define USING_OUTPUT_SPY /
/ UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar
#define USING_OUTPUT_SPY
/
* UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar */
#endif
#endif
#endif /
/ >= 199901
#endif
/
* >= 199901 */
#else /
/ __STDC_VERSION__ else
#else
/
* __STDC_VERSION__ else */
#define UnityOutputCharSpy_OutputChar 42
#define UnityOutputCharSpy_OutputChar 42
#if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar /
/ Works if no -Wundef -Werror
#if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar
/
* Works if no -Wundef -Werror */
#define USING_OUTPUT_SPY
#define USING_OUTPUT_SPY
#endif
#endif
#undef UnityOutputCharSpy_OutputChar
#undef UnityOutputCharSpy_OutputChar
#endif /
/ __STDC_VERSION__
#endif
/
* __STDC_VERSION__ */
TEST
(
LeakDetection
,
DetectsLeak
)
TEST
(
LeakDetection
,
DetectsLeak
)
{
{
...
@@ -428,7 +428,7 @@ TEST(LeakDetection, BufferGuardWriteFoundDuringFree)
...
@@ -428,7 +428,7 @@ TEST(LeakDetection, BufferGuardWriteFoundDuringFree)
void
*
m
=
malloc
(
10
);
void
*
m
=
malloc
(
10
);
char
*
s
=
(
char
*
)
m
;
char
*
s
=
(
char
*
)
m
;
TEST_ASSERT_NOT_NULL
(
m
);
TEST_ASSERT_NOT_NULL
(
m
);
s
[
-
1
]
=
(
char
)
0x00
;
/
/ Will not detect 0
s
[
-
1
]
=
(
char
)
0x00
;
/
* Will not detect 0 */
s
[
-
2
]
=
(
char
)
0x01
;
s
[
-
2
]
=
(
char
)
0x01
;
UnityOutputCharSpy_Enable
(
1
);
UnityOutputCharSpy_Enable
(
1
);
EXPECT_ABORT_BEGIN
EXPECT_ABORT_BEGIN
...
@@ -476,7 +476,7 @@ TEST(LeakDetection, PointerSettingMax)
...
@@ -476,7 +476,7 @@ TEST(LeakDetection, PointerSettingMax)
#endif
#endif
}
}
/
/------------------------------------------------------------
/
*------------------------------------------------------------ */
TEST_GROUP
(
InternalMalloc
);
TEST_GROUP
(
InternalMalloc
);
#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \
#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \
...
@@ -535,9 +535,9 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem)
...
@@ -535,9 +535,9 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem)
if
(
out_of_mem
==
NULL
)
free
(
n1
);
if
(
out_of_mem
==
NULL
)
free
(
n1
);
free
(
m
);
free
(
m
);
TEST_ASSERT_NOT_NULL
(
m
);
/
/ Got a real memory location
TEST_ASSERT_NOT_NULL
(
m
);
/
* Got a real memory location */
TEST_ASSERT_NULL
(
out_of_mem
);
/
/ The realloc should have failed
TEST_ASSERT_NULL
(
out_of_mem
);
/
* The realloc should have failed */
TEST_ASSERT_NOT_EQUAL
(
n2
,
n1
);
/
/ If n1 != n2 then realloc did not free n1
TEST_ASSERT_NOT_EQUAL
(
n2
,
n1
);
/
* If n1 != n2 then realloc did not free n1 */
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n2
);
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n2
);
#endif
#endif
}
}
extras/fixture/test/unity_fixture_TestRunner.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include "unity_fixture.h"
#include "unity_fixture.h"
...
...
extras/fixture/test/unity_output_Spy.c
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#include "unity_output_Spy.h"
#include "unity_output_Spy.h"
...
...
extras/fixture/test/unity_output_Spy.h
浏览文件 @
de7627f0
/
/-
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
*
Copyright (c) 2010 James Grenning and Contributed to Unity Project
/
* ==========================================
* ==========================================
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]
========================================== */
*
========================================== */
#ifndef D_unity_output_Spy_H
#ifndef D_unity_output_Spy_H
#define D_unity_output_Spy_H
#define D_unity_output_Spy_H
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录