Skip to content

Commit

Permalink
Add NULL regression tests for agtype and numbers
Browse files Browse the repository at this point in the history
Added and refactored regression tests for null operations.
  • Loading branch information
dehowef committed Apr 22, 2021
1 parent 7d045e4 commit cb75d48
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 21 deletions.
132 changes: 117 additions & 15 deletions regress/expected/agtype.out
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,36 @@ SELECT agtype_any_mod('null'::agtype, 1);

(1 row)

SELECT agtype_any_add(null, '1'::agtype);
agtype_any_add
----------------

(1 row)

SELECT agtype_any_sub(null, '1'::agtype);
agtype_any_sub
----------------

(1 row)

SELECT agtype_any_mul(null, '1'::agtype);
agtype_any_mul
----------------

(1 row)

SELECT agtype_any_div(null, '1'::agtype);
agtype_any_div
----------------

(1 row)

SELECT agtype_any_mod(null, '1'::agtype);
agtype_any_mod
----------------

(1 row)

SELECT 1 + 'null'::agtype;
?column?
----------
Expand Down Expand Up @@ -938,33 +968,33 @@ SELECT 1 % 'null'::agtype;

(1 row)

SELECT agtype_any_add('null'::agtype, 1);
agtype_any_add
----------------
SELECT '1'::agtype + null;
?column?
----------

(1 row)

SELECT agtype_any_sub('null'::agtype, 1);
agtype_any_sub
----------------
SELECT '1'::agtype - null;
?column?
----------

(1 row)

SELECT agtype_any_mul('null'::agtype, 1);
agtype_any_mul
----------------
SELECT '1'::agtype * null;
?column?
----------

(1 row)

SELECT agtype_any_div('null'::agtype, 1);
agtype_any_div
----------------
SELECT '1'::agtype / null;
?column?
----------

(1 row)

SELECT agtype_any_mod('null'::agtype, 1);
agtype_any_mod
----------------
SELECT '1'::agtype % null;
?column?
----------

(1 row)

Expand Down Expand Up @@ -1004,6 +1034,42 @@ SELECT 1 >= 'null'::agtype;

(1 row)

SELECT '1'::agtype = null;
?column?
----------

(1 row)

SELECT '1'::agtype <> null;
?column?
----------

(1 row)

SELECT '1'::agtype < null;
?column?
----------

(1 row)

SELECT '1'::agtype > null;
?column?
----------

(1 row)

SELECT '1'::agtype <= null;
?column?
----------

(1 row)

SELECT '1'::agtype >= null;
?column?
----------

(1 row)

SELECT agtype_any_eq('null'::agtype, 1);
agtype_any_eq
---------------
Expand Down Expand Up @@ -1040,6 +1106,42 @@ SELECT agtype_any_ge('null'::agtype, 1);

(1 row)

SELECT agtype_any_eq(null, '1'::agtype);
agtype_any_eq
---------------

(1 row)

SELECT agtype_any_ne(null, '1'::agtype);
agtype_any_ne
---------------

(1 row)

SELECT agtype_any_lt(null, '1'::agtype);
agtype_any_lt
---------------

(1 row)

SELECT agtype_any_gt(null, '1'::agtype);
agtype_any_gt
---------------

(1 row)

SELECT agtype_any_le(null, '1'::agtype);
agtype_any_le
---------------

(1 row)

SELECT agtype_any_ge(null, '1'::agtype);
agtype_any_ge
---------------

(1 row)

--
-- Test orderability of comparison operators =, <>, <, >, <=, >=
-- These should all return true
Expand Down
28 changes: 22 additions & 6 deletions regress/sql/agtype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -275,32 +275,48 @@ SELECT agtype_any_sub('null'::agtype, 1);
SELECT agtype_any_mul('null'::agtype, 1);
SELECT agtype_any_div('null'::agtype, 1);
SELECT agtype_any_mod('null'::agtype, 1);
SELECT agtype_any_add(null, '1'::agtype);
SELECT agtype_any_sub(null, '1'::agtype);
SELECT agtype_any_mul(null, '1'::agtype);
SELECT agtype_any_div(null, '1'::agtype);
SELECT agtype_any_mod(null, '1'::agtype);

SELECT 1 + 'null'::agtype;
SELECT 1 - 'null'::agtype;
SELECT 1 * 'null'::agtype;
SELECT 1 / 'null'::agtype;
SELECT 1 % 'null'::agtype;

SELECT agtype_any_add('null'::agtype, 1);
SELECT agtype_any_sub('null'::agtype, 1);
SELECT agtype_any_mul('null'::agtype, 1);
SELECT agtype_any_div('null'::agtype, 1);
SELECT agtype_any_mod('null'::agtype, 1);
SELECT '1'::agtype + null;
SELECT '1'::agtype - null;
SELECT '1'::agtype * null;
SELECT '1'::agtype / null;
SELECT '1'::agtype % null;

SELECT 1 = 'null'::agtype;
SELECT 1 <> 'null'::agtype;
SELECT 1 < 'null'::agtype;
SELECT 1 > 'null'::agtype;
SELECT 1 <= 'null'::agtype;
SELECT 1 >= 'null'::agtype;
SELECT '1'::agtype = null;
SELECT '1'::agtype <> null;
SELECT '1'::agtype < null;
SELECT '1'::agtype > null;
SELECT '1'::agtype <= null;
SELECT '1'::agtype >= null;

SELECT agtype_any_eq('null'::agtype, 1);
SELECT agtype_any_ne('null'::agtype, 1);
SELECT agtype_any_lt('null'::agtype, 1);
SELECT agtype_any_gt('null'::agtype, 1);
SELECT agtype_any_le('null'::agtype, 1);
SELECT agtype_any_ge('null'::agtype, 1);
SELECT agtype_any_eq(null, '1'::agtype);
SELECT agtype_any_ne(null, '1'::agtype);
SELECT agtype_any_lt(null, '1'::agtype);
SELECT agtype_any_gt(null, '1'::agtype);
SELECT agtype_any_le(null, '1'::agtype);
SELECT agtype_any_ge(null, '1'::agtype);

--
-- Test orderability of comparison operators =, <>, <, >, <=, >=
Expand Down

0 comments on commit cb75d48

Please sign in to comment.