Fix excessive white space in manpages.
[openvswitch] / tests / ovsdb-types.at
index 9a92a5ca65bad57cd403ecce86ed640b38851869..d05277666cdf6e3550f1d773a5b39f59c6d867f5 100644 (file)
@@ -13,6 +13,90 @@ OVSDB_CHECK_POSITIVE([uuid],
 OVSDB_CHECK_NEGATIVE([void is not a valid atomic-type],
   [[parse-atomic-type '["void"]' ]], ["void" is not an atomic-type])
 
+AT_BANNER([OVSDB -- base types])
+
+OVSDB_CHECK_POSITIVE([integer >= 5], 
+  [[parse-base-type '{"type": "integer", "minInteger": 5}' ]],
+  [{"minInteger":5,"type":"integer"}])
+OVSDB_CHECK_POSITIVE([integer <= 7], 
+  [[parse-base-type '{"type": "integer", "maxInteger": 7}' ]],
+  [{"maxInteger":7,"type":"integer"}])
+OVSDB_CHECK_POSITIVE([integer between -5 and 10], 
+  [[parse-base-type '{"type": "integer", "minInteger": -5, "maxInteger": 10}']],
+  [{"maxInteger":10,"minInteger":-5,"type":"integer"}])
+OVSDB_CHECK_NEGATIVE([integer max may not be less than min],
+  [[parse-base-type '{"type": "integer", "minInteger": 5, "maxInteger": 3}']],
+  [minInteger exceeds maxInteger])
+
+OVSDB_CHECK_POSITIVE([real >= -1.5], 
+  [[parse-base-type '{"type": "real", "minReal": -1.5}']],
+  [{"minReal":-1.5,"type":"real"}])
+OVSDB_CHECK_POSITIVE([real <= 1e5], 
+  [[parse-base-type '{"type": "real", "maxReal": 1e5}']],
+  [{"maxReal":100000,"type":"real"}])
+OVSDB_CHECK_POSITIVE([real between -2.5 and 3.75], 
+  [[parse-base-type '{"type": "real", "minReal": -2.5, "maxReal": 3.75}']],
+  [{"maxReal":3.75,"minReal":-2.5,"type":"real"}])
+OVSDB_CHECK_NEGATIVE([real max may not be less than min], 
+  [[parse-base-type '{"type": "real", "minReal": 555, "maxReal": 444}']],
+  [minReal exceeds maxReal])
+
+OVSDB_CHECK_POSITIVE([boolean], 
+  [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
+
+OVSDB_CHECK_POSITIVE([string reMatch], 
+  [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}"}']],
+  [{"reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
+OVSDB_CHECK_POSITIVE([string reMatch + reComment], 
+  [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}", "reComment": "US-style telephone number"}']],
+  [{"reComment":"US-style telephone number","reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
+
+AT_SETUP([reMatch must be a valid regexp])
+AT_KEYWORDS([ovsdb negative])
+if test "$HAVE_PCRE" = yes; then
+   AT_CHECK(
+     [[test-ovsdb parse-base-type \
+                  '{"type": "string", "reMatch": "x{2,1}"}']],
+     [1], [],
+     [[test-ovsdb: invalid regular expression: "x{2,1}" is not a valid regular expression: numbers out of order in {} quantifier
+]])
+else
+   AT_CHECK(
+     [[test-ovsdb parse-base-type \
+                  '{"type": "string", "reMatch": "x{2,1}"}']],
+     [0], [[{"reMatch":"x{2,1}","type":"string"}
+]], [])
+fi
+AT_CLEANUP
+
+OVSDB_CHECK_POSITIVE([string minLength], 
+  [[parse-base-type '{"type": "string", "minLength": 1}']],
+  [{"minLength":1,"type":"string"}])
+OVSDB_CHECK_POSITIVE([string maxLength], 
+  [[parse-base-type '{"type": "string", "maxLength": 5}']],
+  [{"maxLength":5,"type":"string"}])
+OVSDB_CHECK_POSITIVE([string minLength and maxLength], 
+  [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
+  [{"maxLength":5,"minLength":1,"type":"string"}])
+OVSDB_CHECK_NEGATIVE([maxLength must not be less than minLength], 
+  [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
+  [minLength exceeds maxLength])
+OVSDB_CHECK_NEGATIVE([maxLength must not be negative], 
+  [[parse-base-type '{"type": "string", "maxLength": -1}']],
+  [maxLength out of valid range 0 to 4294967295])
+
+OVSDB_CHECK_POSITIVE([uuid refTable], 
+  [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
+  [{"refTable":"myTable","type":"uuid"}])
+OVSDB_CHECK_NEGATIVE([uuid refTable must be valid id], 
+  [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
+  [Type mismatch for member 'refTable'])
+
+OVSDB_CHECK_NEGATIVE([void is not a valid base-type],
+  [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
+OVSDB_CHECK_NEGATIVE(["type" member must be present],
+  [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
+
 AT_BANNER([OVSDB -- simple types])
 
 OVSDB_CHECK_POSITIVE([simple integer], 
@@ -50,9 +134,9 @@ OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
   [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
   [[{"key":"integer","max":"unlimited","min":0}]])
-OVSDB_CHECK_POSITIVE([set of 10 or more reals],
-  [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
-  [[{"key":"real","max":"unlimited","min":10}]])
+OVSDB_CHECK_POSITIVE([set of 1 or more reals],
+  [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
+  [[{"key":"real","max":"unlimited"}]])
 
 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
   [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
@@ -63,6 +147,9 @@ OVSDB_CHECK_NEGATIVE([set max cannot be negative],
 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
   [[parse-type '{"key": "real", "min": -1}' ]],
   [bad min or max value])
+OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
+  [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
+  [ovsdb type fails constraint checks])
 
 AT_BANNER([OVSDB -- map types])
 
@@ -72,18 +159,18 @@ OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
  [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
  [[{"key":"boolean","value":"integer"}]])
-OVSDB_CHECK_POSITIVE([map of 2 to 5 uuid to real],
- [[parse-type '{"key": "uuid", "value": "real", "min": 2, "max": 5}' ]],
- [[{"key":"uuid","max":5,"min":2,"value":"real"}]])
+OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
+ [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
+ [[{"key":"uuid","max":5,"value":"real"}]])
 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
  [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
  [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
-OVSDB_CHECK_POSITIVE([map of 10 to 20 real to string],
- [[parse-type '{"key": "real", "value": "string", "min": 10, "max": 20}' ]],
- [[{"key":"real","max":20,"min":10,"value":"string"}]])
-OVSDB_CHECK_POSITIVE([map of 20 or more string to real],
- [[parse-type '{"key": "string", "value": "real", "min": 20, "max": "unlimited"}' ]],
- [[{"key":"string","max":"unlimited","min":20,"value":"real"}]])
+OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
+ [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
+ [[{"key":"real","max":20,"value":"string"}]])
+OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
+ [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
+ [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
 
 OVSDB_CHECK_NEGATIVE([map key type is required],
  [[parse-type '{"value": "integer"}' ]],