static void test_validate_alternate(TestInputVisitorData *data, const void *unused) { UserDefAlternate *tmp = NULL; Visitor *v; v = validate_test_init(data, "42"); visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort); qapi_free_UserDefAlternate(tmp); }
static void test_validate_union_native_list(TestInputVisitorData *data, const void *unused) { UserDefNativeListUnion *tmp = NULL; Visitor *v; v = validate_test_init(data, "{ 'type': 'integer', 'data' : [ 1, 2 ] }"); visit_type_UserDefNativeListUnion(v, NULL, &tmp, &error_abort); qapi_free_UserDefNativeListUnion(tmp); }
static void test_validate_list(TestInputVisitorData *data, const void *unused) { UserDefOneList *head = NULL; Visitor *v; v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]"); visit_type_UserDefOneList(v, NULL, &head, &error_abort); qapi_free_UserDefOneList(head); }
static void test_validate_struct(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Visitor *v; v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); visit_type_TestStruct(v, NULL, &p, &error_abort); g_free(p->string); g_free(p); }
static void test_validate_fail_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefNested *udp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &err); g_assert(err); qapi_free_UserDefNested(udp); }
static void test_validate_fail_union(TestInputVisitorData *data, const void *unused) { UserDefUnion *tmp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }"); visit_type_UserDefUnion(v, &tmp, NULL, &err); g_assert(err); qapi_free_UserDefUnion(tmp); }
static void test_validate_fail_alternate(TestInputVisitorData *data, const void *unused) { UserDefAlternate *tmp; Visitor *v; Error *err = NULL; v = validate_test_init(data, "3.14"); visit_type_UserDefAlternate(v, NULL, &tmp, &err); error_free_or_abort(&err); g_assert(!tmp); }
static void test_validate_fail_struct(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }"); visit_type_TestStruct(v, NULL, &p, &err); error_free_or_abort(&err); g_assert(!p); }
static void test_validate_fail_union_flat(TestInputVisitorData *data, const void *unused) { UserDefFlatUnion *tmp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }"); visit_type_UserDefFlatUnion(v, &tmp, NULL, &err); g_assert(err); qapi_free_UserDefFlatUnion(tmp); }
static void test_validate_fail_list(TestInputVisitorData *data, const void *unused) { UserDefOneList *head = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]"); visit_type_UserDefOneList(v, &head, NULL, &err); g_assert(err); qapi_free_UserDefOneList(head); }
static void test_validate_fail_union_anon(TestInputVisitorData *data, const void *unused) { UserDefAnonUnion *tmp = NULL; Visitor *v; Error *err = NULL; v = validate_test_init(data, "3.14"); visit_type_UserDefAnonUnion(v, &tmp, NULL, &err); g_assert(err); qapi_free_UserDefAnonUnion(tmp); }
static void test_validate_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefTwo *udp = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', " "'dict1': { 'string1': 'string1', " "'dict2': { 'userdef': { 'integer': 42, " "'string': 'string' }, 'string': 'string2'}}}"); visit_type_UserDefTwo(v, NULL, &udp, &error_abort); qapi_free_UserDefTwo(udp); }
static void test_validate_fail_union_native_list(TestInputVisitorData *data, const void *unused) { UserDefNativeListUnion *tmp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'type': 'integer', 'data' : [ 'string' ] }"); visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err); error_free_or_abort(&err); g_assert(!tmp); }
static void test_validate_fail_union_flat_no_discrim(TestInputVisitorData *data, const void *unused) { UserDefFlatUnion2 *tmp = NULL; Error *err = NULL; Visitor *v; /* test situation where discriminator field ('enum1' here) is missing */ v = validate_test_init(data, "{ 'integer': 42, 'string': 'c', 'string1': 'd', 'string2': 'e' }"); visit_type_UserDefFlatUnion2(v, NULL, &tmp, &err); error_free_or_abort(&err); g_assert(!tmp); }
static void test_validate_union_flat(TestInputVisitorData *data, const void *unused) { UserDefFlatUnion *tmp = NULL; Visitor *v; v = validate_test_init(data, "{ 'enum1': 'value1', " "'integer': 41, " "'string': 'str', " "'boolean': true }"); visit_type_UserDefFlatUnion(v, NULL, &tmp, &error_abort); qapi_free_UserDefFlatUnion(tmp); }
static void test_validate_union_flat(TestInputVisitorData *data, const void *unused) { UserDefFlatUnion *tmp = NULL; Visitor *v; Error *err = NULL; v = validate_test_init(data, "{ 'enum1': 'value1', " "'string': 'str', " "'boolean': true }"); /* TODO when generator bug is fixed, add 'integer': 41 */ visit_type_UserDefFlatUnion(v, &tmp, NULL, &err); g_assert(!err); qapi_free_UserDefFlatUnion(tmp); }
static void test_validate_fail_struct_missing(TestInputVisitorData *data, const void *unused) { Error *err = NULL; Visitor *v; QObject *any; GenericAlternate *alt; bool present; int en; int64_t i64; uint32_t u32; int8_t i8; char *str; double dbl; v = validate_test_init(data, "{}"); visit_start_struct(v, NULL, NULL, 0, &error_abort); visit_start_struct(v, "struct", NULL, 0, &err); error_free_or_abort(&err); visit_start_list(v, "list", NULL, 0, &err); error_free_or_abort(&err); visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err); error_free_or_abort(&err); visit_optional(v, "optional", &present); g_assert(!present); visit_type_enum(v, "enum", &en, EnumOne_lookup, &err); error_free_or_abort(&err); visit_type_int(v, "i64", &i64, &err); error_free_or_abort(&err); visit_type_uint32(v, "u32", &u32, &err); error_free_or_abort(&err); visit_type_int8(v, "i8", &i8, &err); error_free_or_abort(&err); visit_type_str(v, "i8", &str, &err); error_free_or_abort(&err); visit_type_number(v, "dbl", &dbl, &err); error_free_or_abort(&err); visit_type_any(v, "any", &any, &err); error_free_or_abort(&err); visit_type_null(v, "null", &err); error_free_or_abort(&err); visit_end_struct(v, NULL); }