Skip to content

Commit 2766cdf

Browse files
committed
tests REFACTOR shorten YANG module
1 parent 2234fde commit 2766cdf

File tree

1 file changed

+83
-232
lines changed

1 file changed

+83
-232
lines changed

tests/utests/data/test_diff.c

Lines changed: 83 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -59,248 +59,99 @@
5959
lyd_free_all(diff2);\
6060
}
6161

62-
const char *schema1 =
63-
"module defaults {\n"
64-
" yang-version 1.1;\n"
65-
" namespace \"urn:libyang:tests:defaults\";\n"
66-
" prefix df;\n"
62+
const char *schema =
63+
"module defaults {"
64+
"yang-version 1.1;"
65+
"namespace \"urn:libyang:tests:defaults\";"
66+
"prefix df;"
6767
""
68-
" feature unhide;\n"
68+
"feature unhide;"
6969
""
70-
" typedef defint32 {\n"
71-
" type int32;\n"
72-
" default \"42\";\n"
73-
" }\n"
70+
"typedef defint32 {type int32; default \"42\";}"
7471
""
75-
" leaf hiddenleaf {\n"
76-
" if-feature \"unhide\";\n"
77-
" type int32;\n"
78-
" default \"42\";\n"
79-
" }\n"
80-
""
81-
" container df {\n"
82-
" leaf foo {\n"
83-
" type defint32;\n"
84-
" }\n"
85-
""
86-
" leaf hiddenleaf {\n"
87-
" if-feature \"unhide\";\n"
88-
" type int32;\n"
89-
" default \"42\";\n"
90-
" }\n"
91-
""
92-
" container bar {\n"
93-
" presence \"\";\n"
94-
" leaf hi {\n"
95-
" type int32;\n"
96-
" default \"42\";\n"
97-
" }\n"
98-
""
99-
" leaf ho {\n"
100-
" type int32;\n"
101-
" mandatory true;\n"
102-
" }\n"
103-
" }\n"
104-
""
105-
" leaf-list llist {\n"
106-
" type defint32;\n"
107-
" ordered-by user;\n"
108-
" }\n"
109-
""
110-
" list ul {\n"
111-
" key \"l1\";\n"
112-
" ordered-by user;\n"
113-
" leaf l1 {\n"
114-
" type string;\n"
115-
" }\n"
116-
""
117-
" leaf l2 {\n"
118-
" type int32;\n"
119-
" }\n"
120-
""
121-
" container cont {\n"
122-
" leaf l3 {\n"
123-
" type string;\n"
124-
" }\n"
125-
" }\n"
126-
" }\n"
127-
""
128-
" leaf-list dllist {\n"
129-
" type uint8;\n"
130-
" default \"1\";\n"
131-
" default \"2\";\n"
132-
" default \"3\";\n"
133-
" }\n"
134-
""
135-
" list list {\n"
136-
" key \"name\";\n"
137-
" leaf name {\n"
138-
" type string;\n"
139-
" }\n"
140-
""
141-
" leaf value {\n"
142-
" type int32;\n"
143-
" default \"42\";\n"
144-
" }\n"
145-
" list list2 {\n"
146-
" key \"name2\";\n"
147-
" leaf name2 {\n"
148-
" type string;\n"
149-
" }\n"
150-
" leaf value2 {\n"
151-
" type int32;\n"
152-
" }\n"
153-
" }\n"
154-
" }\n";
155-
const char *schema2 =
156-
" choice select {\n"
157-
" default \"a\";\n"
158-
" case a {\n"
159-
" choice a {\n"
160-
" leaf a1 {\n"
161-
" type int32;\n"
162-
" default \"42\";\n"
163-
" }\n"
164-
""
165-
" leaf a2 {\n"
166-
" type int32;\n"
167-
" default \"24\";\n"
168-
" }\n"
169-
" }\n"
170-
" }\n"
171-
""
172-
" leaf b {\n"
173-
" type string;\n"
174-
" }\n"
175-
""
176-
" container c {\n"
177-
" presence \"\";\n"
178-
" leaf x {\n"
179-
" type int32;\n"
180-
" default \"42\";\n"
181-
" }\n"
182-
" }\n"
183-
" }\n"
184-
""
185-
" choice select2 {\n"
186-
" default \"s2b\";\n"
187-
" leaf s2a {\n"
188-
" type int32;\n"
189-
" default \"42\";\n"
190-
" }\n"
191-
""
192-
" case s2b {\n"
193-
" choice s2b {\n"
194-
" default \"b1\";\n"
195-
" case b1 {\n"
196-
" leaf b1_1 {\n"
197-
" type int32;\n"
198-
" default \"42\";\n"
199-
" }\n"
200-
""
201-
" leaf b1_2 {\n"
202-
" type string;\n"
203-
" }\n"
204-
""
205-
" leaf b1_status {\n"
206-
" type int32;\n"
207-
" default \"42\";\n"
208-
" config false;\n"
209-
" }\n"
210-
" }\n"
211-
""
212-
" leaf b2 {\n"
213-
" type int32;\n"
214-
" default \"42\";\n"
215-
" }\n"
216-
" }\n"
217-
" }\n"
218-
" }\n"
219-
" list kl {\n"
220-
" config \"false\";\n"
221-
" leaf l1 {\n"
222-
" type string;\n"
223-
" }\n"
224-
""
225-
" leaf l2 {\n"
226-
" type int32;\n"
227-
" }\n"
228-
" }\n"
229-
""
230-
" leaf-list kll {\n"
231-
" config \"false\";\n"
232-
" type string;\n"
233-
" }\n"
234-
" }\n"
235-
""
236-
" container hidden {\n"
237-
" leaf foo {\n"
238-
" type int32;\n"
239-
" default \"42\";\n"
240-
" }\n"
241-
""
242-
" leaf baz {\n"
243-
" type int32;\n"
244-
" default \"42\";\n"
245-
" }\n"
246-
""
247-
" leaf papa {\n"
248-
" type int32;\n"
249-
" default \"42\";\n"
250-
" config false;\n"
251-
" }\n"
252-
" }\n"
253-
""
254-
" rpc rpc1 {\n"
255-
" input {\n"
256-
" leaf inleaf1 {\n"
257-
" type string;\n"
258-
" }\n"
259-
""
260-
" leaf inleaf2 {\n"
261-
" type string;\n"
262-
" default \"def1\";\n"
263-
" }\n"
264-
" }\n"
265-
""
266-
" output {\n"
267-
" leaf outleaf1 {\n"
268-
" type string;\n"
269-
" default \"def2\";\n"
270-
" }\n"
271-
""
272-
" leaf outleaf2 {\n"
273-
" type string;\n"
274-
" }\n"
275-
" }\n"
276-
" }\n"
277-
""
278-
" notification notif {\n"
279-
" leaf ntfleaf1 {\n"
280-
" type string;\n"
281-
" default \"def3\";\n"
282-
" }\n"
283-
""
284-
" leaf ntfleaf2 {\n"
285-
" type string;\n"
286-
" }\n"
287-
" }\n"
288-
"}\n";
72+
"leaf hiddenleaf {if-feature \"unhide\"; type int32; default \"42\";}"
73+
"container df {"
74+
" leaf foo {type defint32; }"
75+
" leaf hiddenleaf {if-feature \"unhide\"; type int32; default \"42\";}"
76+
" container bar { presence \"\";"
77+
" leaf hi {type int32; default \"42\";}"
78+
" leaf ho {type int32; mandatory true;}"
79+
" }"
80+
" leaf-list llist {type defint32; ordered-by user;}"
81+
" list ul {key \"l1\"; ordered-by user;"
82+
" leaf l1 {type string;}"
83+
" leaf l2 {type int32;}"
84+
" container cont {"
85+
" leaf l3 {type string;}"
86+
" }"
87+
" }"
88+
" leaf-list dllist {type uint8; default \"1\"; default \"2\"; default \"3\";}"
89+
" list list {key \"name\";"
90+
" leaf name {type string;}"
91+
" leaf value {type int32; default \"42\";}"
92+
" list list2 {key \"name2\";"
93+
" leaf name2 {type string;}"
94+
" leaf value2 {type int32;}"
95+
" }"
96+
" }"
97+
" choice select {default \"a\";"
98+
" case a {"
99+
" choice a {"
100+
" leaf a1 {type int32; default \"42\";}"
101+
" leaf a2 {type int32; default \"24\";}"
102+
" }"
103+
" }"
104+
" leaf b {type string;}"
105+
" container c {presence \"\";"
106+
" leaf x {type int32; default \"42\";}"
107+
" }"
108+
" }"
109+
" choice select2 {default \"s2b\";"
110+
" leaf s2a {type int32; default \"42\";}"
111+
" case s2b {"
112+
" choice s2b {default \"b1\";"
113+
" case b1 {"
114+
" leaf b1_1 {type int32; default \"42\";}"
115+
" leaf b1_2 {type string;}"
116+
" leaf b1_status {type int32; default \"42\"; config false;}"
117+
" }"
118+
" leaf b2 {type int32; default \"42\";}"
119+
" }"
120+
" }"
121+
" }"
122+
" list kl {config \"false\";"
123+
" leaf l1 {type string;}"
124+
" leaf l2 {type int32;}"
125+
" }"
126+
" leaf-list kll {config \"false\"; type string;}"
127+
"}"
128+
"container hidden {"
129+
" leaf foo {type int32; default \"42\";}"
130+
" leaf baz {type int32; default \"42\";}"
131+
" leaf papa {type int32; default \"42\"; config false;}"
132+
"}"
133+
"rpc rpc1 {"
134+
" input {"
135+
" leaf inleaf1 {type string;}"
136+
" leaf inleaf2 {type string; default \"def1\";}"
137+
" }"
138+
" output {"
139+
" leaf outleaf1 {type string; default \"def2\";}"
140+
" leaf outleaf2 {type string;}"
141+
" }"
142+
"}"
143+
"notification notif {"
144+
" leaf ntfleaf1 {type string; default \"def3\";}"
145+
" leaf ntfleaf2 {type string;}"
146+
"}"
147+
"}";
289148

290149
static int
291150
setup(void **state)
292151
{
293-
char *schema;
294-
295152
UTEST_SETUP;
296153

297-
/* create one schema, longer than 4095 chars */
298-
schema = malloc(strlen(schema1) + strlen(schema2) + 1);
299-
strcpy(schema, schema1);
300-
strcat(schema, schema2);
301-
302154
UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
303-
free(schema);
304155

305156
return 0;
306157
}

0 commit comments

Comments
 (0)