[ovs-dev,3/3] ovsdb-data: Improve grammar in error message.

Message ID 20180907023012.12752-3-blp@ovn.org
State New
Headers show
Series
  • [ovs-dev,1/3] condition: Fix ==, !=, includes, excludes on optional scalars.
Related show

Commit Message

Ben Pfaff Sept. 7, 2018, 2:30 a.m.
"must have exactly one member" is much better than "must have 1 to 1
members".

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/ovsdb-data.c         | 13 +++++--
 tests/ovsdb-condition.at | 90 ++++++++++++++++++++++++------------------------
 2 files changed, 55 insertions(+), 48 deletions(-)

Patch

diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
index 1e523f29cb87..542f79786e6a 100644
--- a/lib/ovsdb-data.c
+++ b/lib/ovsdb-data.c
@@ -1234,9 +1234,16 @@  ovsdb_datum_from_json__(struct ovsdb_datum *datum,
 
         n = inner->array.n;
         if (n < type->n_min || n > type->n_max) {
-            return ovsdb_syntax_error(json, NULL, "%s must have %u to "
-                                      "%u members but %"PRIuSIZE" are present",
-                                      class, type->n_min, type->n_max, n);
+            if (type->n_min == 1 && type->n_max == 1) {
+                return ovsdb_syntax_error(json, NULL, "%s must have exactly "
+                                          "one member but %"PRIuSIZE" "
+                                          "are present", class, n);
+            } else {
+                return ovsdb_syntax_error(json, NULL, "%s must have %u to "
+                                          "%u members but %"PRIuSIZE" are "
+                                          "present",
+                                          class, type->n_min, type->n_max, n);
+            }
         }
 
         datum->n = 0;
diff --git a/tests/ovsdb-condition.at b/tests/ovsdb-condition.at
index 4dee5f9530d5..58af7f638d23 100644
--- a/tests/ovsdb-condition.at
+++ b/tests/ovsdb-condition.at
@@ -157,56 +157,56 @@  test-ovsdb: syntax "["u",">",["uuid","b10d28f7-af18-4a67-9e78-2a6394516c59"]]":
 test-ovsdb: syntax "["u",">=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: ">=" operator may not be applied to column u of type uuid.
 test-ovsdb: syntax "["u","<",["uuid","ad0fa355-8b84-4a36-a4b5-b2c1bfd91758"]]": syntax error: Type mismatch: "<" operator may not be applied to column u of type uuid.
 test-ovsdb: syntax "["u","<=",["uuid","62315898-64e0-40b9-b26f-ff74225303e6"]]": syntax error: Type mismatch: "<=" operator may not be applied to column u of type uuid.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["b",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column b of type boolean.
 test-ovsdb: syntax "["b",">=",["set",[]]]": syntax error: Type mismatch: ">=" operator may not be applied to column b of type boolean.
 test-ovsdb: syntax "["b","<",["set",[]]]": syntax error: Type mismatch: "<" operator may not be applied to column b of type boolean.
 test-ovsdb: syntax "["b","<=",["set",[]]]": syntax error: Type mismatch: "<=" operator may not be applied to column b of type boolean.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["b",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column b of type boolean.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["s",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column s of type string.
 test-ovsdb: syntax "["s",">=",["set",[]]]": syntax error: Type mismatch: ">=" operator may not be applied to column s of type string.
 test-ovsdb: syntax "["s","<",["set",[]]]": syntax error: Type mismatch: "<" operator may not be applied to column s of type string.
 test-ovsdb: syntax "["s","<=",["set",[]]]": syntax error: Type mismatch: "<=" operator may not be applied to column s of type string.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["s",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column s of type string.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["u",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column u of type uuid.
 test-ovsdb: syntax "["u",">=",["set",[]]]": syntax error: Type mismatch: ">=" operator may not be applied to column u of type uuid.
 test-ovsdb: syntax "["u","<",["set",[]]]": syntax error: Type mismatch: "<" operator may not be applied to column u of type uuid.
 test-ovsdb: syntax "["u","<=",["set",[]]]": syntax error: Type mismatch: "<=" operator may not be applied to column u of type uuid.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["u",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column u of type uuid.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 ]])
 AT_CLEANUP
 
@@ -335,16 +335,16 @@  test-ovsdb: syntax "["u",">",["uuid","b10d28f7-af18-4a67-9e78-2a6394516c59"]]":
 test-ovsdb: syntax "["u",">=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: ">=" operator may not be applied to column u of type set of up to 1 uuids.
 test-ovsdb: syntax "["u","<",["uuid","ad0fa355-8b84-4a36-a4b5-b2c1bfd91758"]]": syntax error: Type mismatch: "<" operator may not be applied to column u of type set of up to 1 uuids.
 test-ovsdb: syntax "["u","<=",["uuid","62315898-64e0-40b9-b26f-ff74225303e6"]]": syntax error: Type mismatch: "<=" operator may not be applied to column u of type set of up to 1 uuids.
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
-test-ovsdb: syntax "["set",[]]": syntax error: set must have 1 to 1 members but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
+test-ovsdb: syntax "["set",[]]": syntax error: set must have exactly one member but 0 are present
 test-ovsdb: syntax "["b",">",["set",[]]]": syntax error: Type mismatch: ">" operator may not be applied to column b of type set of up to 1 booleans.
 test-ovsdb: syntax "["b",">=",["set",[]]]": syntax error: Type mismatch: ">=" operator may not be applied to column b of type set of up to 1 booleans.
 test-ovsdb: syntax "["b","<",["set",[]]]": syntax error: Type mismatch: "<" operator may not be applied to column b of type set of up to 1 booleans.