Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
0ac7cc2a
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0ac7cc2a
编写于
1月 10, 2012
作者:
A
Anthony Liguori
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check-qstring: convert to gtest
Signed-off-by:
N
Anthony Liguori
<
aliguori@us.ibm.com
>
上级
65cdadd2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
53 deletion
+26
-53
check-qstring.c
check-qstring.c
+24
-51
configure
configure
+2
-2
未找到文件。
check-qstring.c
浏览文件 @
0ac7cc2a
...
...
@@ -20,31 +20,29 @@
* (with some violations to access 'private' data)
*/
START_TEST
(
qstring_from_str_test
)
static
void
qstring_from_str_test
(
void
)
{
QString
*
qstring
;
const
char
*
str
=
"QEMU"
;
qstring
=
qstring_from_str
(
str
);
fail_unless
(
qstring
!=
NULL
);
fail_unless
(
qstring
->
base
.
refcnt
==
1
);
fail_unless
(
strcmp
(
str
,
qstring
->
string
)
==
0
);
fail_unless
(
qobject_type
(
QOBJECT
(
qstring
))
==
QTYPE_QSTRING
);
g_assert
(
qstring
!=
NULL
);
g_assert
(
qstring
->
base
.
refcnt
==
1
);
g_assert
(
strcmp
(
str
,
qstring
->
string
)
==
0
);
g_assert
(
qobject_type
(
QOBJECT
(
qstring
))
==
QTYPE_QSTRING
);
// destroy doesn't exit yet
g_free
(
qstring
->
string
);
g_free
(
qstring
);
}
END_TEST
START_TEST
(
qstring_destroy_test
)
static
void
qstring_destroy_test
(
void
)
{
QString
*
qstring
=
qstring_from_str
(
"destroy test"
);
QDECREF
(
qstring
);
}
END_TEST
START_TEST
(
qstring_get_str_test
)
static
void
qstring_get_str_test
(
void
)
{
QString
*
qstring
;
const
char
*
ret_str
;
...
...
@@ -52,13 +50,12 @@ START_TEST(qstring_get_str_test)
qstring
=
qstring_from_str
(
str
);
ret_str
=
qstring_get_str
(
qstring
);
fail_unless
(
strcmp
(
ret_str
,
str
)
==
0
);
g_assert
(
strcmp
(
ret_str
,
str
)
==
0
);
QDECREF
(
qstring
);
}
END_TEST
START_TEST
(
qstring_append_chr_test
)
static
void
qstring_append_chr_test
(
void
)
{
int
i
;
QString
*
qstring
;
...
...
@@ -69,66 +66,42 @@ START_TEST(qstring_append_chr_test)
for
(
i
=
0
;
str
[
i
];
i
++
)
qstring_append_chr
(
qstring
,
str
[
i
]);
fail_unless
(
strcmp
(
str
,
qstring_get_str
(
qstring
))
==
0
);
g_assert
(
strcmp
(
str
,
qstring_get_str
(
qstring
))
==
0
);
QDECREF
(
qstring
);
}
END_TEST
START_TEST
(
qstring_from_substr_test
)
static
void
qstring_from_substr_test
(
void
)
{
QString
*
qs
;
qs
=
qstring_from_substr
(
"virtualization"
,
3
,
9
);
fail_unless
(
qs
!=
NULL
);
fail_unless
(
strcmp
(
qstring_get_str
(
qs
),
"tualiza"
)
==
0
);
g_assert
(
qs
!=
NULL
);
g_assert
(
strcmp
(
qstring_get_str
(
qs
),
"tualiza"
)
==
0
);
QDECREF
(
qs
);
}
END_TEST
START_TEST
(
qobject_to_qstring_test
)
static
void
qobject_to_qstring_test
(
void
)
{
QString
*
qstring
;
qstring
=
qstring_from_str
(
"foo"
);
fail_unless
(
qobject_to_qstring
(
QOBJECT
(
qstring
))
==
qstring
);
g_assert
(
qobject_to_qstring
(
QOBJECT
(
qstring
))
==
qstring
);
QDECREF
(
qstring
);
}
END_TEST
static
Suite
*
qstring_suite
(
void
)
int
main
(
int
argc
,
char
**
argv
)
{
Suite
*
s
;
TCase
*
qstring_public_tcase
;
g_test_init
(
&
argc
,
&
argv
,
NULL
);
s
=
suite_create
(
"QString test-suite"
);
g_test_add_func
(
"/public/from_str"
,
qstring_from_str_test
);
g_test_add_func
(
"/public/destroy"
,
qstring_destroy_test
);
g_test_add_func
(
"/public/get_str"
,
qstring_get_str_test
);
g_test_add_func
(
"/public/append_chr"
,
qstring_append_chr_test
);
g_test_add_func
(
"/public/from_substr"
,
qstring_from_substr_test
);
g_test_add_func
(
"/public/to_qstring"
,
qobject_to_qstring_test
);
qstring_public_tcase
=
tcase_create
(
"Public Interface"
);
suite_add_tcase
(
s
,
qstring_public_tcase
);
tcase_add_test
(
qstring_public_tcase
,
qstring_from_str_test
);
tcase_add_test
(
qstring_public_tcase
,
qstring_destroy_test
);
tcase_add_test
(
qstring_public_tcase
,
qstring_get_str_test
);
tcase_add_test
(
qstring_public_tcase
,
qstring_append_chr_test
);
tcase_add_test
(
qstring_public_tcase
,
qstring_from_substr_test
);
tcase_add_test
(
qstring_public_tcase
,
qobject_to_qstring_test
);
return
s
;
}
int
main
(
void
)
{
int
nf
;
Suite
*
s
;
SRunner
*
sr
;
s
=
qstring_suite
();
sr
=
srunner_create
(
s
);
srunner_run_all
(
sr
,
CK_NORMAL
);
nf
=
srunner_ntests_failed
(
sr
);
srunner_free
(
sr
);
return
(
nf
==
0
)
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
return
g_test_run
();
}
configure
浏览文件 @
0ac7cc2a
...
...
@@ -2800,10 +2800,10 @@ if test "$softmmu" = yes ; then
tools
=
"qemu-ga
\$
(EXESUF)
$tools
"
fi
if
[
"
$check_utests
"
=
"yes"
]
;
then
checks
=
"check-q
string check-q
list"
checks
=
"check-qlist"
checks
=
"check-qjson
$checks
"
fi
test_progs
=
"
$checks
check-qdict check-qfloat check-qint test-coroutine test-qmp-output-visitor test-qmp-input-visitor"
test_progs
=
"
$checks
check-qdict check-qfloat check-qint
check-qstring
test-coroutine test-qmp-output-visitor test-qmp-input-visitor"
fi
fi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录