Lines Matching +full:- +full:v

2  * String Input Visitor unit-tests.
7 * Paolo Bonzini <pbonzini@redhat.com> (based on test-qobject-input-visitor)
10 * See the COPYING file in the top-level directory.
16 #include "qapi/string-input-visitor.h"
17 #include "test-qapi-visit.h"
20 Visitor *v; member
26 if (data->v) { in visitor_input_teardown()
27 visit_free(data->v); in visitor_input_teardown()
28 data->v = NULL; in visitor_input_teardown()
41 data->v = string_input_visitor_new(string); in visitor_input_test_init()
42 g_assert(data->v); in visitor_input_test_init()
43 return data->v; in visitor_input_test_init()
49 int64_t res = 0, value = -42; in test_visitor_in_int()
51 Visitor *v; in test_visitor_in_int() local
53 v = visitor_input_test_init(data, "-42"); in test_visitor_in_int()
55 visit_type_int(v, NULL, &res, &error_abort); in test_visitor_in_int()
58 v = visitor_input_test_init(data, "not an int"); in test_visitor_in_int()
60 visit_type_int(v, NULL, &res, &err); in test_visitor_in_int()
63 v = visitor_input_test_init(data, ""); in test_visitor_in_int()
65 visit_type_int(v, NULL, &res, &err); in test_visitor_in_int()
69 static void check_ilist(Visitor *v, int64_t *expected, size_t n) in check_ilist() argument
75 visit_type_int64List(v, NULL, &res, &error_abort); in check_ilist()
79 g_assert_cmpint(tail->value, ==, expected[i]); in check_ilist()
80 tail = tail->next; in check_ilist()
87 static void check_ulist(Visitor *v, uint64_t *expected, size_t n) in check_ulist() argument
93 visit_type_uint64List(v, NULL, &res, &error_abort); in check_ulist()
97 g_assert_cmpuint(tail->value, ==, expected[i]); in check_ulist()
98 tail = tail->next; in check_ulist()
110 int64_t expect2[] = { 32767, -32768, -32767 }; in test_visitor_in_intList()
113 int64_t expect5[] = { INT64_MAX - 2, INT64_MAX - 1, INT64_MAX }; in test_visitor_in_intList()
116 Visitor *v; in test_visitor_in_intList() local
121 v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8"); in test_visitor_in_intList()
122 check_ilist(v, expect1, ARRAY_SIZE(expect1)); in test_visitor_in_intList()
124 v = visitor_input_test_init(data, "32767,-32768--32767"); in test_visitor_in_intList()
125 check_ilist(v, expect2, ARRAY_SIZE(expect2)); in test_visitor_in_intList()
127 v = visitor_input_test_init(data, in test_visitor_in_intList()
128 "-9223372036854775808,9223372036854775807"); in test_visitor_in_intList()
129 check_ilist(v, expect3, ARRAY_SIZE(expect3)); in test_visitor_in_intList()
131 v = visitor_input_test_init(data, "1-1"); in test_visitor_in_intList()
132 check_ilist(v, expect4, ARRAY_SIZE(expect4)); in test_visitor_in_intList()
134 v = visitor_input_test_init(data, in test_visitor_in_intList()
135 "9223372036854775805-9223372036854775807"); in test_visitor_in_intList()
136 check_ilist(v, expect5, ARRAY_SIZE(expect5)); in test_visitor_in_intList()
140 v = visitor_input_test_init(data, "9223372036854775808"); in test_visitor_in_intList()
141 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
147 v = visitor_input_test_init(data, "-9223372036854775809"); in test_visitor_in_intList()
148 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
154 v = visitor_input_test_init(data, "3-1"); in test_visitor_in_intList()
155 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
159 v = visitor_input_test_init(data, "9223372036854775807-0"); in test_visitor_in_intList()
160 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
166 v = visitor_input_test_init(data, "0-65536"); in test_visitor_in_intList()
167 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
173 v = visitor_input_test_init(data, ""); in test_visitor_in_intList()
174 visit_type_int64List(v, NULL, &res, &error_abort); in test_visitor_in_intList()
179 v = visitor_input_test_init(data, "not an int list"); in test_visitor_in_intList()
181 visit_type_int64List(v, NULL, &res, &err); in test_visitor_in_intList()
187 v = visitor_input_test_init(data, "0,2-3"); in test_visitor_in_intList()
189 visit_start_list(v, NULL, NULL, 0, &error_abort); in test_visitor_in_intList()
190 visit_type_int64(v, NULL, &val, &error_abort); in test_visitor_in_intList()
192 visit_type_int64(v, NULL, &val, &error_abort); in test_visitor_in_intList()
195 visit_check_list(v, &err); in test_visitor_in_intList()
197 visit_end_list(v, NULL); in test_visitor_in_intList()
201 v = visitor_input_test_init(data, "0"); in test_visitor_in_intList()
203 visit_start_list(v, NULL, NULL, 0, &error_abort); in test_visitor_in_intList()
204 visit_type_int64(v, NULL, &val, &err); in test_visitor_in_intList()
206 visit_type_int64(v, NULL, &val, &err); in test_visitor_in_intList()
209 visit_check_list(v, &error_abort); in test_visitor_in_intList()
210 visit_end_list(v, NULL); in test_visitor_in_intList()
218 uint64_t expect2[] = { 32767, -32768, -32767 }; in test_visitor_in_uintList()
222 uint64_t expect6[] = { UINT64_MAX - 2, UINT64_MAX - 1, UINT64_MAX }; in test_visitor_in_uintList()
225 Visitor *v; in test_visitor_in_uintList() local
230 v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8"); in test_visitor_in_uintList()
231 check_ulist(v, expect1, ARRAY_SIZE(expect1)); in test_visitor_in_uintList()
233 v = visitor_input_test_init(data, "32767,-32768--32767"); in test_visitor_in_uintList()
234 check_ulist(v, expect2, ARRAY_SIZE(expect2)); in test_visitor_in_uintList()
236 v = visitor_input_test_init(data, in test_visitor_in_uintList()
237 "-9223372036854775808,9223372036854775807"); in test_visitor_in_uintList()
238 check_ulist(v, expect3, ARRAY_SIZE(expect3)); in test_visitor_in_uintList()
240 v = visitor_input_test_init(data, "1-1"); in test_visitor_in_uintList()
241 check_ulist(v, expect4, ARRAY_SIZE(expect4)); in test_visitor_in_uintList()
243 v = visitor_input_test_init(data, "18446744073709551615"); in test_visitor_in_uintList()
244 check_ulist(v, expect5, ARRAY_SIZE(expect5)); in test_visitor_in_uintList()
246 v = visitor_input_test_init(data, in test_visitor_in_uintList()
247 "18446744073709551613-18446744073709551615"); in test_visitor_in_uintList()
248 check_ulist(v, expect6, ARRAY_SIZE(expect6)); in test_visitor_in_uintList()
252 v = visitor_input_test_init(data, "18446744073709551616"); in test_visitor_in_uintList()
253 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
259 v = visitor_input_test_init(data, "-18446744073709551616"); in test_visitor_in_uintList()
260 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
266 v = visitor_input_test_init(data, "3-1"); in test_visitor_in_uintList()
267 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
271 v = visitor_input_test_init(data, "18446744073709551615-0"); in test_visitor_in_uintList()
272 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
278 v = visitor_input_test_init(data, "0-65536"); in test_visitor_in_uintList()
279 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
285 v = visitor_input_test_init(data, ""); in test_visitor_in_uintList()
286 visit_type_uint64List(v, NULL, &res, &error_abort); in test_visitor_in_uintList()
291 v = visitor_input_test_init(data, "not an uint list"); in test_visitor_in_uintList()
293 visit_type_uint64List(v, NULL, &res, &err); in test_visitor_in_uintList()
299 v = visitor_input_test_init(data, "0,2-3"); in test_visitor_in_uintList()
301 visit_start_list(v, NULL, NULL, 0, &error_abort); in test_visitor_in_uintList()
302 visit_type_uint64(v, NULL, &val, &error_abort); in test_visitor_in_uintList()
304 visit_type_uint64(v, NULL, &val, &error_abort); in test_visitor_in_uintList()
307 visit_check_list(v, &err); in test_visitor_in_uintList()
309 visit_end_list(v, NULL); in test_visitor_in_uintList()
313 v = visitor_input_test_init(data, "0"); in test_visitor_in_uintList()
315 visit_start_list(v, NULL, NULL, 0, &error_abort); in test_visitor_in_uintList()
316 visit_type_uint64(v, NULL, &val, &err); in test_visitor_in_uintList()
318 visit_type_uint64(v, NULL, &val, &err); in test_visitor_in_uintList()
321 visit_check_list(v, &error_abort); in test_visitor_in_uintList()
322 visit_end_list(v, NULL); in test_visitor_in_uintList()
329 Visitor *v; in test_visitor_in_bool() local
331 v = visitor_input_test_init(data, "true"); in test_visitor_in_bool()
333 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
336 v = visitor_input_test_init(data, "yes"); in test_visitor_in_bool()
338 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
341 v = visitor_input_test_init(data, "on"); in test_visitor_in_bool()
343 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
346 v = visitor_input_test_init(data, "false"); in test_visitor_in_bool()
348 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
351 v = visitor_input_test_init(data, "no"); in test_visitor_in_bool()
353 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
356 v = visitor_input_test_init(data, "off"); in test_visitor_in_bool()
358 visit_type_bool(v, NULL, &res, &error_abort); in test_visitor_in_bool()
367 Visitor *v; in test_visitor_in_number() local
369 v = visitor_input_test_init(data, "3.14"); in test_visitor_in_number()
371 visit_type_number(v, NULL, &res, &error_abort); in test_visitor_in_number()
376 v = visitor_input_test_init(data, "NaN"); in test_visitor_in_number()
378 visit_type_number(v, NULL, &res, &err); in test_visitor_in_number()
381 v = visitor_input_test_init(data, "inf"); in test_visitor_in_number()
383 visit_type_number(v, NULL, &res, &err); in test_visitor_in_number()
392 Visitor *v; in test_visitor_in_string() local
394 v = visitor_input_test_init(data, value); in test_visitor_in_string()
396 visit_type_str(v, NULL, &res, &error_abort); in test_visitor_in_string()
405 Visitor *v; in test_visitor_in_enum() local
409 EnumOne res = -1; in test_visitor_in_enum()
411 v = visitor_input_test_init(data, EnumOne_str(i)); in test_visitor_in_enum()
413 visit_type_EnumOne(v, NULL, &res, &error_abort); in test_visitor_in_enum()
428 Visitor *v; in test_visitor_in_fuzz() local
435 j = g_test_rand_int_range(0, sizeof(buf) - 1); in test_visitor_in_fuzz()
443 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
444 visit_type_int(v, NULL, &ires, NULL); in test_visitor_in_fuzz()
446 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
447 visit_type_intList(v, NULL, &ilres, NULL); in test_visitor_in_fuzz()
450 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
451 visit_type_bool(v, NULL, &bres, NULL); in test_visitor_in_fuzz()
453 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
454 visit_type_number(v, NULL, &nres, NULL); in test_visitor_in_fuzz()
456 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
458 visit_type_str(v, NULL, &sres, NULL); in test_visitor_in_fuzz()
461 v = visitor_input_test_init(data, buf); in test_visitor_in_fuzz()
462 visit_type_EnumOne(v, NULL, &eres, NULL); in test_visitor_in_fuzz()
480 input_visitor_test_add("/string-visitor/input/int", in main()
482 input_visitor_test_add("/string-visitor/input/intList", in main()
484 input_visitor_test_add("/string-visitor/input/uintList", in main()
486 input_visitor_test_add("/string-visitor/input/bool", in main()
488 input_visitor_test_add("/string-visitor/input/number", in main()
490 input_visitor_test_add("/string-visitor/input/string", in main()
492 input_visitor_test_add("/string-visitor/input/enum", in main()
494 input_visitor_test_add("/string-visitor/input/fuzz", in main()