Commit 12884987 authored by Peter Eisentraut's avatar Peter Eisentraut

Additional test coverage for boolean type (bool.c)

parent 44d5be0e
...@@ -11,7 +11,19 @@ SELECT 1 AS one; ...@@ -11,7 +11,19 @@ SELECT 1 AS one;
(1 row) (1 row)
-- ******************testing built-in type bool******************** -- ******************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; SELECT bool 't' AS true;
true true
------ ------
...@@ -24,6 +36,83 @@ SELECT bool ' f ' AS false; ...@@ -24,6 +36,83 @@ SELECT bool ' f ' AS false;
f f
(1 row) (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; SELECT bool 't' or bool 'f' AS true;
true true
------ ------
...@@ -54,6 +143,30 @@ SELECT bool 't' <> bool 'f' AS true; ...@@ -54,6 +143,30 @@ SELECT bool 't' <> bool 'f' AS true;
t t
(1 row) (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 -- explicit casts to/from text
SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false; SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
true | false true | false
......
...@@ -10,12 +10,48 @@ SELECT 1 AS one; ...@@ -10,12 +10,48 @@ SELECT 1 AS one;
-- ******************testing built-in type bool******************** -- ******************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 't' AS true;
SELECT bool ' f ' AS false; 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' or bool 'f' AS true;
SELECT bool 't' and bool 'f' AS false; SELECT bool 't' and bool 'f' AS false;
...@@ -26,6 +62,14 @@ SELECT bool 't' = 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 't' >= bool 'f' AS true;
SELECT bool 'f' < bool 't' AS true;
SELECT bool 'f' <= bool 't' AS true;
-- explicit casts to/from text -- explicit casts to/from text
SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false; SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
SELECT ' true '::text::boolean AS true, SELECT ' true '::text::boolean AS true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment