summaryrefslogtreecommitdiff
path: root/tests/ovsdb-data.at
blob: 25c6acdac6cbe098821b0c54e4f73ed592b06f9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
AT_BANNER([OVSDB -- default values])

OVSDB_CHECK_POSITIVE_CPY([default atoms],
  [default-atoms],
  [[integer: OK
real: OK
boolean: OK
string: OK
uuid: OK]])

OVSDB_CHECK_POSITIVE_CPY([default data],
  [default-data],
  [[key integer, value void, n_min 0: OK
key integer, value integer, n_min 0: OK
key integer, value real, n_min 0: OK
key integer, value boolean, n_min 0: OK
key integer, value string, n_min 0: OK
key integer, value uuid, n_min 0: OK
key real, value void, n_min 0: OK
key real, value integer, n_min 0: OK
key real, value real, n_min 0: OK
key real, value boolean, n_min 0: OK
key real, value string, n_min 0: OK
key real, value uuid, n_min 0: OK
key boolean, value void, n_min 0: OK
key boolean, value integer, n_min 0: OK
key boolean, value real, n_min 0: OK
key boolean, value boolean, n_min 0: OK
key boolean, value string, n_min 0: OK
key boolean, value uuid, n_min 0: OK
key string, value void, n_min 0: OK
key string, value integer, n_min 0: OK
key string, value real, n_min 0: OK
key string, value boolean, n_min 0: OK
key string, value string, n_min 0: OK
key string, value uuid, n_min 0: OK
key uuid, value void, n_min 0: OK
key uuid, value integer, n_min 0: OK
key uuid, value real, n_min 0: OK
key uuid, value boolean, n_min 0: OK
key uuid, value string, n_min 0: OK
key uuid, value uuid, n_min 0: OK
key integer, value void, n_min 1: OK
key integer, value integer, n_min 1: OK
key integer, value real, n_min 1: OK
key integer, value boolean, n_min 1: OK
key integer, value string, n_min 1: OK
key integer, value uuid, n_min 1: OK
key real, value void, n_min 1: OK
key real, value integer, n_min 1: OK
key real, value real, n_min 1: OK
key real, value boolean, n_min 1: OK
key real, value string, n_min 1: OK
key real, value uuid, n_min 1: OK
key boolean, value void, n_min 1: OK
key boolean, value integer, n_min 1: OK
key boolean, value real, n_min 1: OK
key boolean, value boolean, n_min 1: OK
key boolean, value string, n_min 1: OK
key boolean, value uuid, n_min 1: OK
key string, value void, n_min 1: OK
key string, value integer, n_min 1: OK
key string, value real, n_min 1: OK
key string, value boolean, n_min 1: OK
key string, value string, n_min 1: OK
key string, value uuid, n_min 1: OK
key uuid, value void, n_min 1: OK
key uuid, value integer, n_min 1: OK
key uuid, value real, n_min 1: OK
key uuid, value boolean, n_min 1: OK
key uuid, value string, n_min 1: OK
key uuid, value uuid, n_min 1: OK]])

AT_BANNER([OVSDB -- atoms without constraints])

OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON], 
  [[parse-atoms '["integer"]' \
    '[0]' \
    '[-1]' \
    '[1e3]' \
    '[9223372036854775807]' \
    '[-9223372036854775808]' ]], 
  [0
-1
1000
9223372036854775807
-9223372036854775808])

OVSDB_CHECK_POSITIVE([integer atom from string], 
  [[parse-atom-strings -- '["integer"]' \
    '0' \
    '-1' \
    '+1000' \
    '9223372036854775807' \
    '-9223372036854775808' \
    '0-1000' \
    '-1000-+1000' \
    '-1000--10' \
    '+10-+1000' \
    '1-4096' \
    '-4096--1' \
    '-2000-2095']],
  [0
-1
1000
9223372036854775807
-9223372036854775808
0-1000
-1000-1000
-1000--10
10-1000
1-4096
-4096--1
-2000-2095])

OVSDB_CHECK_POSITIVE_CPY([real atom from JSON], 
  [[parse-atoms '["real"]' \
    '[0]' \
    '[0.0]' \
    '[-0.0]' \
    '[-1.25]' \
    '[1e3]' \
    '[1e37]' \
    '[0.00390625]' ]], 
  [0
0
0
-1.25
1000
1e+37
0.00390625])

