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_CPY([no invalid UTF-8 sequences in strings],
+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: "m4_esyscmd([printf "\300"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
-constraint violation: "m4_esyscmd([printf "\355\240\200"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0],
- [], [], [xfail])
+ [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_PY([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' ]],
[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])
"ab"
"abc"
constraint violation: "𝄞" length 1 is less than minimum allowed length 2]],
- [], [], [xfail])
+ [],
+ [],
+ [dnl This test requires a wide build of Python.
+ AT_CHECK([$PYTHON -c 'unichr(0x10000)' || exit 77],
+ [0], [ignore], [ignore])])
OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
[[parse-atoms '{"type": "string", "maxLength": 2}' \
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]]]']],
+ [["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],
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"]]]']],
+ ["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": "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
+OK]])
+
+OVSDB_CHECK_POSITIVE([generate and apply diff -- boolean],
+ [[diff-data '["boolean"]' '[true]' '[false]']],
+ [[diff: false
+apply diff: false
+OK]])
+
+OVSDB_CHECK_POSITIVE([generate and apply diff -- string],
+ [[diff-data '["string"]' '["AAA"]' '["BBB"]']],
+ [[diff: "BBB"
+apply diff: "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]]
+OK
+diff: 0
+apply diff: 1
+OK
+diff: ["set",[0,1]]
+apply diff: ["set",[0,1]]
+OK
+diff: ["set",[0,1]]
+apply diff: ["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"]]]
+OK
+diff: ["map",[]]
+apply diff: ["map",[["2 gills","1 chopin"]]]
+OK
+diff: ["map",[["2 gills","1 chopin"]]]
+apply diff: ["map",[]]
+OK
+diff: ["map",[["2 pints","1 quart"]]]
+apply diff: ["map",[["2 pints","1 quart"]]]
+OK
+diff: ["map",[["2 gills","1 gallon"]]]
+apply diff: ["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]])