Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
75ad84c9
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看板
提交
75ad84c9
编写于
8月 21, 2016
作者:
M
Mark VanderVoord
提交者:
GitHub
8月 21, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #209 from jsalling/cleanup/fixture-memory-testing
Cleanup fixture memory testing
上级
f276c79f
92f6d5dd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
13 deletion
+17
-13
extras/fixture/src/unity_fixture.c
extras/fixture/src/unity_fixture.c
+0
-3
extras/fixture/test/unity_fixture_Test.c
extras/fixture/test/unity_fixture_Test.c
+17
-10
未找到文件。
extras/fixture/src/unity_fixture.c
浏览文件 @
75ad84c9
...
...
@@ -207,9 +207,6 @@ void* unity_malloc(size_t size)
mem
=
(
char
*
)
&
(
guard
[
1
]);
memcpy
(
&
mem
[
size
],
end
,
sizeof
(
end
));
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
free
(
guard
);
#endif
return
(
void
*
)
mem
;
}
...
...
extras/fixture/test/unity_fixture_Test.c
浏览文件 @
75ad84c9
...
...
@@ -479,6 +479,10 @@ TEST(LeakDetection, PointerSettingMax)
//------------------------------------------------------------
TEST_GROUP
(
InternalMalloc
);
#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \
ptr = malloc(10); free(ptr); \
TEST_ASSERT_EQUAL_PTR_MESSAGE(first_mem_ptr, ptr, "Memory was stranded, free in LIFO order");
TEST_SETUP
(
InternalMalloc
)
{
}
TEST_TEAR_DOWN
(
InternalMalloc
)
{
}
...
...
@@ -488,9 +492,10 @@ TEST(InternalMalloc, MallocPastBufferFails)
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
void
*
m
=
malloc
(
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
+
1
);
void
*
n
=
malloc
(
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
);
free
(
m
);
TEST_ASSERT_NOT_NULL
(
m
);
TEST_ASSERT_NULL
(
n
);
free
(
m
);
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n
);
#endif
}
...
...
@@ -499,9 +504,10 @@ TEST(InternalMalloc, CallocPastBufferFails)
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
void
*
m
=
calloc
(
1
,
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
+
1
);
void
*
n
=
calloc
(
1
,
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
);
free
(
m
);
TEST_ASSERT_NOT_NULL
(
m
);
TEST_ASSERT_NULL
(
n
);
free
(
m
);
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n
);
#endif
}
...
...
@@ -510,9 +516,10 @@ TEST(InternalMalloc, MallocThenReallocGrowsMemoryInPlace)
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
void
*
m
=
malloc
(
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
+
1
);
void
*
n
=
realloc
(
m
,
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
+
9
);
free
(
n
);
TEST_ASSERT_NOT_NULL
(
m
);
TEST_ASSERT_EQUAL
(
m
,
n
);
free
(
n
);
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n
);
#endif
}
...
...
@@ -523,14 +530,14 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem)
void
*
n1
=
malloc
(
10
);
void
*
out_of_mem
=
realloc
(
n1
,
UNITY_INTERNAL_HEAP_SIZE_BYTES
/
2
+
1
);
void
*
n2
=
malloc
(
10
);
TEST_ASSERT_NOT_NULL
(
m
);
if
(
out_of_mem
==
NULL
)
{
free
(
n1
);
TEST_ASSERT_NULL
(
out_of_mem
);
}
TEST_ASSERT_NOT_EQUAL
(
n2
,
n1
);
free
(
n2
);
if
(
out_of_mem
==
NULL
)
free
(
n1
);
free
(
m
);
TEST_ASSERT_NOT_NULL
(
m
);
// Got a real memory location
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_MEMORY_ALL_FREE_LIFO_ORDER
(
m
,
n2
);
#endif
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录