From 128849875f33953cc19a7238f15c9398c0490171 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 5 Oct 2008 14:20:03 +0000 Subject: [PATCH] Additional test coverage for boolean type (bool.c) --- src/test/regress/expected/boolean.out | 115 +++++++++++++++++++++++++++++++++- src/test/regress/sql/boolean.sql | 46 +++++++++++++- 2 files changed, 159 insertions(+), 2 deletions(-) diff --git a/src/test/regress/expected/boolean.out b/src/test/regress/expected/boolean.out index e66f33702b..a3629f2282 100644 --- a/src/test/regress/expected/boolean.out +++ b/src/test/regress/expected/boolean.out @@ -11,7 +11,19 @@ SELECT 1 AS one; (1 row) -- ******************testing built-in type bool******************** --- check bool type-casting as well as and, or, not in qualifications-- +-- check bool input syntax +SELECT true AS true; + true +------ + t +(1 row) + +SELECT false AS false; + false +------- + f +(1 row) + SELECT bool 't' AS true; true ------ @@ -24,6 +36,83 @@ SELECT bool ' f ' AS false; f (1 row) +SELECT bool 'true' AS true; + true +------ + t +(1 row) + +SELECT bool 'test' AS error; +ERROR: invalid input syntax for type boolean: "test" +LINE 1: SELECT bool 'test' AS error; + ^ +SELECT bool 'false' AS false; + false +------- + f +(1 row) + +SELECT bool 'foo' AS error; +ERROR: invalid input syntax for type boolean: "foo" +LINE 1: SELECT bool 'foo' AS error; + ^ +SELECT bool 'y' AS true; + true +------ + t +(1 row) + +SELECT bool 'yes' AS true; + true +------ + t +(1 row) + +SELECT bool 'yeah' AS error; +ERROR: invalid input syntax for type boolean: "yeah" +LINE 1: SELECT bool 'yeah' AS error; + ^ +SELECT bool 'n' AS false; + false +------- + f +(1 row) + +SELECT bool 'no' AS false; + false +------- + f +(1 row) + +SELECT bool 'nay' AS error; +ERROR: invalid input syntax for type boolean: "nay" +LINE 1: SELECT bool 'nay' AS error; + ^ +SELECT bool '1' AS true; + true +------ + t +(1 row) + +SELECT bool '11' AS error; +ERROR: invalid input syntax for type boolean: "11" +LINE 1: SELECT bool '11' AS error; + ^ +SELECT bool '0' AS false; + false +------- + f +(1 row) + +SELECT bool '000' AS error; +ERROR: invalid input syntax for type boolean: "000" +LINE 1: SELECT bool '000' AS error; + ^ +SELECT bool '' AS error; +ERROR: invalid input syntax for type boolean: "" +LINE 1: SELECT bool '' AS error; + ^ +-- and, or, not in qualifications SELECT bool 't' or bool 'f' AS true; true ------ @@ -54,6 +143,30 @@ SELECT bool 't' <> bool 'f' AS true; t (1 row) +SELECT bool 't' > bool 'f' AS true; + true +------ + t +(1 row) + +SELECT bool 't' >= bool 'f' AS true; + true +------ + t +(1 row) + +SELECT bool 'f' < bool 't' AS true; + true +------ + t +(1 row) + +SELECT bool 'f' <= bool 't' AS true; + true +------ + t +(1 row) + -- explicit casts to/from text SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false; true | false diff --git a/src/test/regress/sql/boolean.sql b/src/test/regress/sql/boolean.sql index c68f02e7a5..63dd22f877 100644 --- a/src/test/regress/sql/boolean.sql +++ b/src/test/regress/sql/boolean.sql @@ -10,12 +10,48 @@ SELECT 1 AS one; -- ******************testing built-in type bool******************** --- check bool type-casting as well as and, or, not in qualifications-- +-- check bool input syntax + +SELECT true AS true; + +SELECT false AS false; SELECT bool 't' AS true; SELECT bool ' f ' AS false; +SELECT bool 'true' AS true; + +SELECT bool 'test' AS error; + +SELECT bool 'false' AS false; + +SELECT bool 'foo' AS error; + +SELECT bool 'y' AS true; + +SELECT bool 'yes' AS true; + +SELECT bool 'yeah' AS error; + +SELECT bool 'n' AS false; + +SELECT bool 'no' AS false; + +SELECT bool 'nay' AS error; + +SELECT bool '1' AS true; + +SELECT bool '11' AS error; + +SELECT bool '0' AS false; + +SELECT bool '000' AS error; + +SELECT bool '' AS error; + +-- and, or, not in qualifications + SELECT bool 't' or bool 'f' AS true; SELECT bool 't' and bool 'f' AS false; @@ -26,6 +62,14 @@ SELECT bool 't' = bool 'f' AS false; SELECT bool 't' <> bool 'f' AS true; +SELECT bool 't' > bool 'f' AS true; + +SELECT bool 't' >= bool 'f' AS true; + +SELECT bool 'f' < bool 't' AS true; + +SELECT bool 'f' <= bool 't' AS true; + -- explicit casts to/from text SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false; SELECT ' true '::text::boolean AS true, -- 2.11.0