]>
Commit | Line | Data |
---|---|---|
958ac03a BP |
1 | AT_BANNER([OVSDB -- default values]) |
2 | ||
99155935 | 3 | OVSDB_CHECK_POSITIVE_CPY([default atoms], |
958ac03a BP |
4 | [default-atoms], |
5 | [[integer: OK | |
6 | real: OK | |
7 | boolean: OK | |
8 | string: OK | |
9 | uuid: OK]]) | |
10 | ||
99155935 | 11 | OVSDB_CHECK_POSITIVE_CPY([default data], |
958ac03a BP |
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 | ||
bd76d25d | 74 | AT_BANNER([OVSDB -- atoms without constraints]) |
f85f8ebb | 75 | |
99155935 | 76 | OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON], |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 102 | OVSDB_CHECK_POSITIVE_CPY([real atom from JSON], |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 136 | OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON], |
f85f8ebb BP |
137 | [[parse-atoms '["boolean"]' '[true]' '[false]' ]], |
138 | [true | |
139 | false]) | |
140 | ||
5c414a2e BP |
141 | OVSDB_CHECK_POSITIVE([boolean atom from string], |
142 | [[parse-atom-strings '["boolean"]' 'true' 'false' ]], | |
143 | [true | |
144 | false]) | |
145 | ||
99155935 | 146 | OVSDB_CHECK_POSITIVE_CPY([string atom from JSON], |
f85f8ebb BP |
147 | [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']], |
148 | ["" | |
149 | "true" | |
150 | "\"\\/\b\f\n\r\t"]) | |
151 | ||
5c414a2e BP |
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 | ||
99155935 | 167 | OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON], |
f85f8ebb BP |
168 | [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']], |
169 | [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]]) | |
170 | ||
5c414a2e BP |
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 | ||
99155935 | 175 | OVSDB_CHECK_POSITIVE_CPY([integer atom sorting], |
f85f8ebb BP |
176 | [[sort-atoms '["integer"]' '[55,0,-1,2,1]']], |
177 | [[[-1,0,1,2,55]]]) | |
178 | ||
99155935 | 179 | OVSDB_CHECK_POSITIVE_CPY([real atom sorting], |
f85f8ebb BP |
180 | [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']], |
181 | [[[-1e+99,0,0,1.23,1.25]]]) | |
182 | ||
99155935 | 183 | OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting], |
f85f8ebb BP |
184 | [[sort-atoms '["boolean"]' '[true,false,true,false,false]']], |
185 | [[[false,false,false,true,true]]]) | |
186 | ||
99155935 | 187 | OVSDB_CHECK_POSITIVE_CPY([string atom sorting], |
f85f8ebb BP |
188 | [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']], |
189 | [[["\b","abc","abd","xxx"]]]) | |
190 | ||
99155935 | 191 | OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting], |
f85f8ebb BP |
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 | ||
99155935 | 228 | OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom], |
f85f8ebb | 229 | [[parse-atoms '["integer"]' '[0.5]' ]], |
bd76d25d BP |
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. | |
99155935 | 234 | OVSDB_CHECK_POSITIVE_CPY([no invalid UTF-8 sequences in strings], |
bd76d25d | 235 | [parse-atoms '[["string"]]' \ |
a238d75e BP |
236 | '@<:@"m4_esyscmd([printf "\300"])"@:>@' \ |
237 | '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \ | |
bd76d25d | 238 | ], |
a238d75e | 239 | [constraint violation: "m4_esyscmd([printf "\300"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xc0 |
99155935 BP |
240 | constraint violation: "m4_esyscmd([printf "\355\240\200"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0], |
241 | [], [], [xfail]) | |
f85f8ebb | 242 | |
5c414a2e BP |
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 | ||
99155935 | 247 | OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom], |
f85f8ebb | 248 | [[parse-atoms '["boolean"]' '["true"]' ]], |
bd76d25d | 249 | [syntax ""true"": syntax error: expected boolean]) |
f85f8ebb | 250 | |
5c414a2e BP |
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 | ||
99155935 | 255 | OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom], |
f85f8ebb | 256 | [[parse-atoms '["string"]' '[1]']], |
bd76d25d | 257 | [syntax "1": syntax error: expected string]) |
f85f8ebb | 258 | |
99155935 | 259 | OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array], |
f85f8ebb | 260 | [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']], |
bd76d25d | 261 | [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]]) |
f85f8ebb | 262 | |
5c414a2e BP |
263 | OVSDB_CHECK_NEGATIVE([empty string atom must be quoted], |
264 | [[parse-atom-strings '["string"]' '']], | |
265 | [An empty string is not valid as input; use "" to represent the empty string]) | |
266 | ||
267 | OVSDB_CHECK_NEGATIVE([quotes must be balanced], | |
268 | [parse-atom-strings '[["string"]]' '"asdf'], | |
269 | ["asdf: missing quote at end of quoted string]) | |
270 | ||
271 | OVSDB_CHECK_NEGATIVE([uuids must be valid], | |
272 | [parse-atom-strings '[["uuid"]]' '1234-5678'], | |
273 | ["1234-5678" is not a valid UUID]) | |
bd76d25d | 274 | \f |
bfc96d9b BP |
275 | AT_BANNER([OVSDB -- atoms with enum constraints]) |
276 | ||
99155935 | 277 | OVSDB_CHECK_POSITIVE_CPY([integer atom enum], |
bfc96d9b BP |
278 | [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \ |
279 | '[0]' \ | |
280 | '[1]' \ | |
281 | '[2]' \ | |
282 | '[3]' \ | |
283 | '[6]' \ | |
284 | '[7]' \ | |
285 | '[8]' \ | |
286 | '[9]' \ | |
287 | '[10]' \ | |
288 | '[11]']], | |
289 | [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10]) | |
290 | 1 | |
291 | constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10]) | |
292 | constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10]) | |
293 | 6 | |
294 | constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10]) | |
295 | 8 | |
296 | constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10]) | |
297 | 10 | |
298 | constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]]) | |
299 | ||
99155935 | 300 | OVSDB_CHECK_POSITIVE_CPY([real atom enum], |
bfc96d9b BP |
301 | [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \ |
302 | '[-2]' \ | |
303 | '[-1]' \ | |
304 | '[-1.5]' \ | |
305 | '[0]' \ | |
306 | '[1]' \ | |
307 | '[1.5]' \ | |
308 | '[2]']], | |
309 | [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5]) | |
310 | constraint violation: -1 is not one of the allowed values ([-1.5, 1.5]) | |
311 | -1.5 | |
312 | constraint violation: 0 is not one of the allowed values ([-1.5, 1.5]) | |
313 | constraint violation: 1 is not one of the allowed values ([-1.5, 1.5]) | |
314 | 1.5 | |
315 | constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]]) | |
316 | ||
99155935 | 317 | OVSDB_CHECK_POSITIVE_CPY([boolean atom enum], |
bfc96d9b BP |
318 | [[parse-atoms '[{"type": "boolean", "enum": false}]' \ |
319 | '[false]' \ | |
320 | '[true]']], | |
321 | [[false | |
322 | constraint violation: true is not one of the allowed values ([false])]]) | |
323 | ||
99155935 | 324 | OVSDB_CHECK_POSITIVE_CPY([string atom enum], |
bfc96d9b BP |
325 | [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \ |
326 | '[""]' \ | |
327 | '["ab"]' \ | |
328 | '["abc"]' \ | |
329 | '["def"]' \ | |
330 | '["defg"]' \ | |
331 | '["DEF"]']], | |
332 | [[constraint violation: "" is not one of the allowed values ([abc, def]) | |
333 | constraint violation: ab is not one of the allowed values ([abc, def]) | |
334 | "abc" | |
335 | "def" | |
336 | constraint violation: defg is not one of the allowed values ([abc, def]) | |
337 | constraint violation: DEF is not one of the allowed values ([abc, def])]]) | |
338 | ||
99155935 | 339 | OVSDB_CHECK_POSITIVE_CPY([uuid atom enum], |
bfc96d9b BP |
340 | [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \ |
341 | '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \ | |
342 | '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \ | |
343 | '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']], | |
344 | [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"] | |
345 | ["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"] | |
346 | constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]]) | |
347 | \f | |
348 | AT_BANNER([OVSDB -- atoms with other constraints]) | |
bd76d25d | 349 | |
99155935 | 350 | OVSDB_CHECK_POSITIVE_CPY([integers >= 5], |
bd76d25d BP |
351 | [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \ |
352 | '[0]' \ | |
353 | '[4]' \ | |
354 | '[5]' \ | |
355 | '[6]' \ | |
356 | '[12345]']], | |
357 | [constraint violation: 0 is less than minimum allowed value 5 | |
358 | constraint violation: 4 is less than minimum allowed value 5 | |
359 | 5 | |
360 | 6 | |
361 | 12345]) | |
362 | ||
99155935 | 363 | OVSDB_CHECK_POSITIVE_CPY([integers <= -1], |
bd76d25d BP |
364 | [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \ |
365 | '[0]' \ | |
366 | '[-1]' \ | |
367 | '[-2]' \ | |
368 | '[-123]']], | |
369 | [constraint violation: 0 is greater than maximum allowed value -1 | |
370 | -1 | |
371 | -2 | |
372 | -123]) | |
373 | ||
99155935 | 374 | OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10], |
bd76d25d BP |
375 | [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \ |
376 | '[-20]' \ | |
377 | '[-11]' \ | |
378 | '[-10]' \ | |
379 | '[-9]' \ | |
380 | '[1]' \ | |
381 | '[9]' \ | |
382 | '[10]' \ | |
383 | '[11]' \ | |
384 | '[123576]']], | |
385 | [constraint violation: -20 is not in the valid range -10 to 10 (inclusive) | |
386 | constraint violation: -11 is not in the valid range -10 to 10 (inclusive) | |
387 | -10 | |
388 | -9 | |
389 | 1 | |
390 | 9 | |
391 | 10 | |
392 | constraint violation: 11 is not in the valid range -10 to 10 (inclusive) | |
393 | constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)]) | |
394 | ||
99155935 | 395 | OVSDB_CHECK_POSITIVE_CPY([reals >= 5], |
bd76d25d BP |
396 | [[parse-atoms '[{"type": "real", "minReal": 5}]' \ |
397 | '[0]' \ | |
398 | '[4]' \ | |
399 | '[5]' \ | |
400 | '[6]' \ | |
401 | '[12345]']], | |
402 | [constraint violation: 0 is less than minimum allowed value 5 | |
403 | constraint violation: 4 is less than minimum allowed value 5 | |
404 | 5 | |
405 | 6 | |
406 | 12345]) | |
407 | ||
99155935 | 408 | OVSDB_CHECK_POSITIVE_CPY([reals <= -1], |
bd76d25d BP |
409 | [[parse-atoms '[{"type": "real", "maxReal": -1}]' \ |
410 | '[0]' \ | |
411 | '[-1]' \ | |
412 | '[-2]' \ | |
413 | '[-123]']], | |
414 | [constraint violation: 0 is greater than maximum allowed value -1 | |
415 | -1 | |
416 | -2 | |
417 | -123]) | |
418 | ||
99155935 | 419 | OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10], |
bd76d25d BP |
420 | [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \ |
421 | '[-20]' \ | |
422 | '[-11]' \ | |
423 | '[-10]' \ | |
424 | '[-9]' \ | |
425 | '[1]' \ | |
426 | '[9]' \ | |
427 | '[10]' \ | |
428 | '[11]' \ | |
429 | '[123576]']], | |
430 | [constraint violation: -20 is not in the valid range -10 to 10 (inclusive) | |
431 | constraint violation: -11 is not in the valid range -10 to 10 (inclusive) | |
432 | -10 | |
433 | -9 | |
434 | 1 | |
435 | 9 | |
436 | 10 | |
437 | constraint violation: 11 is not in the valid range -10 to 10 (inclusive) | |
438 | constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)]) | |
439 | ||
99155935 | 440 | OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long], |
bd76d25d BP |
441 | [[parse-atoms '{"type": "string", "minLength": 2}' \ |
442 | '[""]' \ | |
443 | '["a"]' \ | |
444 | '["ab"]' \ | |
445 | '["abc"]' \ | |
446 | '["\ud834\udd1e"]']], | |
447 | [[constraint violation: "" length 0 is less than minimum allowed length 2 | |
448 | constraint violation: "a" length 1 is less than minimum allowed length 2 | |
449 | "ab" | |
450 | "abc" | |
99155935 BP |
451 | constraint violation: "𝄞" length 1 is less than minimum allowed length 2]], |
452 | [], [], [xfail]) | |
bd76d25d | 453 | |
99155935 | 454 | OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long], |
bd76d25d BP |
455 | [[parse-atoms '{"type": "string", "maxLength": 2}' \ |
456 | '[""]' \ | |
457 | '["a"]' \ | |
458 | '["ab"]' \ | |
459 | '["abc"]' \ | |
460 | '["\ud834\udd1e"]']], | |
461 | [["" | |
462 | "a" | |
463 | "ab" | |
464 | constraint violation: "abc" length 3 is greater than maximum allowed length 2 | |
465 | "𝄞"]]) | |
5c414a2e | 466 | |
f85f8ebb BP |
467 | AT_BANNER([OSVDB -- simple data]) |
468 | ||
99155935 | 469 | OVSDB_CHECK_POSITIVE_CPY([integer JSON datum], |
ae8f13e2 | 470 | [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']], |
f85f8ebb BP |
471 | [0 |
472 | 1 | |
473 | -1]) | |
474 | ||
5c414a2e BP |
475 | OVSDB_CHECK_POSITIVE([integer string datum], |
476 | [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']], | |
477 | [0 | |
478 | 1 | |
479 | -1 | |
480 | 1]) | |
481 | ||
99155935 | 482 | OVSDB_CHECK_POSITIVE_CPY([real JSON datum], |
ae8f13e2 | 483 | [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']], |
f85f8ebb BP |
484 | [0 |
485 | 1 | |
486 | -1.25]) | |
487 | ||
5c414a2e BP |
488 | OVSDB_CHECK_POSITIVE([real string datum], |
489 | [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']], | |
490 | [0 | |
491 | 1 | |
492 | -1.25]) | |
493 | ||
99155935 | 494 | OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum], |
ae8f13e2 | 495 | [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]], |
f85f8ebb BP |
496 | [true |
497 | false]) | |
498 | ||
5c414a2e BP |
499 | OVSDB_CHECK_POSITIVE([boolean string datum], |
500 | [[parse-data-strings '["boolean"]' 'true' 'false' ]], | |
501 | [true | |
502 | false]) | |
503 | ||
99155935 | 504 | OVSDB_CHECK_POSITIVE_CPY([string JSON datum], |
ae8f13e2 | 505 | [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']], |
f85f8ebb BP |
506 | ["" |
507 | "true" | |
508 | "\"\\/\b\f\n\r\t"]) | |
509 | ||
5c414a2e BP |
510 | OVSDB_CHECK_POSITIVE([string string datum], |
511 | [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']], | |
512 | [x | |
513 | "" | |
514 | "true" | |
515 | "\"\\/\b\f\n\r\t"]) | |
bd76d25d | 516 | \f |
f85f8ebb BP |
517 | AT_BANNER([OVSDB -- set data]) |
518 | ||
99155935 | 519 | OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean], |
f85f8ebb | 520 | [[parse-data '{"key": "boolean", "min": 0}' \ |
ae8f13e2 | 521 | '[true]' \ |
f85f8ebb BP |
522 | '["set", [false]]' \ |
523 | '["set", []]']], | |
ae8f13e2 BP |
524 | [[true |
525 | false | |
f85f8ebb BP |
526 | ["set",[]]]], |
527 | [set]) | |
528 | ||
5c414a2e BP |
529 | OVSDB_CHECK_POSITIVE([string optional boolean], |
530 | [[parse-data-strings '{"key": "boolean", "min": 0}' \ | |
531 | 'true' \ | |
532 | 'false' \ | |
533 | '[]']], | |
534 | [[true | |
535 | false | |
536 | []]], | |
537 | [set]) | |
538 | ||
99155935 | 539 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers], |
f85f8ebb BP |
540 | [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \ |
541 | '["set", [0]]' \ | |
ae8f13e2 | 542 | '[1]' \ |
f85f8ebb BP |
543 | '["set", [0, 1]]' \ |
544 | '["set", [0, 1, 2]]' \ | |
545 | '["set", [0, 1, 2, 3, 4, 5]]' \ | |
546 | '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \ | |
547 | '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']], | |
ae8f13e2 BP |
548 | [[0 |
549 | 1 | |
f85f8ebb BP |
550 | ["set",[0,1]] |
551 | ["set",[0,1,2]] | |
552 | ["set",[0,1,2,3,4,5]] | |
553 | ["set",[0,1,2,3,4,5,6,7,8]] | |
554 | ["set",[0,1,2,3,4,5,6,7,8,9,10]]]]) | |
555 | ||
5c414a2e BP |
556 | OVSDB_CHECK_POSITIVE([string set of 0 or more integers], |
557 | [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \ | |
558 | '0' \ | |
559 | '0,1' \ | |
560 | '0, 1, 2' \ | |
561 | '[0, 1,2, 3, 4, 5]' \ | |
562 | '0, 1,2, 3,4, 5, 6, 7, 8' \ | |
563 | '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']], | |
564 | [[[0] | |
565 | [0, 1] | |
566 | [0, 1, 2] | |
567 | [0, 1, 2, 3, 4, 5] | |
568 | [0, 1, 2, 3, 4, 5, 6, 7, 8] | |
569 | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]]) | |
570 | ||
99155935 | 571 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids], |
f85f8ebb BP |
572 | [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \ |
573 | '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \ | |
ae8f13e2 | 574 | '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \ |
f85f8ebb BP |
575 | '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"], |
576 | ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"], | |
577 | ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']], | |
ae8f13e2 BP |
578 | [[["uuid","550e8400-e29b-41d4-a716-446655440000"] |
579 | ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"] | |
f85f8ebb BP |
580 | ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]]) |
581 | ||
5c414a2e BP |
582 | OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids], |
583 | [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \ | |
584 | '[550e8400-e29b-41d4-a716-446655440000]' \ | |
585 | '[c5051240-30ff-43ed-b4b9-93cf3f050813, | |
586 | 90558331-09af-4d2f-a572-509cad2e9088, | |
587 | 550e8400-e29b-41d4-a716-446655440000]']], | |
588 | [[[550e8400-e29b-41d4-a716-446655440000] | |
589 | [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]]) | |
590 | ||
99155935 | 591 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings], |
f85f8ebb BP |
592 | [[parse-data '{"key": "string", "min": 0, "max": 3}' \ |
593 | '["set", []]' \ | |
ae8f13e2 | 594 | '["a longer string"]' \ |
f85f8ebb BP |
595 | '["set", ["a relatively long string"]]' \ |
596 | '["set", ["short string", "a relatively long string"]]' \ | |
597 | '["set", ["zzz", "short string", "a relatively long string"]]']], | |
598 | [[["set",[]] | |
ae8f13e2 BP |
599 | "a longer string" |
600 | "a relatively long string" | |
f85f8ebb BP |
601 | ["set",["a relatively long string","short string"]] |
602 | ["set",["a relatively long string","short string","zzz"]]]]) | |
603 | ||
5c414a2e BP |
604 | OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings], |
605 | [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \ | |
606 | '[]' \ | |
607 | '"a relatively long string"' \ | |
608 | '["short string", "a relatively long string"]' \ | |
609 | '"zzz","short string","a relatively long string"']], | |
610 | [[[] | |
611 | ["a relatively long string"] | |
612 | ["a relatively long string", "short string"] | |
613 | ["a relatively long string", "short string", zzz]]]) | |
614 | ||
99155935 | 615 | OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set], |
f85f8ebb BP |
616 | [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']], |
617 | [ovsdb error: set contains duplicate]) | |
618 | ||
5c414a2e BP |
619 | OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set], |
620 | [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']], | |
621 | [set contains duplicate value]) | |
622 | ||
99155935 | 623 | OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set], |
f85f8ebb BP |
624 | [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']], |
625 | [ovsdb error: set contains duplicate]) | |
626 | ||
5c414a2e BP |
627 | OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set], |
628 | [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']], | |
629 | [set contains duplicate value]) | |
630 | ||
99155935 | 631 | OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set], |
f85f8ebb BP |
632 | [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']], |
633 | [ovsdb error: set contains duplicate]) | |
634 | ||
5c414a2e BP |
635 | OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set], |
636 | [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']], | |
637 | [set contains duplicate value]) | |
638 | ||
99155935 | 639 | OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set], |
f85f8ebb BP |
640 | [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']], |
641 | [ovsdb error: set contains duplicate]) | |
642 | ||
5c414a2e BP |
643 | OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set], |
644 | [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']], | |
645 | [set contains duplicate value]) | |
646 | ||
99155935 | 647 | OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set], |
f85f8ebb BP |
648 | [[parse-data '{"key": "uuid", "max": 5}' \ |
649 | '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"], | |
650 | ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"], | |
651 | ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']], | |
652 | [ovsdb error: set contains duplicate]) | |
653 | ||
5c414a2e BP |
654 | OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set], |
655 | [[parse-data-strings '{"key": "uuid", "max": 5}' \ | |
656 | '7ef21525-0088-4a28-a418-5518413e43ea, | |
657 | 355ad037-f1da-40aa-b47c-ff9c7e8c6a38, | |
658 | 7ef21525-0088-4a28-a418-5518413e43ea']], | |
659 | [set contains duplicate value]) | |
bd76d25d | 660 | \f |
f85f8ebb BP |
661 | AT_BANNER([OVSDB -- map data]) |
662 | ||
99155935 | 663 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean], |
f85f8ebb BP |
664 | [[parse-data '{"key": "integer", "value": "boolean"}' \ |
665 | '["map", [[1, true]]]']], | |
666 | [[["map",[[1,true]]]]]) | |
667 | ||
5c414a2e BP |
668 | OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean], |
669 | [[parse-data-strings '{"key": "integer", "value": "boolean"}' \ | |
670 | '1=true']], | |
671 | [[1=true]]) | |
672 | ||
99155935 | 673 | OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean], |
f85f8ebb BP |
674 | [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \ |
675 | '["map", [[1, true]]]' \ | |
676 | '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \ | |
677 | '["map", [[3, false], [0, true], [4, false]]]']], | |
678 | [[["map",[[1,true]]] | |
679 | ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]] | |
680 | ["map",[[0,true],[3,false],[4,false]]]]]) | |
681 | ||
5c414a2e BP |
682 | OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean], |
683 | [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \ | |
684 | '1=true' \ | |
685 | '0=true 1=false 2=true, 3=true 4=true,' \ | |
686 | '3=false,0=true ,4=false']], | |
687 | [[{1=true} | |
688 | {0=true, 1=false, 2=true, 3=true, 4=true} | |
689 | {0=true, 3=false, 4=false}]]) | |
690 | ||
99155935 | 691 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer], |
f85f8ebb BP |
692 | [[parse-data '{"key": "boolean", "value": "integer"}' \ |
693 | '["map", [[true, 1]]]']], | |
694 | [[["map",[[true,1]]]]]) | |
695 | ||
5c414a2e BP |
696 | OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer], |
697 | [[parse-data-strings '{"key": "boolean", "value": "integer"}' \ | |
698 | 'true=1']], | |
699 | [[true=1]]) | |
700 | ||
99155935 | 701 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real], |
31a763d7 | 702 | [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \ |
f85f8ebb BP |
703 | '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0], |
704 | [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0], | |
705 | [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0], | |
706 | [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0], | |
707 | [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']], | |
708 | [[["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]]]]]) | |
709 | ||
5c414a2e BP |
710 | OVSDB_CHECK_POSITIVE([string map of 1 uuid to real], |
711 | [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \ | |
712 | 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0, | |
713 | 6b94b968-2702-4f64-9457-314a34d69b8c=2.0, | |
714 | d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0, | |
715 | 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0, | |
716 | 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']], | |
717 | [[{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}]]) | |
718 | ||
99155935 | 719 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string], |
31a763d7 | 720 | [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \ |
f85f8ebb BP |
721 | '["map", [["2 gills", "1 chopin"], |
722 | ["2 chopins", "1 pint"], | |
723 | ["2 pints", "1 quart"], | |
724 | ["2 quarts", "1 pottle"], | |
725 | ["2 pottles", "1 gallon"], | |
726 | ["2 gallons", "1 peck"], | |
727 | ["2 pecks", "1 demibushel"], | |
728 | ["2 demibushel", "1 firkin"], | |
729 | ["2 firkins", "1 kilderkin"], | |
730 | ["2 kilderkins", "1 barrel"]]]']], | |
731 | [[["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"]]]]]) | |
732 | ||
5c414a2e BP |
733 | OVSDB_CHECK_POSITIVE([string map of 10 string to string], |
734 | [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \ | |
735 | '{"2 gills"="1 chopin", | |
736 | "2 chopins"= "1 pint", | |
737 | "2 pints"= "1 quart", | |
738 | "2 quarts"= "1 pottle", | |
739 | "2 pottles"= "1 gallon", | |
740 | "2 gallons"= "1 peck", | |
741 | "2 pecks"= "1 demibushel", | |
742 | "2 demibushel"= "1 firkin", | |
743 | "2 firkins"= "1 kilderkin", | |
744 | "2 kilderkins"= "1 barrel"}']], | |
745 | [[{"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"}]]) | |
746 | ||
99155935 | 747 | OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map], |
f85f8ebb BP |
748 | [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \ |
749 | '["map", [[1, true], [2, false], [1, false]]]']], | |
750 | [ovsdb error: map contains duplicate key]) | |
5c414a2e BP |
751 | |
752 | OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map], | |
753 | [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \ | |
754 | '1=true 2=false 1=false']], | |
755 | [map contains duplicate key]) |