1 AT_BANNER([OVSDB -- atomic types])
3 OVSDB_CHECK_POSITIVE([integer],
4 [[parse-atomic-type '["integer"]' ]], ["integer"])
5 OVSDB_CHECK_POSITIVE([real],
6 [[parse-atomic-type '["real"]' ]], ["real"])
7 OVSDB_CHECK_POSITIVE([boolean],
8 [[parse-atomic-type '["boolean"]' ]], ["boolean"])
9 OVSDB_CHECK_POSITIVE([string],
10 [[parse-atomic-type '["string"]' ]], ["string"])
11 OVSDB_CHECK_POSITIVE([uuid],
12 [[parse-atomic-type '["uuid"]' ]], ["uuid"])
13 OVSDB_CHECK_NEGATIVE([void is not a valid atomic-type],
14 [[parse-atomic-type '["void"]' ]], ["void" is not an atomic-type])
16 AT_BANNER([OVSDB -- base types])
18 OVSDB_CHECK_POSITIVE([integer >= 5],
19 [[parse-base-type '{"type": "integer", "minInteger": 5}' ]],
20 [{"minInteger":5,"type":"integer"}])
21 OVSDB_CHECK_POSITIVE([integer <= 7],
22 [[parse-base-type '{"type": "integer", "maxInteger": 7}' ]],
23 [{"maxInteger":7,"type":"integer"}])
24 OVSDB_CHECK_POSITIVE([integer between -5 and 10],
25 [[parse-base-type '{"type": "integer", "minInteger": -5, "maxInteger": 10}']],
26 [{"maxInteger":10,"minInteger":-5,"type":"integer"}])
27 OVSDB_CHECK_NEGATIVE([integer max may not be less than min],
28 [[parse-base-type '{"type": "integer", "minInteger": 5, "maxInteger": 3}']],
29 [minInteger exceeds maxInteger])
31 OVSDB_CHECK_POSITIVE([real >= -1.5],
32 [[parse-base-type '{"type": "real", "minReal": -1.5}']],
33 [{"minReal":-1.5,"type":"real"}])
34 OVSDB_CHECK_POSITIVE([real <= 1e5],
35 [[parse-base-type '{"type": "real", "maxReal": 1e5}']],
36 [{"maxReal":100000,"type":"real"}])
37 OVSDB_CHECK_POSITIVE([real between -2.5 and 3.75],
38 [[parse-base-type '{"type": "real", "minReal": -2.5, "maxReal": 3.75}']],
39 [{"maxReal":3.75,"minReal":-2.5,"type":"real"}])
40 OVSDB_CHECK_NEGATIVE([real max may not be less than min],
41 [[parse-base-type '{"type": "real", "minReal": 555, "maxReal": 444}']],
42 [minReal exceeds maxReal])
44 OVSDB_CHECK_POSITIVE([boolean],
45 [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
47 OVSDB_CHECK_POSITIVE([string reMatch],
48 [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}"}']],
49 [{"reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
50 OVSDB_CHECK_POSITIVE([string reMatch + reComment],
51 [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}", "reComment": "US-style telephone number"}']],
52 [{"reComment":"US-style telephone number","reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
53 OVSDB_CHECK_NEGATIVE([reMatch must be a valid JavaScript regexp],
54 [[parse-base-type '{"type": "string", "reMatch": "ab@:>@cd"}']],
55 [[test-ovsdb: invalid regular expression: "ab@:>@cd" is not a valid regular expression: @:>@ is an invalid data character in JavaScript compatibility mode]])
57 OVSDB_CHECK_POSITIVE([string minLength],
58 [[parse-base-type '{"type": "string", "minLength": 1}']],
59 [{"minLength":1,"type":"string"}])
60 OVSDB_CHECK_POSITIVE([string maxLength],
61 [[parse-base-type '{"type": "string", "maxLength": 5}']],
62 [{"maxLength":5,"type":"string"}])
63 OVSDB_CHECK_POSITIVE([string minLength and maxLength],
64 [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
65 [{"maxLength":5,"minLength":1,"type":"string"}])
66 OVSDB_CHECK_NEGATIVE([maxLength must not be less than minLength],
67 [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
68 [minLength exceeds maxLength])
69 OVSDB_CHECK_NEGATIVE([maxLength must not be negative],
70 [[parse-base-type '{"type": "string", "maxLength": -1}']],
71 [maxLength out of valid range 0 to 4294967295])
73 OVSDB_CHECK_POSITIVE([uuid refTable],
74 [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
75 [{"refTable":"myTable","type":"uuid"}])
76 OVSDB_CHECK_NEGATIVE([uuid refTable must be valid id],
77 [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
78 [Type mismatch for member 'refTable'])
80 OVSDB_CHECK_NEGATIVE([void is not a valid base-type],
81 [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
82 OVSDB_CHECK_NEGATIVE(["type" member must be present],
83 [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
85 AT_BANNER([OVSDB -- simple types])
87 OVSDB_CHECK_POSITIVE([simple integer],
88 [[parse-type '["integer"]' ]], ["integer"])
89 OVSDB_CHECK_POSITIVE([simple real],
90 [[parse-type '["real"]' ]], ["real"])
91 OVSDB_CHECK_POSITIVE([simple boolean],
92 [[parse-type '["boolean"]' ]], ["boolean"])
93 OVSDB_CHECK_POSITIVE([simple string],
94 [[parse-type '["string"]' ]], ["string"])
95 OVSDB_CHECK_POSITIVE([simple uuid],
96 [[parse-type '["uuid"]' ]], ["uuid"])
97 OVSDB_CHECK_POSITIVE([integer in object],
98 [[parse-type '{"key": "integer"}' ]], ["integer"])
99 OVSDB_CHECK_POSITIVE([real in object with explicit min and max],
100 [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
102 OVSDB_CHECK_NEGATIVE([key type is required],
103 [[parse-type '{}' ]], [Required 'key' member is missing.])
104 OVSDB_CHECK_NEGATIVE([void is not a valid type],
105 [[parse-type '["void"]' ]], ["void" is not an atomic-type])
107 AT_BANNER([OVSDB -- set types])
109 OVSDB_CHECK_POSITIVE([optional boolean],
110 [[parse-type '{"key": "boolean", "min": 0}' ]],
111 [[{"key":"boolean","min":0}]],
113 OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
114 [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]],
115 [[{"key":"uuid","max":3}]])
116 OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
117 [[parse-type '{"key": "string", "min": 0, "max": 3}' ]],
118 [[{"key":"string","max":3,"min":0}]])
119 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
120 [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
121 [[{"key":"integer","max":"unlimited","min":0}]])
122 OVSDB_CHECK_POSITIVE([set of 1 or more reals],
123 [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
124 [[{"key":"real","max":"unlimited"}]])
126 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
127 [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
128 [ovsdb type fails constraint checks])
129 OVSDB_CHECK_NEGATIVE([set max cannot be negative],
130 [[parse-type '{"key": "real", "max": -1}' ]],
131 [bad min or max value])
132 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
133 [[parse-type '{"key": "real", "min": -1}' ]],
134 [bad min or max value])
135 OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
136 [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
137 [ovsdb type fails constraint checks])
139 AT_BANNER([OVSDB -- map types])
141 OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
142 [[parse-type '{"key": "integer", "value": "boolean"}' ]],
143 [[{"key":"integer","value":"boolean"}]])
144 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
145 [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
146 [[{"key":"boolean","value":"integer"}]])
147 OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
148 [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
149 [[{"key":"uuid","max":5,"value":"real"}]])
150 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
151 [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
152 [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
153 OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
154 [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
155 [[{"key":"real","max":20,"value":"string"}]])
156 OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
157 [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
158 [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
160 OVSDB_CHECK_NEGATIVE([map key type is required],
161 [[parse-type '{"value": "integer"}' ]],
162 [Required 'key' member is missing.])