Skip to content

Commit 1288498

Browse files
committed
Additional test coverage for boolean type (bool.c)
1 parent 44d5be0 commit 1288498

File tree

2 files changed

+159
-2
lines changed

2 files changed

+159
-2
lines changed

src/test/regress/expected/boolean.out

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ SELECT 1 AS one;
1111
(1 row)
1212

1313
-- ******************testing built-in type bool********************
14-
-- check bool type-casting as well as and, or, not in qualifications--
14+
-- check bool input syntax
15+
SELECT true AS true;
16+
true
17+
------
18+
t
19+
(1 row)
20+
21+
SELECT false AS false;
22+
false
23+
-------
24+
f
25+
(1 row)
26+
1527
SELECT bool 't' AS true;
1628
true
1729
------
@@ -24,6 +36,83 @@ SELECT bool ' f ' AS false;
2436
f
2537
(1 row)
2638

39+
SELECT bool 'true' AS true;
40+
true
41+
------
42+
t
43+
(1 row)
44+
45+
SELECT bool 'test' AS error;
46+
ERROR: invalid input syntax for type boolean: "test"
47+
LINE 1: SELECT bool 'test' AS error;
48+
^
49+
SELECT bool 'false' AS false;
50+
false
51+
-------
52+
f
53+
(1 row)
54+
55+
SELECT bool 'foo' AS error;
56+
ERROR: invalid input syntax for type boolean: "foo"
57+
LINE 1: SELECT bool 'foo' AS error;
58+
^
59+
SELECT bool 'y' AS true;
60+
true
61+
------
62+
t
63+
(1 row)
64+
65+
SELECT bool 'yes' AS true;
66+
true
67+
------
68+
t
69+
(1 row)
70+
71+
SELECT bool 'yeah' AS error;
72+
ERROR: invalid input syntax for type boolean: "yeah"
73+
LINE 1: SELECT bool 'yeah' AS error;
74+
^
75+
SELECT bool 'n' AS false;
76+
false
77+
-------
78+
f
79+
(1 row)
80+
81+
SELECT bool 'no' AS false;
82+
false
83+
-------
84+
f
85+
(1 row)
86+
87+
SELECT bool 'nay' AS error;
88+
ERROR: invalid input syntax for type boolean: "nay"
89+
LINE 1: SELECT bool 'nay' AS error;
90+
^
91+
SELECT bool '1' AS true;
92+
true
93+
------
94+
t
95+
(1 row)
96+
97+
SELECT bool '11' AS error;
98+
ERROR: invalid input syntax for type boolean: "11"
99+
LINE 1: SELECT bool '11' AS error;
100+
^
101+
SELECT bool '0' AS false;
102+
false
103+
-------
104+
f
105+
(1 row)
106+
107+
SELECT bool '000' AS error;
108+
ERROR: invalid input syntax for type boolean: "000"
109+
LINE 1: SELECT bool '000' AS error;
110+
^
111+
SELECT bool '' AS error;
112+
ERROR: invalid input syntax for type boolean: ""
113+
LINE 1: SELECT bool '' AS error;
114+
^
115+
-- and, or, not in qualifications
27116
SELECT bool 't' or bool 'f' AS true;
28117
true
29118
------
@@ -54,6 +143,30 @@ SELECT bool 't' <> bool 'f' AS true;
54143
t
55144
(1 row)
56145

146+
SELECT bool 't' > bool 'f' AS true;
147+
true
148+
------
149+
t
150+
(1 row)
151+
152+
SELECT bool 't' >= bool 'f' AS true;
153+
true
154+
------
155+
t
156+
(1 row)
157+
158+
SELECT bool 'f' < bool 't' AS true;
159+
true
160+
------
161+
t
162+
(1 row)
163+
164+
SELECT bool 'f' <= bool 't' AS true;
165+
true
166+
------
167+
t
168+
(1 row)
169+
57170
-- explicit casts to/from text
58171
SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
59172
true | false

src/test/regress/sql/boolean.sql

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,48 @@ SELECT 1 AS one;
1010

1111
-- ******************testing built-in type bool********************
1212

13-
-- check bool type-casting as well as and, or, not in qualifications--
13+
-- check bool input syntax
14+
15+
SELECT true AS true;
16+
17+
SELECT false AS false;
1418

1519
SELECT bool 't' AS true;
1620

1721
SELECT bool ' f ' AS false;
1822

23+
SELECT bool 'true' AS true;
24+
25+
SELECT bool 'test' AS error;
26+
27+
SELECT bool 'false' AS false;
28+
29+
SELECT bool 'foo' AS error;
30+
31+
SELECT bool 'y' AS true;
32+
33+
SELECT bool 'yes' AS true;
34+
35+
SELECT bool 'yeah' AS error;
36+
37+
SELECT bool 'n' AS false;
38+
39+
SELECT bool 'no' AS false;
40+
41+
SELECT bool 'nay' AS error;
42+
43+
SELECT bool '1' AS true;
44+
45+
SELECT bool '11' AS error;
46+
47+
SELECT bool '0' AS false;
48+
49+
SELECT bool '000' AS error;
50+
51+
SELECT bool '' AS error;
52+
53+
-- and, or, not in qualifications
54+
1955
SELECT bool 't' or bool 'f' AS true;
2056

2157
SELECT bool 't' and bool 'f' AS false;
@@ -26,6 +62,14 @@ SELECT bool 't' = bool 'f' AS false;
2662

2763
SELECT bool 't' <> bool 'f' AS true;
2864

65+
SELECT bool 't' > bool 'f' AS true;
66+
67+
SELECT bool 't' >= bool 'f' AS true;
68+
69+
SELECT bool 'f' < bool 't' AS true;
70+
71+
SELECT bool 'f' <= bool 't' AS true;
72+
2973
-- explicit casts to/from text
3074
SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
3175
SELECT ' true '::text::boolean AS true,

0 commit comments

Comments
 (0)