ebaffff77246c32bce591f55ec8e0c3e35a341f8
[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 -- simple types])
17
18 OVSDB_CHECK_POSITIVE([simple integer], 
19   [[parse-type '["integer"]' ]], ["integer"])
20 OVSDB_CHECK_POSITIVE([simple real], 
21   [[parse-type '["real"]' ]], ["real"])
22 OVSDB_CHECK_POSITIVE([simple boolean], 
23   [[parse-type '["boolean"]' ]], ["boolean"])
24 OVSDB_CHECK_POSITIVE([simple string], 
25   [[parse-type '["string"]' ]], ["string"])
26 OVSDB_CHECK_POSITIVE([simple uuid], 
27   [[parse-type '["uuid"]' ]], ["uuid"])
28 OVSDB_CHECK_POSITIVE([integer in object],
29   [[parse-type '{"key": "integer"}' ]], ["integer"])
30 OVSDB_CHECK_POSITIVE([real in object with explicit min and max],
31   [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
32
33 OVSDB_CHECK_NEGATIVE([key type is required],
34   [[parse-type '{}' ]], [Required 'key' member is missing.])
35 OVSDB_CHECK_NEGATIVE([void is not a valid type],
36   [[parse-type '["void"]' ]], ["void" is not an atomic-type])
37
38 AT_BANNER([OVSDB -- set types])
39
40 OVSDB_CHECK_POSITIVE([optional boolean],
41   [[parse-type '{"key": "boolean", "min": 0}' ]], 
42   [[{"key":"boolean","min":0}]],
43   [set])
44 OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
45   [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]], 
46   [[{"key":"uuid","max":3}]])
47 OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
48   [[parse-type '{"key": "string", "min": 0, "max": 3}' ]], 
49   [[{"key":"string","max":3,"min":0}]])
50 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
51   [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
52   [[{"key":"integer","max":"unlimited","min":0}]])
53 OVSDB_CHECK_POSITIVE([set of 1 or more reals],
54   [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
55   [[{"key":"real","max":"unlimited"}]])
56
57 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
58   [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
59   [ovsdb type fails constraint checks])
60 OVSDB_CHECK_NEGATIVE([set max cannot be negative],
61   [[parse-type '{"key": "real", "max": -1}' ]],
62   [bad min or max value])
63 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
64   [[parse-type '{"key": "real", "min": -1}' ]],
65   [bad min or max value])
66 OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
67   [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
68   [ovsdb type fails constraint checks])
69
70 AT_BANNER([OVSDB -- map types])
71
72 OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
73  [[parse-type '{"key": "integer", "value": "boolean"}' ]],
74  [[{"key":"integer","value":"boolean"}]])
75 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
76  [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
77  [[{"key":"boolean","value":"integer"}]])
78 OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
79  [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
80  [[{"key":"uuid","max":5,"value":"real"}]])
81 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
82  [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
83  [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
84 OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
85  [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
86  [[{"key":"real","max":20,"value":"string"}]])
87 OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
88  [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
89  [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
90
91 OVSDB_CHECK_NEGATIVE([map key type is required],
92  [[parse-type '{"value": "integer"}' ]],
93  [Required 'key' member is missing.])