ovsdb: Drop regular expression constraints.
[sliver-openvswitch.git] / tests / ovsdb-types.at
1 AT_BANNER([OVSDB -- atomic types])
2
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])
15
16 AT_BANNER([OVSDB -- base types])
17
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])
30
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])
43
44 OVSDB_CHECK_POSITIVE([boolean], 
45   [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
46
47 OVSDB_CHECK_POSITIVE([string minLength], 
48   [[parse-base-type '{"type": "string", "minLength": 1}']],
49   [{"minLength":1,"type":"string"}])
50 OVSDB_CHECK_POSITIVE([string maxLength], 
51   [[parse-base-type '{"type": "string", "maxLength": 5}']],
52   [{"maxLength":5,"type":"string"}])
53 OVSDB_CHECK_POSITIVE([string minLength and maxLength], 
54   [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
55   [{"maxLength":5,"minLength":1,"type":"string"}])
56 OVSDB_CHECK_NEGATIVE([maxLength must not be less than minLength], 
57   [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
58   [minLength exceeds maxLength])
59 OVSDB_CHECK_NEGATIVE([maxLength must not be negative], 
60   [[parse-base-type '{"type": "string", "maxLength": -1}']],
61   [maxLength out of valid range 0 to 4294967295])
62
63 OVSDB_CHECK_POSITIVE([uuid refTable], 
64   [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
65   [{"refTable":"myTable","type":"uuid"}])
66 OVSDB_CHECK_NEGATIVE([uuid refTable must be valid id], 
67   [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
68   [Type mismatch for member 'refTable'])
69
70 OVSDB_CHECK_NEGATIVE([void is not a valid base-type],
71   [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
72 OVSDB_CHECK_NEGATIVE(["type" member must be present],
73   [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
74
75 AT_BANNER([OVSDB -- simple types])
76
77 OVSDB_CHECK_POSITIVE([simple integer], 
78   [[parse-type '["integer"]' ]], ["integer"])
79 OVSDB_CHECK_POSITIVE([simple real], 
80   [[parse-type '["real"]' ]], ["real"])
81 OVSDB_CHECK_POSITIVE([simple boolean], 
82   [[parse-type '["boolean"]' ]], ["boolean"])
83 OVSDB_CHECK_POSITIVE([simple string], 
84   [[parse-type '["string"]' ]], ["string"])
85 OVSDB_CHECK_POSITIVE([simple uuid], 
86   [[parse-type '["uuid"]' ]], ["uuid"])
87 OVSDB_CHECK_POSITIVE([integer in object],
88   [[parse-type '{"key": "integer"}' ]], ["integer"])
89 OVSDB_CHECK_POSITIVE([real in object with explicit min and max],
90   [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
91
92 OVSDB_CHECK_NEGATIVE([key type is required],
93   [[parse-type '{}' ]], [Required 'key' member is missing.])
94 OVSDB_CHECK_NEGATIVE([void is not a valid type],
95   [[parse-type '["void"]' ]], ["void" is not an atomic-type])
96
97 AT_BANNER([OVSDB -- set types])
98
99 OVSDB_CHECK_POSITIVE([optional boolean],
100   [[parse-type '{"key": "boolean", "min": 0}' ]], 
101   [[{"key":"boolean","min":0}]],
102   [set])
103 OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
104   [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]], 
105   [[{"key":"uuid","max":3}]])
106 OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
107   [[parse-type '{"key": "string", "min": 0, "max": 3}' ]], 
108   [[{"key":"string","max":3,"min":0}]])
109 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
110   [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
111   [[{"key":"integer","max":"unlimited","min":0}]])
112 OVSDB_CHECK_POSITIVE([set of 1 or more reals],
113   [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
114   [[{"key":"real","max":"unlimited"}]])
115
116 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
117   [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
118   [ovsdb type fails constraint checks])
119 OVSDB_CHECK_NEGATIVE([set max cannot be negative],
120   [[parse-type '{"key": "real", "max": -1}' ]],
121   [bad min or max value])
122 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
123   [[parse-type '{"key": "real", "min": -1}' ]],
124   [bad min or max value])
125 OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
126   [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
127   [ovsdb type fails constraint checks])
128
129 AT_BANNER([OVSDB -- map types])
130
131 OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
132  [[parse-type '{"key": "integer", "value": "boolean"}' ]],
133  [[{"key":"integer","value":"boolean"}]])
134 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
135  [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
136  [[{"key":"boolean","value":"integer"}]])
137 OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
138  [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
139  [[{"key":"uuid","max":5,"value":"real"}]])
140 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
141  [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
142  [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
143 OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
144  [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
145  [[{"key":"real","max":20,"value":"string"}]])
146 OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
147  [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
148  [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
149
150 OVSDB_CHECK_NEGATIVE([map key type is required],
151  [[parse-type '{"value": "integer"}' ]],
152  [Required 'key' member is missing.])