d45e07bfaf9f61565995d3abb646d3036f2c3ddf
[sliver-openvswitch.git] / tests / ovsdb-data.at
1 AT_BANNER([OVSDB -- default values])
2
3 OVSDB_CHECK_POSITIVE_CPY([default atoms],
4   [default-atoms],
5   [[integer: OK
6 real: OK
7 boolean: OK
8 string: OK
9 uuid: OK]])
10
11 OVSDB_CHECK_POSITIVE_CPY([default data],
12   [default-data],
13   [[key integer, value void, n_min 0: OK
14 key integer, value integer, n_min 0: OK
15 key integer, value real, n_min 0: OK
16 key integer, value boolean, n_min 0: OK
17 key integer, value string, n_min 0: OK
18 key integer, value uuid, n_min 0: OK
19 key real, value void, n_min 0: OK
20 key real, value integer, n_min 0: OK
21 key real, value real, n_min 0: OK
22 key real, value boolean, n_min 0: OK
23 key real, value string, n_min 0: OK
24 key real, value uuid, n_min 0: OK
25 key boolean, value void, n_min 0: OK
26 key boolean, value integer, n_min 0: OK
27 key boolean, value real, n_min 0: OK
28 key boolean, value boolean, n_min 0: OK
29 key boolean, value string, n_min 0: OK
30 key boolean, value uuid, n_min 0: OK
31 key string, value void, n_min 0: OK
32 key string, value integer, n_min 0: OK
33 key string, value real, n_min 0: OK
34 key string, value boolean, n_min 0: OK
35 key string, value string, n_min 0: OK
36 key string, value uuid, n_min 0: OK
37 key uuid, value void, n_min 0: OK
38 key uuid, value integer, n_min 0: OK
39 key uuid, value real, n_min 0: OK
40 key uuid, value boolean, n_min 0: OK
41 key uuid, value string, n_min 0: OK
42 key uuid, value uuid, n_min 0: OK
43 key integer, value void, n_min 1: OK
44 key integer, value integer, n_min 1: OK
45 key integer, value real, n_min 1: OK
46 key integer, value boolean, n_min 1: OK
47 key integer, value string, n_min 1: OK
48 key integer, value uuid, n_min 1: OK
49 key real, value void, n_min 1: OK
50 key real, value integer, n_min 1: OK
51 key real, value real, n_min 1: OK
52 key real, value boolean, n_min 1: OK
53 key real, value string, n_min 1: OK
54 key real, value uuid, n_min 1: OK
55 key boolean, value void, n_min 1: OK
56 key boolean, value integer, n_min 1: OK
57 key boolean, value real, n_min 1: OK
58 key boolean, value boolean, n_min 1: OK
59 key boolean, value string, n_min 1: OK
60 key boolean, value uuid, n_min 1: OK
61 key string, value void, n_min 1: OK
62 key string, value integer, n_min 1: OK
63 key string, value real, n_min 1: OK
64 key string, value boolean, n_min 1: OK
65 key string, value string, n_min 1: OK
66 key string, value uuid, n_min 1: OK
67 key uuid, value void, n_min 1: OK
68 key uuid, value integer, n_min 1: OK
69 key uuid, value real, n_min 1: OK
70 key uuid, value boolean, n_min 1: OK
71 key uuid, value string, n_min 1: OK
72 key uuid, value uuid, n_min 1: OK]])
73
74 AT_BANNER([OVSDB -- atoms without constraints])
75
76 OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON], 
77   [[parse-atoms '["integer"]' \
78     '[0]' \
79     '[-1]' \
80     '[1e3]' \
81     '[9223372036854775807]' \
82     '[-9223372036854775808]' ]], 
83   [0
84 -1
85 1000
86 9223372036854775807
87 -9223372036854775808])
88
89 OVSDB_CHECK_POSITIVE([integer atom from string], 
90   [[parse-atom-strings -- '["integer"]' \
91     '0' \
92     '-1' \
93     '+1000' \
94     '9223372036854775807' \
95     '-9223372036854775808' ]], 
96   [0
97 -1
98 1000
99 9223372036854775807
100 -9223372036854775808])
101
102 OVSDB_CHECK_POSITIVE_CPY([real atom from JSON], 
103   [[parse-atoms '["real"]' \
104     '[0]' \
105     '[0.0]' \
106     '[-0.0]' \
107     '[-1.25]' \
108     '[1e3]' \
109     '[1e37]' \
110     '[0.00390625]' ]], 
111   [0
112 0
113 0
114 -1.25
115 1000
116 1e+37
117 0.00390625])
118
119 OVSDB_CHECK_POSITIVE([real atom from string], 
120   [[parse-atom-strings -- '["real"]' \
121     '0' \
122     '0.0' \
123     '-0.0' \
124     '-1.25' \
125     '1e3' \
126     '1e37' \
127     '0.00390625' ]], 
128   [0
129 0
130 0
131 -1.25
132 1000
133 1e+37
134 0.00390625])
135
136 OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
137   [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
138   [true
139 false])
140
141 OVSDB_CHECK_POSITIVE([boolean atom from string],
142   [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
143   [true
144 false])
145
146 OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
147   [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
148   [""
149 "true"
150 "\"\\/\b\f\n\r\t"])
151
152 OVSDB_CHECK_POSITIVE([string atom from string],
153   [[parse-atom-strings '["string"]' \
154     'unquoted' \
155     '"quoted-string"' \
156     '"needs quotes"' \
157     '""' \
158     '"true"' \
159     '"\"\\\/\b\f\n\r\t"']],
160   [unquoted
161 quoted-string
162 "needs quotes"
163 ""
164 "true"
165 "\"\\/\b\f\n\r\t"])
166
167 OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON],
168   [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
169   [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
170
171 OVSDB_CHECK_POSITIVE([uuid atom from string],
172   [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
173   [550e8400-e29b-41d4-a716-446655440000])
174
175 OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
176   [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
177   [[[-1,0,1,2,55]]])
178
179 OVSDB_CHECK_POSITIVE_CPY([real atom sorting],
180   [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
181   [[[-1e+99,0,0,1.23,1.25]]])
182
183 OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
184   [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
185   [[[false,false,false,true,true]]])
186
187 OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
188   [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
189   [[["\b","abc","abd","xxx"]]])
190
191 OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting],
192   [[sort-atoms '["uuid"]' '[
193     ["uuid", "00000000-0000-0000-0000-000000000001"],
194     ["uuid", "00000000-1000-0000-0000-000000000000"],
195     ["uuid", "00000000-0000-1000-0000-000000000000"],
196     ["uuid", "00010000-0000-0000-0000-000000000000"],
197     ["uuid", "00000000-0000-0000-0000-000000000100"],
198     ["uuid", "00000000-0000-0000-0000-000100000000"],
199     ["uuid", "00000000-0000-0010-0000-000000000000"],
200     ["uuid", "00000100-0000-0000-0000-000000000000"],
201     ["uuid", "00000000-0000-0001-0000-000000000000"],
202     ["uuid", "00000000-0000-0000-0000-000001000000"],
203     ["uuid", "01000000-0000-0000-0000-000000000000"],
204     ["uuid", "00000000-0000-0000-0000-000000001000"],
205     ["uuid", "00000000-0000-0000-0000-000010000000"],
206     ["uuid", "00000000-0000-0000-0000-010000000000"],
207     ["uuid", "00000000-0000-0100-0000-000000000000"],
208     ["uuid", "10000000-0000-0000-0000-000000000000"],
209     ["uuid", "00000000-0000-0000-0000-000000000010"],
210     ["uuid", "00000000-0100-0000-0000-000000000000"],
211     ["uuid", "00000000-0000-0000-0100-000000000000"],
212     ["uuid", "00000000-0000-0000-0001-000000000000"],
213     ["uuid", "00000010-0000-0000-0000-000000000000"],
214     ["uuid", "00000000-0000-0000-0010-000000000000"],
215     ["uuid", "00000000-0000-0000-0000-000000010000"],
216     ["uuid", "00000000-0000-0000-1000-000000000000"],
217     ["uuid", "00000000-0000-0000-0000-100000000000"],
218     ["uuid", "00000000-0000-0000-0000-001000000000"],
219     ["uuid", "00000000-0000-0000-0000-000000100000"],
220     ["uuid", "00000000-0000-0000-0000-000000000000"],
221     ["uuid", "00000000-0010-0000-0000-000000000000"],
222     ["uuid", "00100000-0000-0000-0000-000000000000"],
223     ["uuid", "00000000-0001-0000-0000-000000000000"],
224     ["uuid", "00000001-0000-0000-0000-000000000000"],
225     ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
226   [[[["uuid","00000000-0000-0000-0000-000000000000"],["uuid","00000000-0000-0000-0000-000000000001"],["uuid","00000000-0000-0000-0000-000000000010"],["uuid","00000000-0000-0000-0000-000000000100"],["uuid","00000000-0000-0000-0000-000000001000"],["uuid","00000000-0000-0000-0000-000000010000"],["uuid","00000000-0000-0000-0000-000000100000"],["uuid","00000000-0000-0000-0000-000001000000"],["uuid","00000000-0000-0000-0000-000010000000"],["uuid","00000000-0000-0000-0000-000100000000"],["uuid","00000000-0000-0000-0000-001000000000"],["uuid","00000000-0000-0000-0000-010000000000"],["uuid","00000000-0000-0000-0000-100000000000"],["uuid","00000000-0000-0000-0001-000000000000"],["uuid","00000000-0000-0000-0010-000000000000"],["uuid","00000000-0000-0000-0100-000000000000"],["uuid","00000000-0000-0000-1000-000000000000"],["uuid","00000000-0000-0001-0000-000000000000"],["uuid","00000000-0000-0010-0000-000000000000"],["uuid","00000000-0000-0100-0000-000000000000"],["uuid","00000000-0000-1000-0000-000000000000"],["uuid","00000000-0001-0000-0000-000000000000"],["uuid","00000000-0010-0000-0000-000000000000"],["uuid","00000000-0100-0000-0000-000000000000"],["uuid","00000000-1000-0000-0000-000000000000"],["uuid","00000001-0000-0000-0000-000000000000"],["uuid","00000010-0000-0000-0000-000000000000"],["uuid","00000100-0000-0000-0000-000000000000"],["uuid","00001000-0000-0000-0000-000000000000"],["uuid","00010000-0000-0000-0000-000000000000"],["uuid","00100000-0000-0000-0000-000000000000"],["uuid","01000000-0000-0000-0000-000000000000"],["uuid","10000000-0000-0000-0000-000000000000"]]]])
227
228 OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom],
229   [[parse-atoms '["integer"]' '[0.5]' ]],
230   [syntax "0.5": syntax error: expected integer])
231
232 dnl <C0> is not allowed anywhere in a UTF-8 string.
233 dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
234 OVSDB_CHECK_POSITIVE_CPY([no invalid UTF-8 sequences in strings],
235   [parse-atoms '[["string"]]' \
236      '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
237      '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \
238 ],
239   [constraint violation: "m4_esyscmd([printf "\300"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
240 constraint violation: "m4_esyscmd([printf "\355\240\200"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0],
241   [], [], [xfail])
242
243 OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
244   [[parse-atom-strings '["integer"]' '0.5' ]],
245   ["0.5" is not a valid integer])
246
247 OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
248   [[parse-atoms '["boolean"]' '["true"]' ]],
249   [syntax ""true"": syntax error: expected boolean])
250
251 OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean string atom],
252   [[parse-atom-strings '["boolean"]' '"true"' ]],
253   [""true"" is not a valid boolean (use "true" or "false")])
254
255 OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
256   [[parse-atoms '["string"]' '[1]']],
257   [syntax "1": syntax error: expected string])
258
259 OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
260   [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
261   [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
262
263 OVSDB_CHECK_POSITIVE_CPY([named-uuid requires symbol table],
264   [parse-atoms '[["uuid"]]' '[["named-uuid", "x"]]'],
265   [[syntax "["named-uuid","x"]": syntax error: expected ["uuid", <string>]]])
266
267 OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
268   [[parse-atom-strings '["string"]' '']],
269   [An empty string is not valid as input; use "" to represent the empty string])
270
271 OVSDB_CHECK_NEGATIVE([quotes must be balanced],
272   [parse-atom-strings '[["string"]]' '"asdf'],
273   ["asdf: missing quote at end of quoted string])
274
275 OVSDB_CHECK_NEGATIVE([uuids must be valid],
276   [parse-atom-strings '[["uuid"]]' '1234-5678'],
277   ["1234-5678" is not a valid UUID])
278 \f
279 AT_BANNER([OVSDB -- atoms with enum constraints])
280
281 OVSDB_CHECK_POSITIVE_CPY([integer atom enum], 
282   [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
283     '[0]' \
284     '[1]' \
285     '[2]' \
286     '[3]' \
287     '[6]' \
288     '[7]' \
289     '[8]' \
290     '[9]' \
291     '[10]' \
292     '[11]']], 
293   [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
294 1
295 constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
296 constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
297 6
298 constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
299 8
300 constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
301 10
302 constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
303
304 OVSDB_CHECK_POSITIVE_CPY([real atom enum], 
305   [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
306     '[-2]' \
307     '[-1]' \
308     '[-1.5]' \
309     '[0]' \
310     '[1]' \
311     '[1.5]' \
312     '[2]']], 
313   [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
314 constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
315 -1.5
316 constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
317 constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
318 1.5
319 constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
320
321 OVSDB_CHECK_POSITIVE_CPY([boolean atom enum], 
322   [[parse-atoms '[{"type": "boolean", "enum": false}]' \
323     '[false]' \
324     '[true]']], 
325   [[false
326 constraint violation: true is not one of the allowed values ([false])]])
327
328 OVSDB_CHECK_POSITIVE_CPY([string atom enum], 
329   [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
330     '[""]' \
331     '["ab"]' \
332     '["abc"]' \
333     '["def"]' \
334     '["defg"]' \
335     '["DEF"]']], 
336   [[constraint violation: "" is not one of the allowed values ([abc, def])
337 constraint violation: ab is not one of the allowed values ([abc, def])
338 "abc"
339 "def"
340 constraint violation: defg is not one of the allowed values ([abc, def])
341 constraint violation: DEF is not one of the allowed values ([abc, def])]])
342
343 OVSDB_CHECK_POSITIVE_CPY([uuid atom enum], 
344   [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
345     '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
346     '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
347     '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']], 
348   [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
349 ["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
350 constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])
351 \f
352 AT_BANNER([OVSDB -- atoms with other constraints])
353
354 OVSDB_CHECK_POSITIVE_CPY([integers >= 5], 
355   [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
356     '[0]' \
357     '[4]' \
358     '[5]' \
359     '[6]' \
360     '[12345]']], 
361   [constraint violation: 0 is less than minimum allowed value 5
362 constraint violation: 4 is less than minimum allowed value 5
363 5
364 6
365 12345])
366
367 OVSDB_CHECK_POSITIVE_CPY([integers <= -1], 
368   [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
369     '[0]' \
370     '[-1]' \
371     '[-2]' \
372     '[-123]']], 
373   [constraint violation: 0 is greater than maximum allowed value -1
374 -1
375 -2
376 -123])
377
378 OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10], 
379   [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
380     '[-20]' \
381     '[-11]' \
382     '[-10]' \
383     '[-9]' \
384     '[1]' \
385     '[9]' \
386     '[10]' \
387     '[11]' \
388     '[123576]']], 
389   [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
390 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
391 -10
392 -9
393 1
394 9
395 10
396 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
397 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
398
399 OVSDB_CHECK_POSITIVE_CPY([reals >= 5], 
400   [[parse-atoms '[{"type": "real", "minReal": 5}]' \
401     '[0]' \
402     '[4]' \
403     '[5]' \
404     '[6]' \
405     '[12345]']], 
406   [constraint violation: 0 is less than minimum allowed value 5
407 constraint violation: 4 is less than minimum allowed value 5
408 5
409 6
410 12345])
411
412 OVSDB_CHECK_POSITIVE_CPY([reals <= -1], 
413   [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
414     '[0]' \
415     '[-1]' \
416     '[-2]' \
417     '[-123]']], 
418   [constraint violation: 0 is greater than maximum allowed value -1
419 -1
420 -2
421 -123])
422
423 OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10], 
424   [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
425     '[-20]' \
426     '[-11]' \
427     '[-10]' \
428     '[-9]' \
429     '[1]' \
430     '[9]' \
431     '[10]' \
432     '[11]' \
433     '[123576]']], 
434   [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
435 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
436 -10
437 -9
438 1
439 9
440 10
441 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
442 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
443
444 OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
445   [[parse-atoms '{"type": "string", "minLength": 2}' \
446     '[""]' \
447     '["a"]' \
448     '["ab"]' \
449     '["abc"]' \
450     '["\ud834\udd1e"]']],
451   [[constraint violation: "" length 0 is less than minimum allowed length 2
452 constraint violation: "a" length 1 is less than minimum allowed length 2
453 "ab"
454 "abc"
455 constraint violation: "𝄞" length 1 is less than minimum allowed length 2]],
456   [], [], [xfail])
457
458 OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
459   [[parse-atoms '{"type": "string", "maxLength": 2}' \
460     '[""]' \
461     '["a"]' \
462     '["ab"]' \
463     '["abc"]' \
464     '["de"]']],
465   [[""
466 "a"
467 "ab"
468 constraint violation: "abc" length 3 is greater than maximum allowed length 2
469 "de"]])
470
471 AT_BANNER([OSVDB -- simple data])
472
473 OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
474   [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
475   [0
476 1
477 -1])
478
479 OVSDB_CHECK_POSITIVE([integer string datum],
480   [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
481   [0
482 1
483 -1
484 1])
485
486 OVSDB_CHECK_POSITIVE_CPY([real JSON datum], 
487   [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
488   [0
489 1
490 -1.25])
491
492 OVSDB_CHECK_POSITIVE([real string datum], 
493   [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
494   [0
495 1
496 -1.25])
497
498 OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
499   [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
500   [true
501 false])
502
503 OVSDB_CHECK_POSITIVE([boolean string datum],
504   [[parse-data-strings '["boolean"]' 'true' 'false' ]],
505   [true
506 false])
507
508 OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
509   [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
510   [""
511 "true"
512 "\"\\/\b\f\n\r\t"])
513
514 OVSDB_CHECK_POSITIVE([string string datum],
515   [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
516   [x
517 ""
518 "true"
519 "\"\\/\b\f\n\r\t"])
520 \f
521 AT_BANNER([OVSDB -- set data])
522
523 OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
524   [[parse-data '{"key": "boolean", "min": 0}' \
525     '[true]' \
526     '["set", [false]]' \
527     '["set", []]']], 
528   [[true
529 false
530 ["set",[]]]],
531   [set])
532
533 OVSDB_CHECK_POSITIVE([string optional boolean],
534   [[parse-data-strings '{"key": "boolean", "min": 0}' \
535     'true' \
536     'false' \
537     '[]']], 
538   [[true
539 false
540 []]],
541   [set])
542
543 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
544   [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
545     '["set", [0]]' \
546     '[1]' \
547     '["set", [0, 1]]' \
548     '["set", [0, 1, 2]]' \
549     '["set", [0, 1, 2, 3, 4, 5]]' \
550     '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
551     '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
552   [[0
553 1
554 ["set",[0,1]]
555 ["set",[0,1,2]]
556 ["set",[0,1,2,3,4,5]]
557 ["set",[0,1,2,3,4,5,6,7,8]]
558 ["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
559
560 OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
561   [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
562     '0' \
563     '0,1' \
564     '0, 1, 2' \
565     '[0, 1,2, 3, 4, 5]' \
566     '0, 1,2, 3,4, 5, 6, 7, 8' \
567     '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']],
568   [[[0]
569 [0, 1]
570 [0, 1, 2]
571 [0, 1, 2, 3, 4, 5]
572 [0, 1, 2, 3, 4, 5, 6, 7, 8]
573 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
574
575 OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
576   [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
577     '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
578     '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
579     '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
580               ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
581               ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
582   [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
583 ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
584 ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
585
586 OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
587   [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
588     '[550e8400-e29b-41d4-a716-446655440000]' \
589     '[c5051240-30ff-43ed-b4b9-93cf3f050813,
590       90558331-09af-4d2f-a572-509cad2e9088,
591       550e8400-e29b-41d4-a716-446655440000]']],
592   [[[550e8400-e29b-41d4-a716-446655440000]
593 [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
594
595 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
596   [[parse-data '{"key": "string", "min": 0, "max": 3}' \
597     '["set", []]' \
598     '["a longer string"]' \
599     '["set", ["a relatively long string"]]' \
600     '["set", ["short string", "a relatively long string"]]' \
601     '["set", ["zzz", "short string", "a relatively long string"]]']],
602   [[["set",[]]
603 "a longer string"
604 "a relatively long string"
605 ["set",["a relatively long string","short string"]]
606 ["set",["a relatively long string","short string","zzz"]]]])
607
608 OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
609   [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
610     '[]' \
611     '"a relatively long string"' \
612     '["short string", "a relatively long string"]' \
613     '"zzz","short string","a relatively long string"']],
614   [[[]
615 ["a relatively long string"]
616 ["a relatively long string", "short string"]
617 ["a relatively long string", "short string", zzz]]])
618
619 OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
620   [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
621   [ovsdb error: set contains duplicate])
622
623 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
624   [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
625   [set contains duplicate value])
626
627 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
628   [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
629   [ovsdb error: set contains duplicate])
630
631 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
632   [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
633   [set contains duplicate value])
634
635 OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
636   [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
637   [ovsdb error: set contains duplicate])
638
639 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
640   [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
641   [set contains duplicate value])
642
643 OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
644   [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
645   [ovsdb error: set contains duplicate])
646
647 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
648   [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
649   [set contains duplicate value])
650
651 OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
652   [[parse-data '{"key": "uuid", "max": 5}' \
653     '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
654               ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
655               ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
656   [ovsdb error: set contains duplicate])
657
658 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
659   [[parse-data-strings '{"key": "uuid", "max": 5}' \
660     '7ef21525-0088-4a28-a418-5518413e43ea,
661      355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
662      7ef21525-0088-4a28-a418-5518413e43ea']],
663   [set contains duplicate value])
664 \f
665 AT_BANNER([OVSDB -- map data])
666
667 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
668   [[parse-data '{"key": "integer", "value": "boolean"}' \
669     '["map", [[1, true]]]']],
670   [[["map",[[1,true]]]]])
671
672 OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
673   [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
674     '1=true']],
675   [[1=true]])
676
677 OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
678   [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
679     '["map", [[1, true]]]' \
680     '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
681     '["map", [[3, false], [0, true], [4, false]]]']],
682   [[["map",[[1,true]]]
683 ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
684 ["map",[[0,true],[3,false],[4,false]]]]])
685
686 OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
687   [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
688     '1=true' \
689     '0=true 1=false 2=true, 3=true 4=true,' \
690     '3=false,0=true ,4=false']],
691   [[{1=true}
692 {0=true, 1=false, 2=true, 3=true, 4=true}
693 {0=true, 3=false, 4=false}]])
694
695 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
696  [[parse-data '{"key": "boolean", "value": "integer"}' \
697    '["map", [[true, 1]]]']],
698  [[["map",[[true,1]]]]])
699
700 OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
701  [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
702    'true=1']],
703  [[true=1]])
704
705 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
706   [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
707     '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
708               [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
709               [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
710               [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
711               [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
712   [[["map",[[["uuid","1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"],5],[["uuid","25bfa475-d072-4f60-8be1-00f48643e9cb"],4],[["uuid","6b94b968-2702-4f64-9457-314a34d69b8c"],2],[["uuid","cad8542b-6ee1-486b-971b-7dcbf6e14979"],1],[["uuid","d2c4a168-24de-47eb-a8a3-c1abfc814979"],3]]]]])
713
714 OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
715   [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
716     'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
717      6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
718      d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
719      25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
720      1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
721   [[{1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5, 25bfa475-d072-4f60-8be1-00f48643e9cb=4, 6b94b968-2702-4f64-9457-314a34d69b8c=2, cad8542b-6ee1-486b-971b-7dcbf6e14979=1, d2c4a168-24de-47eb-a8a3-c1abfc814979=3}]])
722
723 OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
724   [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
725     '["map", [["2 gills", "1 chopin"],
726               ["2 chopins", "1 pint"],
727               ["2 pints", "1 quart"],
728               ["2 quarts", "1 pottle"],
729               ["2 pottles", "1 gallon"],
730               ["2 gallons", "1 peck"],
731               ["2 pecks", "1 demibushel"],
732               ["2 demibushel", "1 firkin"],
733               ["2 firkins", "1 kilderkin"],
734               ["2 kilderkins", "1 barrel"]]]']],
735    [[["map",[["2 chopins","1 pint"],["2 demibushel","1 firkin"],["2 firkins","1 kilderkin"],["2 gallons","1 peck"],["2 gills","1 chopin"],["2 kilderkins","1 barrel"],["2 pecks","1 demibushel"],["2 pints","1 quart"],["2 pottles","1 gallon"],["2 quarts","1 pottle"]]]]])
736
737 OVSDB_CHECK_POSITIVE([string map of 10 string to string],
738   [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
739     '{"2 gills"="1 chopin",
740       "2 chopins"= "1 pint",
741       "2 pints"= "1 quart",
742       "2 quarts"= "1 pottle",
743       "2 pottles"= "1 gallon",
744       "2 gallons"= "1 peck",
745       "2 pecks"= "1 demibushel",
746       "2 demibushel"= "1 firkin",
747       "2 firkins"= "1 kilderkin",
748       "2 kilderkins"= "1 barrel"}']],
749    [[{"2 chopins"="1 pint", "2 demibushel"="1 firkin", "2 firkins"="1 kilderkin", "2 gallons"="1 peck", "2 gills"="1 chopin", "2 kilderkins"="1 barrel", "2 pecks"="1 demibushel", "2 pints"="1 quart", "2 pottles"="1 gallon", "2 quarts"="1 pottle"}]])
750
751 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
752   [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
753     '["map", [[1, true], [2, false], [1, false]]]']],
754   [ovsdb error: map contains duplicate key])
755
756 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
757   [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
758     '1=true 2=false 1=false']],
759   [map contains duplicate key])