OVSDB_CHECK_POSITIVE([real atom from string], 
  [[parse-atom-strings -- '["real"]' \
    '0' \
    '0.0' \
    '-0.0' \
    '-1.25' \
    '1e3' \
    '1e37' \
    '0.00390625' ]], 
  [0
0
0
-1.25
1000
1e+37
0.00390625])

OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
  [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
  [true
false])

OVSDB_CHECK_POSITIVE([boolean atom from string],
  [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
  [true
false])

OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
  [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
  [""
"true"
"\"\\/\b\f\n\r\t"])

OVSDB_CHECK_POSITIVE([string atom from string],
  [[parse-atom-strings '["string"]' \
    'unquoted' \
    '"quoted-string"' \
    '"needs quotes"' \
    '""' \
    '"true"' \
    '"\"\\\/\b\f\n\r\t"']],
  [unquoted
quoted-string
"needs quotes"
""
"true"
"\"\\/\b\f\n\r\t"])

OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON],
  [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
  [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])

OVSDB_CHECK_POSITIVE([uuid atom from string],
  [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
  [550e8400-e29b-41d4-a716-446655440000])

OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
  [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
  [[[-1,0,1,2,55]]])

OVSDB_CHECK_POSITIVE_CPY([real atom sorting],
  [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
  [[[-1e+99,0,0,1.23,1.25]]])

OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
  [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
  [[[false,false,false,true,true]]])

OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
  [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
  [[["\b","abc","abd","xxx"]]])

OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting],
  [[sort-atoms '["uuid"]' '[
    ["uuid", "00000000-0000-0000-0000-000000000001"],
    ["uuid", "00000000-1000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-1000-0000-000000000000"],
    ["uuid", "00010000-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0000-000000000100"],
    ["uuid", "00000000-0000-0000-0000-000100000000"],
    ["uuid", "00000000-0000-0010-0000-000000000000"],
    ["uuid", "00000100-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0001-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0000-000001000000"],
    ["uuid", "01000000-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0000-000000001000"],
    ["uuid", "00000000-0000-0000-0000-000010000000"],
    ["uuid", "00000000-0000-0000-0000-010000000000"],
    ["uuid", "00000000-0000-0100-0000-000000000000"],
    ["uuid", "10000000-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0000-000000000010"],
    ["uuid", "00000000-0100-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0100-000000000000"],
    ["uuid", "00000000-0000-0000-0001-000000000000"],
    ["uuid", "00000010-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0000-0000-0010-000000000000"],
    ["uuid", "00000000-0000-0000-0000-000000010000"],
    ["uuid", "00000000-0000-0000-1000-000000000000"],
    ["uuid", "00000000-0000-0000-0000-100000000000"],
    ["uuid", "00000000-0000-0000-0000-001000000000"],
    ["uuid", "00000000-0000-0000-0000-000000100000"],
    ["uuid", "00000000-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0010-0000-0000-000000000000"],
    ["uuid", "00100000-0000-0000-0000-000000000000"],
    ["uuid", "00000000-0001-0000-0000-000000000000"],
    ["uuid", "00000001-0000-0000-0000-000000000000"],
    ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
  [[[["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"]]]])

OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom],
  [[parse-atoms '["integer"]' '[0.5]' ]],
  [syntax "0.5": syntax error: expected integer])

dnl <C0> is not allowed anywhere in a UTF-8 string.
dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings],
  [parse-atoms '[["string"]]' \
     '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
     '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \
],
  [constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])

dnl Python won't let invalid UTF-8 (its idea of invalid UTF-8, anyway) into it
dnl at all, so this test never gets as far as a constraint violation.  It's
dnl just a JSON parse error.
dnl
dnl <C0> is not allowed anywhere in a UTF-8 string.
dnl (<ED A0 80> is not allowed in UTF-8 but Python doesn't care.)
dnl <ED 80 7F> is not allowed in UTF-8.
OVSDB_CHECK_POSITIVE_PY3([no invalid UTF-8 sequences in strings - Python],
  [parse-atoms '[["string"]]' \
     '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
     '@<:@"m4_esyscmd([printf "\355\200\177"])"@:>@' \
],
  ["not a valid UTF-8 string: invalid UTF-8 sequence 0xc0"
"not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0x80"])

OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
  [[parse-atom-strings '["integer"]' '0.5' ]],
  ["0.5" is not a valid integer])

OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom positive and negative],
  [[parse-atom-strings -- '["integer"]' '10--10' ]],
  ["10--10" is not a valid range. Range end cannot be before start.])

OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom negative],
  [[parse-atom-strings -- '["integer"]' '-10--100' ]],
  ["-10--100" is not a valid range. Range end cannot be before start.])

OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom positive],
  [[parse-atom-strings -- '["integer"]' '100-10' ]],
  ["100-10" is not a valid range. Range end cannot be before start.])

OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom positive and negative],
  [[parse-atom-strings -- '["integer"]' '-2000-2096' ]],
  [Range "-2000-2096" is too big.])

OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom negative],
  [[parse-atom-strings -- '["integer"]' '-4097--1' ]],
  [Range "-4097--1" is too big.])

OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom positive],
  [[parse-atom-strings -- '["integer"]' '1-4097' ]],
  [Range "1-4097" is too big.])

OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
  [[parse-atoms '["boolean"]' '["true"]' ]],
  [syntax ""true"": syntax error: expected boolean])

OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean string atom],
  [[parse-atom-strings '["boolean"]' '"true"' ]],
  [""true"" is not a valid boolean (use "true" or "false")])

OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
  [[parse-atoms '["string"]' '[1]']],
  [syntax "1": syntax error: expected string])

OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
  [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
  [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])

OVSDB_CHECK_POSITIVE_CPY([named-uuid requires symbol table],
  [parse-atoms '[["uuid"]]' '[["named-uuid", "x"]]'],
  [[syntax "["named-uuid","x"]": syntax error: expected ["uuid", <string>]]])

OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
  [[parse-atom-strings '["string"]' '']],
  [An empty string is not valid as input; use "" to represent the empty string])

OVSDB_CHECK_NEGATIVE([quotes must be balanced],
  [parse-atom-strings '[["string"]]' '"asdf'],
  ["asdf: missing quote at end of quoted string])

OVSDB_CHECK_NEGATIVE([quoted string must not contain unescaped quote],
  [parse-atom-strings '[["string"]]' '"as"df"'],
  ["as"df": quoted string may not include unescaped "])

OVSDB_CHECK_NEGATIVE([quoted string must not end with backslash],
  [parse-atom-strings '[["string"]]' '"asdf\"'],
  ["asdf\": quoted string may not end with backslash])

OVSDB_CHECK_NEGATIVE([uuids must be valid],
  [parse-atom-strings '[["uuid"]]' '1234-5678'],
  ["1234-5678" is not a valid UUID])

AT_BANNER([OVSDB -- atoms with enum constraints])

OVSDB_CHECK_POSITIVE_CPY([integer atom enum], 
  [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
    '[0]' \
    '[1]' \
    '[2]' \
    '[3]' \
    '[6]' \
    '[7]' \
    '[8]' \
    '[9]' \
    '[10]' \
    '[11]']], 
  [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
1
constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
6
constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
8
constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
10
constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])

OVSDB_CHECK_POSITIVE([integer atom enum from string],
  [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10, 20, 21, 22, 23, 24, 25]]}]' \
    '1' \
    '6' \
    '8' \
    '10' \
    '20-25']],
  [[1
6
8
10
20-25]])

OVSDB_CHECK_NEGATIVE([integer not in enum set from string],
  [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' '0' ]],
  [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])]])

OVSDB_CHECK_NEGATIVE([integer range not in enum set from string],
  [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' '8-10' ]],
  [[constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])]])

OVSDB_CHECK_POSITIVE_CPY([real atom enum], 
  [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
    '[-2]' \
    '[-1]' \
    '[-1.5]' \
    '[0]' \
    '[1]' \
    '[1.5]' \
    '[2]']], 
  [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
-1.5
constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
1.5
constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])

OVSDB_CHECK_POSITIVE_CPY([boolean atom enum], 
  [[parse-atoms '[{"type": "boolean", "enum": false}]' \
    '[false]' \
    '[true]']], 
  [[false
constraint violation: true is not one of the allowed values ([false])]])

OVSDB_CHECK_POSITIVE_CPY([string atom enum], 
  [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
    '[""]' \
    '["ab"]' \
    '["abc"]' \
    '["def"]' \
    '["defg"]' \
    '["DEF"]']], 
  [[constraint violation: "" is not one of the allowed values ([abc, def])
constraint violation: ab is not one of the allowed values ([abc, def])
"abc"
"def"
constraint violation: defg is not one of the allowed values ([abc, def])
constraint violation: DEF is not one of the allowed values ([abc, def])]])

OVSDB_CHECK_POSITIVE_CPY([uuid atom enum], 
  [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
    '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
    '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
    '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']], 
  [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])

AT_BANNER([OVSDB -- atoms with other constraints])

