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_NEGATIVE([void is not a valid base-type],
74 [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
75 OVSDB_CHECK_NEGATIVE(["type" member must be present],
76 [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
78 AT_BANNER([OVSDB -- simple types])
80 OVSDB_CHECK_POSITIVE([simple integer],
81 [[parse-type '["integer"]' ]], ["integer"])
82 OVSDB_CHECK_POSITIVE([simple real],
83 [[parse-type '["real"]' ]], ["real"])
84 OVSDB_CHECK_POSITIVE([simple boolean],
85 [[parse-type '["boolean"]' ]], ["boolean"])
86 OVSDB_CHECK_POSITIVE([simple string],
87 [[parse-type '["string"]' ]], ["string"])
88 OVSDB_CHECK_POSITIVE([simple uuid],
89 [[parse-type '["uuid"]' ]], ["uuid"])
90 OVSDB_CHECK_POSITIVE([integer in object],
91 [[parse-type '{"key": "integer"}' ]], ["integer"])
92 OVSDB_CHECK_POSITIVE([real in object with explicit min and max],
93 [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
95 OVSDB_CHECK_NEGATIVE([key type is required],
96 [[parse-type '{}' ]], [Required 'key' member is missing.])
97 OVSDB_CHECK_NEGATIVE([void is not a valid type],
98 [[parse-type '["void"]' ]], ["void" is not an atomic-type])
100 AT_BANNER([OVSDB -- set types])
102 OVSDB_CHECK_POSITIVE([optional boolean],
103 [[parse-type '{"key": "boolean", "min": 0}' ]],
104 [[{"key":"boolean","min":0}]],
106 OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
107 [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]],
108 [[{"key":"uuid","max":3}]])
109 OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
110 [[parse-type '{"key": "string", "min": 0, "max": 3}' ]],
111 [[{"key":"string","max":3,"min":0}]])
112 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
113 [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
114 [[{"key":"integer","max":"unlimited","min":0}]])
115 OVSDB_CHECK_POSITIVE([set of 1 or more reals],
116 [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
117 [[{"key":"real","max":"unlimited"}]])
119 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
120 [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
121 [ovsdb type fails constraint checks])
122 OVSDB_CHECK_NEGATIVE([set max cannot be negative],
123 [[parse-type '{"key": "real", "max": -1}' ]],
124 [bad min or max value])
125 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
126 [[parse-type '{"key": "real", "min": -1}' ]],
127 [bad min or max value])
128 OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
129 [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
130 [ovsdb type fails constraint checks])
132 AT_BANNER([OVSDB -- map types])
134 OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
135 [[parse-type '{"key": "integer", "value": "boolean"}' ]],
136 [[{"key":"integer","value":"boolean"}]])
137 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
138 [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
139 [[{"key":"boolean","value":"integer"}]])
140 OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
141 [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
142 [[{"key":"uuid","max":5,"value":"real"}]])
143 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
144 [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
145 [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
146 OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
147 [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
148 [[{"key":"real","max":20,"value":"string"}]])
149 OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
150 [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
151 [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
153 OVSDB_CHECK_NEGATIVE([map key type is required],
154 [[parse-type '{"value": "integer"}' ]],
155 [Required 'key' member is missing.])