Additional test coverage for boolean type (bool.c)

This commit is contained in:
Peter Eisentraut 2008-10-05 14:20:03 +00:00
parent 44d5be0e53
commit 128849875f
2 changed files with 159 additions and 2 deletions

View File

@ -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

View File

@ -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,