Commit 09e35315 authored by Peter Eisentraut's avatar Peter Eisentraut

Add more tests for money type

Add tests for functions currently not covered at all.
Reviewed-by: default avatarPavel Stehule <pavel.stehule@gmail.com>
parent 6fc54796
......@@ -27,18 +27,84 @@ SELECT m - '123.45' FROM money_data;
-$0.45
(1 row)
SELECT m / '2'::money FROM money_data;
?column?
----------
61.5
(1 row)
SELECT m * 2 FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT 2 * m FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT m / 2 FROM money_data;
?column?
----------
$61.50
(1 row)
SELECT m * 2::int2 FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT 2::int2 * m FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT m / 2::int2 FROM money_data;
?column?
----------
$61.50
(1 row)
SELECT m * 2::float8 FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT 2::float8 * m FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT m / 2::float8 FROM money_data;
?column?
----------
$61.50
(1 row)
SELECT m * 2::float4 FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT 2::float4 * m FROM money_data;
?column?
----------
$246.00
(1 row)
SELECT m / 2::float4 FROM money_data;
?column?
----------
$61.50
(1 row)
-- All true
SELECT m = '$123.00' FROM money_data;
?column?
......@@ -275,7 +341,7 @@ SELECT '92233720368547758.075'::money;
ERROR: value "92233720368547758.075" is out of range for type money
LINE 1: SELECT '92233720368547758.075'::money;
^
-- Cast int4/int8 to money
-- Cast int4/int8/numeric to money
SELECT 1234567890::money;
money
-------------------
......@@ -318,6 +384,12 @@ SELECT 12345678901234567::int8::money;
$12,345,678,901,234,567.00
(1 row)
SELECT 12345678901234567::numeric::money;
money
----------------------------
$12,345,678,901,234,567.00
(1 row)
SELECT (-1234567890)::int4::money;
money
--------------------
......@@ -330,3 +402,22 @@ SELECT (-12345678901234567)::int8::money;
-$12,345,678,901,234,567.00
(1 row)
SELECT (-12345678901234567)::numeric::money;
money
-----------------------------
-$12,345,678,901,234,567.00
(1 row)
-- Cast from money
SELECT '12345678901234567'::money::numeric;
numeric
----------------------
12345678901234567.00
(1 row)
SELECT '-12345678901234567'::money::numeric;
numeric
-----------------------
-12345678901234567.00
(1 row)
......@@ -9,8 +9,19 @@ SELECT * FROM money_data;
SELECT m + '123' FROM money_data;
SELECT m + '123.45' FROM money_data;
SELECT m - '123.45' FROM money_data;
SELECT m / '2'::money FROM money_data;
SELECT m * 2 FROM money_data;
SELECT 2 * m FROM money_data;
SELECT m / 2 FROM money_data;
SELECT m * 2::int2 FROM money_data;
SELECT 2::int2 * m FROM money_data;
SELECT m / 2::int2 FROM money_data;
SELECT m * 2::float8 FROM money_data;
SELECT 2::float8 * m FROM money_data;
SELECT m / 2::float8 FROM money_data;
SELECT m * 2::float4 FROM money_data;
SELECT 2::float4 * m FROM money_data;
SELECT m / 2::float4 FROM money_data;
-- All true
SELECT m = '$123.00' FROM money_data;
......@@ -83,7 +94,7 @@ SELECT '92233720368547758.08'::money;
SELECT '-92233720368547758.085'::money;
SELECT '92233720368547758.075'::money;
-- Cast int4/int8 to money
-- Cast int4/int8/numeric to money
SELECT 1234567890::money;
SELECT 12345678901234567::money;
SELECT (-12345)::money;
......@@ -91,5 +102,11 @@ SELECT (-1234567890)::money;
SELECT (-12345678901234567)::money;
SELECT 1234567890::int4::money;
SELECT 12345678901234567::int8::money;
SELECT 12345678901234567::numeric::money;
SELECT (-1234567890)::int4::money;
SELECT (-12345678901234567)::int8::money;
SELECT (-12345678901234567)::numeric::money;
-- Cast from money
SELECT '12345678901234567'::money::numeric;
SELECT '-12345678901234567'::money::numeric;
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