OVSDB_CHECK_POSITIVE_CPY([integers >= 5], 
  [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
    '[0]' \
    '[4]' \
    '[5]' \
    '[6]' \
    '[12345]']], 
  [constraint violation: 0 is less than minimum allowed value 5
constraint violation: 4 is less than minimum allowed value 5
5
6
12345])

OVSDB_CHECK_POSITIVE_CPY([integers <= -1], 
  [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
    '[0]' \
    '[-1]' \
    '[-2]' \
    '[-123]']], 
  [constraint violation: 0 is greater than maximum allowed value -1
-1
-2
-123])

OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10], 
  [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
    '[-20]' \
    '[-11]' \
    '[-10]' \
    '[-9]' \
    '[1]' \
    '[9]' \
    '[10]' \
    '[11]' \
    '[123576]']], 
  [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
-10
-9
1
9
10
constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])

OVSDB_CHECK_POSITIVE_CPY([reals >= 5], 
  [[parse-atoms '[{"type": "real", "minReal": 5}]' \
    '[0]' \
    '[4]' \
    '[5]' \
    '[6]' \
    '[12345]']], 
  [constraint violation: 0 is less than minimum allowed value 5
constraint violation: 4 is less than minimum allowed value 5
5
6
12345])

OVSDB_CHECK_POSITIVE_CPY([reals <= -1], 
  [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
    '[0]' \
    '[-1]' \
    '[-2]' \
    '[-123]']], 
  [constraint violation: 0 is greater than maximum allowed value -1
-1
-2
-123])

OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10], 
  [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
    '[-20]' \
    '[-11]' \
    '[-10]' \
    '[-9]' \
    '[1]' \
    '[9]' \
    '[10]' \
    '[11]' \
    '[123576]']], 
  [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
-10
-9
1
9
10
constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])

OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
  [[parse-atoms '{"type": "string", "minLength": 2}' \
    '[""]' \
    '["a"]' \
    '["ab"]' \
    '["abc"]' \
    '["\ud834\udd1e"]']],
  [[constraint violation: "" length 0 is less than minimum allowed length 2
constraint violation: "a" length 1 is less than minimum allowed length 2
"ab"
"abc"
constraint violation: "𝄞" length 1 is less than minimum allowed length 2]])

OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
  [[parse-atoms '{"type": "string", "maxLength": 2}' \
    '[""]' \
    '["a"]' \
    '["ab"]' \
    '["abc"]' \
    '["de"]']],
  [[""
"a"
"ab"
constraint violation: "abc" length 3 is greater than maximum allowed length 2
"de"]])

AT_BANNER([OVSDB -- simple data])

OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
  [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
  [0
1
-1])

OVSDB_CHECK_POSITIVE([integer string datum],
  [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
  [0
1
-1
1])

OVSDB_CHECK_POSITIVE_CPY([real JSON datum], 
  [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
  [0
1
-1.25])

OVSDB_CHECK_POSITIVE([real string datum], 
  [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
  [0
1
-1.25])

OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
  [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
  [true
false])

OVSDB_CHECK_POSITIVE([boolean string datum],
  [[parse-data-strings '["boolean"]' 'true' 'false' ]],
  [true
false])

OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
  [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
  [""
"true"
"\"\\/\b\f\n\r\t"])

OVSDB_CHECK_POSITIVE([string string datum],
  [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
  [x
""
"true"
"\"\\/\b\f\n\r\t"])

AT_BANNER([OVSDB -- set data])

OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
  [[parse-data '{"key": "boolean", "min": 0}' \
    '[true]' \
    '["set", [false]]' \
    '["set", []]']], 
  [[true
false
["set",[]]]],
  [set])

OVSDB_CHECK_POSITIVE([string optional boolean],
  [[parse-data-strings '{"key": "boolean", "min": 0}' \
    'true' \
    'false' \
    '[]']], 
  [[true
false
[]]],
  [set])

OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
  [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
    '["set", [0]]' \
    '[1]' \
    '["set", [0, 1]]' \
    '["set", [0, 1, 2]]' \
    '["set", [0, 1, 2, 3, 4, 5]]' \
    '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
    '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
  [[0
1
["set",[0,1]]
["set",[0,1,2]]
["set",[0,1,2,3,4,5]]
["set",[0,1,2,3,4,5,6,7,8]]
["set",[0,1,2,3,4,5,6,7,8,9,10]]]])

OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
  [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
    '0' \
    '0,1' \
    '0, 1, 2' \
    '[0, 1,2, 3, 4, 5]' \
    '0, 1,2, 3,4, 5, 6, 7, 8' \
    '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]' \
    '0-8' \
    '[0-10']]],
  [[[0]
[0, 1]
[0, 1, 2]
[0, 1, 2, 3, 4, 5]
[0, 1, 2, 3, 4, 5, 6, 7, 8]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[0, 1, 2, 3, 4, 5, 6, 7, 8]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])

OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
  [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
    '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
    '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
    '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
              ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
              ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
  [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])

OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
  [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
    '[550e8400-e29b-41d4-a716-446655440000]' \
    '[c5051240-30ff-43ed-b4b9-93cf3f050813,
      90558331-09af-4d2f-a572-509cad2e9088,
      550e8400-e29b-41d4-a716-446655440000]']],
  [[[550e8400-e29b-41d4-a716-446655440000]
[550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])

OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
  [[parse-data '{"key": "string", "min": 0, "max": 3}' \
    '["set", []]' \
    '["a longer string"]' \
    '["set", ["a relatively long string"]]' \
    '["set", ["short string", "a relatively long string"]]' \
    '["set", ["zzz", "short string", "a relatively long string"]]']],
  [[["set",[]]
"a longer string"
"a relatively long string"
["set",["a relatively long string","short string"]]
["set",["a relatively long string","short string","zzz"]]]])

OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
  [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
    '[]' \
    '"a relatively long string"' \
    '["short string", "a relatively long string"]' \
    '"zzz","short string","a relatively long string"']],
  [[[]
["a relatively long string"]
["a relatively long string", "short string"]
["a relatively long string", "short string", zzz]]])

OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
  [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
  [ovsdb error: set contains duplicate])

OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
  [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
  [set contains duplicate value])

OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
  [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
  [ovsdb error: set contains duplicate])

OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
  [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
  [set contains duplicate value])

OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
  [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
  [ovsdb error: set contains duplicate])

OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
  [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
  [set contains duplicate value])

OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
  [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
  [ovsdb error: set contains duplicate])

OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
  [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
  [set contains duplicate value])

OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
  [[parse-data '{"key": "uuid", "max": 5}' \
    '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
              ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
              ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
  [ovsdb error: set contains duplicate])

OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
  [[parse-data-strings '{"key": "uuid", "max": 5}' \
    '7ef21525-0088-4a28-a418-5518413e43ea,
     355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
     7ef21525-0088-4a28-a418-5518413e43ea']],
  [set contains duplicate value])

AT_BANNER([OVSDB -- map data])

OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
  [[parse-data '{"key": "integer", "value": "boolean"}' \
    '["map", [[1, true]]]']],
  [[["map",[[1,true]]]]])

OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
  [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
    '1=true']],
  [[1=true]])

OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
  [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
    '["map", [[1, true]]]' \
    '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
    '["map", [[3, false], [0, true], [4, false]]]']],
  [[["map",[[1,true]]]
["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
["map",[[0,true],[3,false],[4,false]]]]])

OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
  [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
    '1=true' \
    '0=true 1=false 2=true, 3=true 4=true,' \
    '3=false,0=true ,4=false']],
  [[{1=true}
{0=true, 1=false, 2=true, 3=true, 4=true}
{0=true, 3=false, 4=false}]])

OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
 [[parse-data '{"key": "boolean", "value": "integer"}' \
   '["map", [[true, 1]]]']],
 [[["map",[[true,1]]]]])

OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
   'true=1']],
 [[true=1]])

OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
  [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
    '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
              [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
              [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
              [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
              [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
  [[["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]]]]])

OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
  [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
    'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
     6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
     d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
     25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
     1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
  [[{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}]])

OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
  [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
    '["map", [["2 gills", "1 chopin"],
              ["2 chopins", "1 pint"],
              ["2 pints", "1 quart"],
              ["2 quarts", "1 pottle"],
              ["2 pottles", "1 gallon"],
              ["2 gallons", "1 peck"],
              ["2 pecks", "1 demibushel"],
              ["2 demibushel", "1 firkin"],
              ["2 firkins", "1 kilderkin"],
              ["2 kilderkins", "1 barrel"]]]']],
   [[["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"]]]]])

OVSDB_CHECK_POSITIVE([string map of 10 string to string],
  [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
    '{"2 gills"="1 chopin",
      "2 chopins"= "1 pint",
      "2 pints"= "1 quart",
      "2 quarts"= "1 pottle",
      "2 pottles"= "1 gallon",
      "2 gallons"= "1 peck",
      "2 pecks"= "1 demibushel",
      "2 demibushel"= "1 firkin",
      "2 firkins"= "1 kilderkin",
      "2 kilderkins"= "1 barrel"}']],
   [[{"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"}]])

OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
  [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
    '["map", [[1, true], [2, false], [1, false]]]']],
  [ovsdb error: map contains duplicate key])

OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
  [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
    '1=true 2=false 1=false']],
  [map contains duplicate key])

