Lines Matching +full:src +full:-

2  * QAPI Clone Visitor unit-tests.
7 * See the COPYING file in the top-level directory.
12 #include "qapi/clone-visitor.h"
13 #include "test-qapi-visit.h"
17 UserDefOne *src, *dst; in test_clone_struct() local
19 src = g_new0(UserDefOne, 1); in test_clone_struct()
20 src->integer = 42; in test_clone_struct()
21 src->string = g_strdup("Hello"); in test_clone_struct()
22 src->has_enum1 = false; in test_clone_struct()
23 src->enum1 = ENUM_ONE_VALUE2; in test_clone_struct()
25 dst = QAPI_CLONE(UserDefOne, src); in test_clone_struct()
27 g_assert_cmpint(dst->integer, ==, 42); in test_clone_struct()
28 g_assert(dst->string != src->string); in test_clone_struct()
29 g_assert_cmpstr(dst->string, ==, "Hello"); in test_clone_struct()
30 g_assert_cmpint(dst->has_enum1, ==, false); in test_clone_struct()
32 g_assert_cmpint(dst->enum1, ==, ENUM_ONE_VALUE2); in test_clone_struct()
35 qapi_free_UserDefOne(src); in test_clone_struct()
44 b_src->type = QTYPE_QBOOL; in test_clone_alternate()
45 b_src->u.b = true; in test_clone_alternate()
47 s_src->type = QTYPE_QSTRING; in test_clone_alternate()
48 s_src->u.e = ENUM_ONE_VALUE1; in test_clone_alternate()
52 g_assert_cmpint(b_dst->type, ==, b_src->type); in test_clone_alternate()
53 g_assert_cmpint(b_dst->u.b, ==, b_src->u.b); in test_clone_alternate()
56 g_assert_cmpint(s_dst->type, ==, s_src->type); in test_clone_alternate()
57 g_assert_cmpint(s_dst->u.e, ==, s_src->u.e); in test_clone_alternate()
67 uint8List *src = NULL, *dst; in test_clone_list() local
72 for (i = 10; i; i--) { in test_clone_list()
73 QAPI_LIST_PREPEND(src, i); in test_clone_list()
76 dst = QAPI_CLONE(uint8List, src); in test_clone_list()
79 g_assert_cmpint(tmp->value, ==, i); in test_clone_list()
80 tmp = tmp->next; in test_clone_list()
84 qapi_free_uint8List(src); in test_clone_list()
90 Empty2 *src, *dst; in test_clone_empty() local
92 src = g_new0(Empty2, 1); in test_clone_empty()
93 dst = QAPI_CLONE(Empty2, src); in test_clone_empty()
95 qapi_free_Empty2(src); in test_clone_empty()
101 UserDefFlatUnion *src, *dst; in test_clone_complex1() local
103 src = g_new0(UserDefFlatUnion, 1); in test_clone_complex1()
104 src->integer = 123; in test_clone_complex1()
105 src->string = g_strdup("abc"); in test_clone_complex1()
106 src->enum1 = ENUM_ONE_VALUE1; in test_clone_complex1()
107 src->u.value1.boolean = true; in test_clone_complex1()
109 dst = QAPI_CLONE(UserDefFlatUnion, src); in test_clone_complex1()
112 g_assert_cmpint(dst->integer, ==, 123); in test_clone_complex1()
113 g_assert_cmpstr(dst->string, ==, "abc"); in test_clone_complex1()
114 g_assert_cmpint(dst->enum1, ==, ENUM_ONE_VALUE1); in test_clone_complex1()
115 g_assert(dst->u.value1.boolean); in test_clone_complex1()
116 g_assert(!dst->u.value1.has_a_b); in test_clone_complex1()
117 g_assert_cmpint(dst->u.value1.a_b, ==, 0); in test_clone_complex1()
119 qapi_free_UserDefFlatUnion(src); in test_clone_complex1()
125 WrapAlternate *src, *dst; in test_clone_complex2() local
127 src = g_new0(WrapAlternate, 1); in test_clone_complex2()
128 src->alt = g_new(UserDefAlternate, 1); in test_clone_complex2()
129 src->alt->type = QTYPE_QDICT; in test_clone_complex2()
130 src->alt->u.udfu.integer = 42; in test_clone_complex2()
132 src->alt->u.udfu.string = NULL; in test_clone_complex2()
133 src->alt->u.udfu.enum1 = ENUM_ONE_VALUE3; in test_clone_complex2()
134 src->alt->u.udfu.u.value3.intb = 99; in test_clone_complex2()
135 src->alt->u.udfu.u.value3.has_a_b = true; in test_clone_complex2()
136 src->alt->u.udfu.u.value3.a_b = true; in test_clone_complex2()
138 dst = QAPI_CLONE(WrapAlternate, src); in test_clone_complex2()
140 g_assert(dst->alt); in test_clone_complex2()
141 g_assert_cmpint(dst->alt->type, ==, QTYPE_QDICT); in test_clone_complex2()
142 g_assert_cmpint(dst->alt->u.udfu.integer, ==, 42); in test_clone_complex2()
143 g_assert_cmpstr(dst->alt->u.udfu.string, ==, ""); in test_clone_complex2()
144 g_assert_cmpint(dst->alt->u.udfu.enum1, ==, ENUM_ONE_VALUE3); in test_clone_complex2()
145 g_assert_cmpint(dst->alt->u.udfu.u.value3.intb, ==, 99); in test_clone_complex2()
146 g_assert_cmpint(dst->alt->u.udfu.u.value3.has_a_b, ==, true); in test_clone_complex2()
147 g_assert_cmpint(dst->alt->u.udfu.u.value3.a_b, ==, true); in test_clone_complex2()
149 qapi_free_WrapAlternate(src); in test_clone_complex2()
155 UserDefOneList *src, *dst, *tail; in test_clone_complex3() local
158 src = NULL; in test_clone_complex3()
160 elt->integer = 3; in test_clone_complex3()
161 elt->string = g_strdup("three"); in test_clone_complex3()
162 elt->has_enum1 = true; in test_clone_complex3()
163 elt->enum1 = ENUM_ONE_VALUE3; in test_clone_complex3()
164 QAPI_LIST_PREPEND(src, elt); in test_clone_complex3()
166 elt->integer = 2; in test_clone_complex3()
167 elt->string = g_strdup("two"); in test_clone_complex3()
168 QAPI_LIST_PREPEND(src, elt); in test_clone_complex3()
170 elt->integer = 1; in test_clone_complex3()
171 elt->string = g_strdup("one"); in test_clone_complex3()
172 QAPI_LIST_PREPEND(src, elt); in test_clone_complex3()
174 dst = QAPI_CLONE(UserDefOneList, src); in test_clone_complex3()
178 elt = tail->value; in test_clone_complex3()
179 g_assert_cmpint(elt->integer, ==, 1); in test_clone_complex3()
180 g_assert_cmpstr(elt->string, ==, "one"); in test_clone_complex3()
181 g_assert(!elt->has_enum1); in test_clone_complex3()
182 tail = tail->next; in test_clone_complex3()
183 elt = tail->value; in test_clone_complex3()
184 g_assert_cmpint(elt->integer, ==, 2); in test_clone_complex3()
185 g_assert_cmpstr(elt->string, ==, "two"); in test_clone_complex3()
186 g_assert(!elt->has_enum1); in test_clone_complex3()
187 tail = tail->next; in test_clone_complex3()
188 elt = tail->value; in test_clone_complex3()
189 g_assert_cmpint(elt->integer, ==, 3); in test_clone_complex3()
190 g_assert_cmpstr(elt->string, ==, "three"); in test_clone_complex3()
191 g_assert(elt->has_enum1); in test_clone_complex3()
192 g_assert_cmpint(elt->enum1, ==, ENUM_ONE_VALUE3); in test_clone_complex3()
193 g_assert(!tail->next); in test_clone_complex3()
195 qapi_free_UserDefOneList(src); in test_clone_complex3()