Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b7bcb22c
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b7bcb22c
编写于
1月 23, 2012
作者:
S
Stefan Berger
提交者:
Stefan Berger
1月 23, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test case for virHashEqual function
Add a test case to test the virHashEqual function.
上级
da094fe2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
0 deletion
+79
-0
tests/hashtest.c
tests/hashtest.c
+79
-0
未找到文件。
tests/hashtest.c
浏览文件 @
b7bcb22c
...
@@ -574,6 +574,84 @@ cleanup:
...
@@ -574,6 +574,84 @@ cleanup:
return
ret
;
return
ret
;
}
}
static
int
testHashEqualCompValue
(
const
void
*
value1
,
const
void
*
value2
)
{
return
c_strcasecmp
(
value1
,
value2
);
}
static
int
testHashEqual
(
const
void
*
data
ATTRIBUTE_UNUSED
)
{
virHashTablePtr
hash1
,
hash2
;
int
ret
=
-
1
;
char
keya
[]
=
"a"
;
char
keyb
[]
=
"b"
;
char
keyc
[]
=
"c"
;
char
value1_l
[]
=
"m"
;
char
value2_l
[]
=
"n"
;
char
value3_l
[]
=
"o"
;
char
value1_u
[]
=
"M"
;
char
value2_u
[]
=
"N"
;
char
value3_u
[]
=
"O"
;
char
value4_u
[]
=
"P"
;
if
(
!
(
hash1
=
virHashCreate
(
0
,
NULL
))
||
!
(
hash2
=
virHashCreate
(
0
,
NULL
))
||
virHashAddEntry
(
hash1
,
keya
,
value1_l
)
<
0
||
virHashAddEntry
(
hash1
,
keyb
,
value2_l
)
<
0
||
virHashAddEntry
(
hash1
,
keyc
,
value3_l
)
<
0
||
virHashAddEntry
(
hash2
,
keya
,
value1_u
)
<
0
||
virHashAddEntry
(
hash2
,
keyb
,
value2_u
)
<
0
)
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed to create hashes"
);
}
goto
cleanup
;
}
if
(
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed equal test for different number of elements"
);
}
goto
cleanup
;
}
if
(
virHashAddEntry
(
hash2
,
keyc
,
value4_u
)
<
0
)
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed to add element to hash2"
);
}
goto
cleanup
;
}
if
(
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed equal test for same number of elements"
);
}
goto
cleanup
;
}
if
(
virHashUpdateEntry
(
hash2
,
keyc
,
value3_u
)
<
0
)
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed to update element in hash2"
);
}
goto
cleanup
;
}
if
(
!
virHashEqual
(
hash1
,
hash2
,
testHashEqualCompValue
))
{
if
(
virTestGetVerbose
())
{
testError
(
"
\n
failed equal test for equal hash tables"
);
}
goto
cleanup
;
}
ret
=
0
;
cleanup:
virHashFree
(
hash1
);
virHashFree
(
hash2
);
return
ret
;
}
static
int
static
int
mymain
(
void
)
mymain
(
void
)
...
@@ -612,6 +690,7 @@ mymain(void)
...
@@ -612,6 +690,7 @@ mymain(void)
DO_TEST
(
"RemoveSet"
,
RemoveSet
);
DO_TEST
(
"RemoveSet"
,
RemoveSet
);
DO_TEST
(
"Search"
,
Search
);
DO_TEST
(
"Search"
,
Search
);
DO_TEST
(
"GetItems"
,
GetItems
);
DO_TEST
(
"GetItems"
,
GetItems
);
DO_TEST
(
"Equal"
,
Equal
);
return
(
ret
==
0
)
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
return
(
ret
==
0
)
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录