aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHu Tao <hutao@cn.fujitsu.com>2014-06-10 19:15:28 +0800
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 18:44:21 +0300
commit69e255635d0126dcce60b17454a7ec23e7afc174 (patch)
tree47c82803a102a3063f3f2531f96424cdce8e5a8e /tests
parent659268ffbff0ffc823eb30dbe0ce83bd5703933e (diff)
qapi: make string output visitor parse int list
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> MST: split up patch
Diffstat (limited to 'tests')
-rw-r--r--tests/test-string-output-visitor.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index 2af5a21ab5..28e7359a2a 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -44,7 +44,7 @@ static void visitor_output_teardown(TestOutputVisitorData *data,
static void test_visitor_out_int(TestOutputVisitorData *data,
const void *unused)
{
- int64_t value = -42;
+ int64_t value = 42;
Error *err = NULL;
char *str;
@@ -53,10 +53,42 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
str = string_output_get_string(data->sov);
g_assert(str != NULL);
- g_assert_cmpstr(str, ==, "-42");
+ g_assert_cmpstr(str, ==, "42");
g_free(str);
}
+static void test_visitor_out_intList(TestOutputVisitorData *data,
+ const void *unused)
+{
+ int64_t value[] = {0, 1, 9, 10, 16, 15, 14,
+ 3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX};
+ intList *list = NULL, **tmp = &list;
+ int i;
+ Error *errp = NULL;
+ char *str;
+
+ for (i = 0; i < sizeof(value) / sizeof(value[0]); i++) {
+ *tmp = g_malloc0(sizeof(**tmp));
+ (*tmp)->value = value[i];
+ tmp = &(*tmp)->next;
+ }
+
+ visit_type_intList(data->ov, &list, NULL, &errp);
+ g_assert(errp == NULL);
+
+ str = string_output_get_string(data->sov);
+ g_assert(str != NULL);
+ g_assert_cmpstr(str, ==,
+ "0-1,3-6,9-16,21-22,9223372036854775806-9223372036854775807");
+ g_free(str);
+ while (list) {
+ intList *tmp2;
+ tmp2 = list->next;
+ g_free(list);
+ list = tmp2;
+ }
+}
+
static void test_visitor_out_bool(TestOutputVisitorData *data,
const void *unused)
{
@@ -182,6 +214,8 @@ int main(int argc, char **argv)
&out_visitor_data, test_visitor_out_enum);
output_visitor_test_add("/string-visitor/output/enum-errors",
&out_visitor_data, test_visitor_out_enum_errors);
+ output_visitor_test_add("/string-visitor/output/intList",
+ &out_visitor_data, test_visitor_out_intList);
g_test_run();