OVSDB_CHECK_POSITIVE([generate and apply diff -- integer],
  [[diff-data '["integer"]' '[0]' '[2]']],
  [[diff: 2
apply diff: 2
apply diff in place: 2
OK]])

OVSDB_CHECK_POSITIVE([generate and apply diff -- boolean],
  [[diff-data '["boolean"]' '[true]' '[false]']],
  [[diff: false
apply diff: false
apply diff in place: false
OK]])

OVSDB_CHECK_POSITIVE([generate and apply diff -- string],
  [[diff-data '["string"]' '["AAA"]' '["BBB"]']],
  [[diff: "BBB"
apply diff: "BBB"
apply diff in place: "BBB"
OK]])

dnl Test set modifications.
OVSDB_CHECK_POSITIVE([generate and apply diff -- set],
  [[diff-data '{"key": "integer", "min":0, "max": 3}' \
  '["set", [0, 1]]'  '["set", [1,2]]' \
  '["set", [0, 1]]'  '["set", [1]]' \
  '["set", []]'  '["set", [0, 1]]' \
  '["set", [0, 1]]'  '["set", []]'
  ]],
  [[diff: ["set",[0,2]]
apply diff: ["set",[1,2]]
apply diff in place: ["set",[1,2]]
OK
diff: 0
apply diff: 1
apply diff in place: 1
OK
diff: ["set",[0,1]]
apply diff: ["set",[0,1]]
apply diff in place: ["set",[0,1]]
OK
diff: ["set",[0,1]]
apply diff: ["set",[]]
apply diff in place: ["set",[]]
OK]])

dnl Test set modifications causes data to violate set size constrain.
OVSDB_CHECK_NEGATIVE([generate and apply diff -- set -- size error],
  [[diff-data '{"key": "integer", "min":0, "max": 3}' \
  '["set", [0, 1]]'  '["set", [1, 2, 3, 4]]']],
  [[ovsdb error: Datum crated by diff has size error]])

dnl Test set modifications.
OVSDB_CHECK_POSITIVE([generate and apply diff -- map],
  [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
  '["map", [["2 gills", "1 chopin"]]]'  '["map", [["2 pints", "1 quart"]]]' \
  '["map", [["2 gills", "1 chopin"]]]'  '["map", [["2 gills", "1 chopin"]]]' \
  '["map", [["2 gills", "1 chopin"]]]'  '["map", []]' \
  '["map", []]'  '["map", [["2 pints", "1 quart"]]]' \
  '["map", [["2 gills", "1 chopin"]]]'  '["map", [["2 gills", "1 gallon"]]]' \
  ]],
  [[diff: ["map",[["2 gills","1 chopin"],["2 pints","1 quart"]]]
apply diff: ["map",[["2 pints","1 quart"]]]
apply diff in place: ["map",[["2 pints","1 quart"]]]
OK
diff: ["map",[]]
apply diff: ["map",[["2 gills","1 chopin"]]]
apply diff in place: ["map",[["2 gills","1 chopin"]]]
OK
diff: ["map",[["2 gills","1 chopin"]]]
apply diff: ["map",[]]
apply diff in place: ["map",[]]
OK
diff: ["map",[["2 pints","1 quart"]]]
apply diff: ["map",[["2 pints","1 quart"]]]
apply diff in place: ["map",[["2 pints","1 quart"]]]
OK
diff: ["map",[["2 gills","1 gallon"]]]
apply diff: ["map",[["2 gills","1 gallon"]]]
apply diff in place: ["map",[["2 gills","1 gallon"]]]
OK]])

OVSDB_CHECK_NEGATIVE([generate and apply diff with map -- size error],
  [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
  '["map", [["2 gills", "1 chopin"]]]' \
  '["map", [["2 gills", "1 gallon"],
            ["2 pints", "1 quart"],
            ["2 quarts", "1 pottle"],
            ["2 gallons", "1 peck"]]]' \
  ]],
  [[ovsdb error: Datum crated by diff has size error]])