test-string-input-visitor: Tear down existing test automatically
Call visitor_input_teardown() from visitor_input_test_init(), so you
don't have to call it from the actual tests.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1488544368-30622-22-git-send-email-armbru@redhat.com>
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index 7f10e25..a32828c 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -39,6 +39,8 @@
Visitor *visitor_input_test_init(TestInputVisitorData *data,
const char *string)
{
+ visitor_input_teardown(data, NULL);
+
data->v = string_input_visitor_new(string);
g_assert(data->v);
return data->v;
@@ -57,8 +59,6 @@
g_assert(!err);
g_assert_cmpint(res, ==, value);
- visitor_input_teardown(data, unused);
-
v = visitor_input_test_init(data, "not an int");
visit_type_int(v, NULL, &res, &err);
@@ -87,8 +87,6 @@
qapi_free_int16List(res);
- visitor_input_teardown(data, unused);
-
v = visitor_input_test_init(data, "not an int list");
visit_type_int16List(v, NULL, &res, &err);
@@ -108,35 +106,30 @@
visit_type_bool(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, true);
- visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "yes");
visit_type_bool(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, true);
- visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "on");
visit_type_bool(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, true);
- visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "false");
visit_type_bool(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, false);
- visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "no");
visit_type_bool(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, false);
- visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "off");
@@ -190,8 +183,6 @@
visit_type_EnumOne(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(i, ==, res);
-
- visitor_input_teardown(data, NULL);
}
}
@@ -224,30 +215,24 @@
v = visitor_input_test_init(data, buf);
visit_type_int(v, NULL, &ires, NULL);
- visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
visit_type_intList(v, NULL, &ilres, NULL);
qapi_free_intList(ilres);
- visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
visit_type_bool(v, NULL, &bres, NULL);
- visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
visit_type_number(v, NULL, &nres, NULL);
- visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
sres = NULL;
visit_type_str(v, NULL, &sres, NULL);
g_free(sres);
- visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
visit_type_EnumOne(v, NULL, &eres, NULL);
- visitor_input_teardown(data, NULL);
}
}