]>
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>]]]) |
fdba6728 BP |
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>]]]) | |
f85f8ebb | 266 | |
5c414a2e BP |
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]) | |
bd76d25d | 278 | \f |
bfc96d9b BP |
279 | AT_BANNER([OVSDB -- atoms with enum constraints]) |
280 | ||
99155935 | 281 | OVSDB_CHECK_POSITIVE_CPY([integer atom enum], |
bfc96d9b BP |
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 | ||
99155935 | 304 | OVSDB_CHECK_POSITIVE_CPY([real atom enum], |
bfc96d9b BP |
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 | ||
99155935 | 321 | OVSDB_CHECK_POSITIVE_CPY([boolean atom enum], |
bfc96d9b BP |
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 | ||
99155935 | 328 | OVSDB_CHECK_POSITIVE_CPY([string atom enum], |
bfc96d9b BP |
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 | ||
99155935 | 343 | OVSDB_CHECK_POSITIVE_CPY([uuid atom enum], |
bfc96d9b BP |
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]) | |
bd76d25d | 353 | |
99155935 | 354 | OVSDB_CHECK_POSITIVE_CPY([integers >= 5], |
bd76d25d BP |
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 | ||
99155935 | 367 | OVSDB_CHECK_POSITIVE_CPY([integers <= -1], |
bd76d25d BP |
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 | ||
99155935 | 378 | OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10], |
bd76d25d BP |
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 | ||
99155935 | 399 | OVSDB_CHECK_POSITIVE_CPY([reals >= 5], |
bd76d25d BP |
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 | ||
99155935 | 412 | OVSDB_CHECK_POSITIVE_CPY([reals <= -1], |
bd76d25d BP |
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 | ||
99155935 | 423 | OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10], |
bd76d25d BP |
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 | ||
99155935 | 444 | OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long], |
bd76d25d BP |
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" | |
99155935 BP |
455 | constraint violation: "𝄞" length 1 is less than minimum allowed length 2]], |
456 | [], [], [xfail]) | |
bd76d25d | 457 | |
99155935 | 458 | OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long], |
bd76d25d BP |
459 | [[parse-atoms '{"type": "string", "maxLength": 2}' \ |
460 | '[""]' \ | |
461 | '["a"]' \ | |
462 | '["ab"]' \ | |
463 | '["abc"]' \ | |
65683353 | 464 | '["de"]']], |
bd76d25d BP |
465 | [["" |
466 | "a" | |
467 | "ab" | |
468 | constraint violation: "abc" length 3 is greater than maximum allowed length 2 | |
65683353 | 469 | "de"]]) |
5c414a2e | 470 | |
f85f8ebb BP |
471 | AT_BANNER([OSVDB -- simple data]) |
472 | ||
99155935 | 473 | OVSDB_CHECK_POSITIVE_CPY([integer JSON datum], |
ae8f13e2 | 474 | [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']], |
f85f8ebb BP |
475 | [0 |
476 | 1 | |
477 | -1]) | |
478 | ||
5c414a2e BP |
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 | ||
99155935 | 486 | OVSDB_CHECK_POSITIVE_CPY([real JSON datum], |
ae8f13e2 | 487 | [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']], |
f85f8ebb BP |
488 | [0 |
489 | 1 | |
490 | -1.25]) | |
491 | ||
5c414a2e BP |
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 | ||
99155935 | 498 | OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum], |
ae8f13e2 | 499 | [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]], |
f85f8ebb BP |
500 | [true |
501 | false]) | |
502 | ||
5c414a2e BP |
503 | OVSDB_CHECK_POSITIVE([boolean string datum], |
504 | [[parse-data-strings '["boolean"]' 'true' 'false' ]], | |
505 | [true | |
506 | false]) | |
507 | ||
99155935 | 508 | OVSDB_CHECK_POSITIVE_CPY([string JSON datum], |
ae8f13e2 | 509 | [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']], |
f85f8ebb BP |
510 | ["" |
511 | "true" | |
512 | "\"\\/\b\f\n\r\t"]) | |
513 | ||
5c414a2e BP |
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"]) | |
bd76d25d | 520 | \f |
f85f8ebb BP |
521 | AT_BANNER([OVSDB -- set data]) |
522 | ||
99155935 | 523 | OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean], |
f85f8ebb | 524 | [[parse-data '{"key": "boolean", "min": 0}' \ |
ae8f13e2 | 525 | '[true]' \ |
f85f8ebb BP |
526 | '["set", [false]]' \ |
527 | '["set", []]']], | |
ae8f13e2 BP |
528 | [[true |
529 | false | |
f85f8ebb BP |
530 | ["set",[]]]], |
531 | [set]) | |
532 | ||
5c414a2e BP |
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 | ||
99155935 | 543 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers], |
f85f8ebb BP |
544 | [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \ |
545 | '["set", [0]]' \ | |
ae8f13e2 | 546 | '[1]' \ |
f85f8ebb BP |
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]]']], | |
ae8f13e2 BP |
552 | [[0 |
553 | 1 | |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 575 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids], |
f85f8ebb BP |
576 | [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \ |
577 | '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \ | |
ae8f13e2 | 578 | '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \ |
f85f8ebb BP |
579 | '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"], |
580 | ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"], | |
581 | ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']], | |
ae8f13e2 BP |
582 | [[["uuid","550e8400-e29b-41d4-a716-446655440000"] |
583 | ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"] | |
f85f8ebb BP |
584 | ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]]) |
585 | ||
5c414a2e BP |
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 | ||
99155935 | 595 | OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings], |
f85f8ebb BP |
596 | [[parse-data '{"key": "string", "min": 0, "max": 3}' \ |
597 | '["set", []]' \ | |
ae8f13e2 | 598 | '["a longer string"]' \ |
f85f8ebb BP |
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",[]] | |
ae8f13e2 BP |
603 | "a longer string" |
604 | "a relatively long string" | |
f85f8ebb BP |
605 | ["set",["a relatively long string","short string"]] |
606 | ["set",["a relatively long string","short string","zzz"]]]]) | |
607 | ||
5c414a2e BP |
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 | ||
99155935 | 619 | OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set], |
f85f8ebb BP |
620 | [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']], |
621 | [ovsdb error: set contains duplicate]) | |
622 | ||
5c414a2e BP |
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 | ||
99155935 | 627 | OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set], |
f85f8ebb BP |
628 | [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']], |
629 | [ovsdb error: set contains duplicate]) | |
630 | ||
5c414a2e BP |
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 | ||
99155935 | 635 | OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set], |
f85f8ebb BP |
636 | [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']], |
637 | [ovsdb error: set contains duplicate]) | |
638 | ||
5c414a2e BP |
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 | ||
99155935 | 643 | OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set], |
f85f8ebb BP |
644 | [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']], |
645 | [ovsdb error: set contains duplicate]) | |
646 | ||
5c414a2e BP |
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 | ||
99155935 | 651 | OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set], |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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]) | |
bd76d25d | 664 | \f |
f85f8ebb BP |
665 | AT_BANNER([OVSDB -- map data]) |
666 | ||
99155935 | 667 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean], |
f85f8ebb BP |
668 | [[parse-data '{"key": "integer", "value": "boolean"}' \ |
669 | '["map", [[1, true]]]']], | |
670 | [[["map",[[1,true]]]]]) | |
671 | ||
5c414a2e BP |
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 | ||
99155935 | 677 | OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean], |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 695 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer], |
f85f8ebb BP |
696 | [[parse-data '{"key": "boolean", "value": "integer"}' \ |
697 | '["map", [[true, 1]]]']], | |
698 | [[["map",[[true,1]]]]]) | |
699 | ||
5c414a2e BP |
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 | ||
99155935 | 705 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real], |
31a763d7 | 706 | [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \ |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 723 | OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string], |
31a763d7 | 724 | [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \ |
f85f8ebb BP |
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 | ||
5c414a2e BP |
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 | ||
99155935 | 751 | OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map], |
f85f8ebb BP |
752 | [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \ |
753 | '["map", [[1, true], [2, false], [1, false]]]']], | |
754 | [ovsdb error: map contains duplicate key]) | |
5c414a2e BP |
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]) |