aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-06-26 18:22:59 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-07-24 13:35:11 +0200
commitd2f95f4d482374485234790a6fc3cca29ebb7355 (patch)
tree4c95230bc64d9a294c9bc6de6696e887576a235a /tests
parent006ca09f3027d86346fce707e9295975c6558f42 (diff)
qapi: Use QNull for a more regular visit_type_null()
Make visit_type_null() take an @obj argument like its buddies. This helps keep the next commit simple. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qnull.c9
-rw-r--r--tests/test-qobject-input-visitor.c13
-rw-r--r--tests/test-qobject-output-visitor.c3
3 files changed, 18 insertions, 7 deletions
diff --git a/tests/check-qnull.c b/tests/check-qnull.c
index 1ab7c983a5..5c6eb0adc8 100644
--- a/tests/check-qnull.c
+++ b/tests/check-qnull.c
@@ -38,6 +38,7 @@ static void qnull_visit_test(void)
{
QObject *obj;
Visitor *v;
+ QNull *null;
/*
* Most tests of interactions between QObject and visitors are in
@@ -49,13 +50,17 @@ static void qnull_visit_test(void)
obj = QOBJECT(qnull());
v = qobject_input_visitor_new(obj);
qobject_decref(obj);
- visit_type_null(v, NULL, &error_abort);
+ visit_type_null(v, NULL, &null, &error_abort);
+ g_assert(obj == QOBJECT(&qnull_));
+ QDECREF(null);
visit_free(v);
+ null = NULL;
v = qobject_output_visitor_new(&obj);
- visit_type_null(v, NULL, &error_abort);
+ visit_type_null(v, NULL, &null, &error_abort);
visit_complete(v, &obj);
g_assert(obj == QOBJECT(&qnull_));
+ QDECREF(null);
qobject_decref(obj);
visit_free(v);
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 34bab8a913..f98caf9818 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -510,6 +510,7 @@ static void test_visitor_in_null(TestInputVisitorData *data,
{
Visitor *v;
Error *err = NULL;
+ QNull *null;
char *tmp;
/*
@@ -524,12 +525,15 @@ static void test_visitor_in_null(TestInputVisitorData *data,
v = visitor_input_test_init_full(data, false,
"{ 'a': null, 'b': '' }");
visit_start_struct(v, NULL, NULL, 0, &error_abort);
- visit_type_null(v, "a", &error_abort);
- visit_type_null(v, "b", &err);
+ visit_type_null(v, "a", &null, &error_abort);
+ g_assert(qobject_type(QOBJECT(null)) == QTYPE_QNULL);
+ QDECREF(null);
+ visit_type_null(v, "b", &null, &err);
error_free_or_abort(&err);
+ g_assert(!null);
visit_type_str(v, "c", &tmp, &err);
- g_assert(!tmp);
error_free_or_abort(&err);
+ g_assert(!tmp);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
}
@@ -1087,6 +1091,7 @@ static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
Error *err = NULL;
Visitor *v;
QObject *any;
+ QNull *null;
GenericAlternate *alt;
bool present;
int en;
@@ -1120,7 +1125,7 @@ static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
error_free_or_abort(&err);
visit_type_any(v, "any", &any, &err);
error_free_or_abort(&err);
- visit_type_null(v, "null", &err);
+ visit_type_null(v, "null", &null, &err);
error_free_or_abort(&err);
visit_start_list(v, "sub", NULL, 0, &error_abort);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 749c54065f..8f1fcd49cb 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -445,11 +445,12 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
static void test_visitor_out_null(TestOutputVisitorData *data,
const void *unused)
{
+ QNull *null = NULL;
QDict *qdict;
QObject *nil;
visit_start_struct(data->ov, NULL, NULL, 0, &error_abort);
- visit_type_null(data->ov, "a", &error_abort);
+ visit_type_null(data->ov, "a", &null, &error_abort);
visit_check_struct(data->ov, &error_abort);
visit_end_struct(data->ov, NULL);
qdict = qobject_to_qdict(visitor_get(data));