From: D'Arcy J.M. Cain Date: Sat, 24 Nov 2007 19:49:23 +0000 (+0000) Subject: Add regression tests for MONEY type. X-Git-Tag: REL8_3_BETA4~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03debe19a79e661820e23ed13f579684aee5ef02;p=postgresql Add regression tests for MONEY type. --- diff --git a/src/test/regress/expected/money.out b/src/test/regress/expected/money.out new file mode 100644 index 0000000000..ec4169cbb0 --- /dev/null +++ b/src/test/regress/expected/money.out @@ -0,0 +1,187 @@ +-- +-- MONEY +-- +CREATE TABLE money_data (m money); +INSERT INTO money_data VALUES ('123'); +SELECT * FROM money_data; + m +--------- + $123.00 +(1 row) + +SELECT m + '123' FROM money_data; + ?column? +---------- + $246.00 +(1 row) + +SELECT m + '123.45' FROM money_data; + ?column? +---------- + $246.45 +(1 row) + +SELECT m - '123.45' FROM money_data; + ?column? +---------- + -$0.45 +(1 row) + +SELECT m * 2 FROM money_data; + ?column? +---------- + $246.00 +(1 row) + +SELECT m / 2 FROM money_data; + ?column? +---------- + $61.50 +(1 row) + +-- All true +SELECT m = '$123.00' FROM money_data; + ?column? +---------- + t +(1 row) + +SELECT m != '$124.00' FROM money_data; + ?column? +---------- + t +(1 row) + +SELECT m <= '$123.00' FROM money_data; + ?column? +---------- + t +(1 row) + +SELECT m >= '$123.00' FROM money_data; + ?column? +---------- + t +(1 row) + +SELECT m < '$124.00' FROM money_data; + ?column? +---------- + t +(1 row) + +SELECT m > '$122.00' FROM money_data; + ?column? +---------- + t +(1 row) + +-- All false +SELECT m = '$123.01' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT m != '$123.00' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT m <= '$122.99' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT m >= '$123.01' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT m > '$124.00' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT m < '$122.00' FROM money_data; + ?column? +---------- + f +(1 row) + +SELECT cashlarger(m, '$124.00') FROM money_data; + cashlarger +------------ + $124.00 +(1 row) + +SELECT cashsmaller(m, '$124.00') FROM money_data; + cashsmaller +------------- + $123.00 +(1 row) + +SELECT cash_words(m) FROM money_data; + cash_words +------------------------------------------------- + One hundred twenty three dollars and zero cents +(1 row) + +SELECT cash_words(m + '1.23') FROM money_data; + cash_words +-------------------------------------------------------- + One hundred twenty four dollars and twenty three cents +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.45'); +SELECT * FROM money_data; + m +--------- + $123.45 +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.451'); +SELECT * FROM money_data; + m +--------- + $123.45 +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.454'); +SELECT * FROM money_data; + m +--------- + $123.45 +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.455'); +SELECT * FROM money_data; + m +--------- + $123.46 +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.456'); +SELECT * FROM money_data; + m +--------- + $123.46 +(1 row) + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.459'); +SELECT * FROM money_data; + m +--------- + $123.46 +(1 row) + diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out index 922c6af685..6946b2ec16 100644 --- a/src/test/regress/expected/sanity_check.out +++ b/src/test/regress/expected/sanity_check.out @@ -66,6 +66,7 @@ SELECT relname, relhasindex log_table | f lseg_tbl | f main_table | f + money_data | f num_data | f num_exp_add | t num_exp_div | t @@ -148,7 +149,7 @@ SELECT relname, relhasindex timetz_tbl | f tinterval_tbl | f varchar_tbl | f -(137 rows) +(138 rows) -- -- another sanity check: every system catalog that has OIDs should have diff --git a/src/test/regress/output/misc.source b/src/test/regress/output/misc.source index 7aac0461be..e409c0a100 100644 --- a/src/test/regress/output/misc.source +++ b/src/test/regress/output/misc.source @@ -626,6 +626,7 @@ SELECT user_relns() AS user_relns log_table lseg_tbl main_table + money_data num_data num_exp_add num_exp_div @@ -666,7 +667,7 @@ SELECT user_relns() AS user_relns toyemp varchar_tbl xacttest -(100 rows) +(101 rows) SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))); name diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 6d33f38020..8d72885bc7 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -1,5 +1,5 @@ # ---------- -# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.45 2007/10/13 23:06:27 tgl Exp $ +# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.46 2007/11/24 19:49:23 darcy Exp $ # # By convention, we put no more than twenty tests in any one parallel group; # this limits the number of connections needed to run the tests. @@ -8,7 +8,7 @@ # ---------- # The first group of parallel tests # ---------- -test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric txid uuid enum +test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric txid uuid enum money # Depends on things setup during char, varchar and text test: strings diff --git a/src/test/regress/sql/money.sql b/src/test/regress/sql/money.sql new file mode 100644 index 0000000000..40bc0e1b41 --- /dev/null +++ b/src/test/regress/sql/money.sql @@ -0,0 +1,59 @@ +-- +-- MONEY +-- + +CREATE TABLE money_data (m money); + +INSERT INTO money_data VALUES ('123'); +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 FROM money_data; +SELECT m / 2 FROM money_data; + +-- All true +SELECT m = '$123.00' FROM money_data; +SELECT m != '$124.00' FROM money_data; +SELECT m <= '$123.00' FROM money_data; +SELECT m >= '$123.00' FROM money_data; +SELECT m < '$124.00' FROM money_data; +SELECT m > '$122.00' FROM money_data; + +-- All false +SELECT m = '$123.01' FROM money_data; +SELECT m != '$123.00' FROM money_data; +SELECT m <= '$122.99' FROM money_data; +SELECT m >= '$123.01' FROM money_data; +SELECT m > '$124.00' FROM money_data; +SELECT m < '$122.00' FROM money_data; + +SELECT cashlarger(m, '$124.00') FROM money_data; +SELECT cashsmaller(m, '$124.00') FROM money_data; +SELECT cash_words(m) FROM money_data; +SELECT cash_words(m + '1.23') FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.45'); +SELECT * FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.451'); +SELECT * FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.454'); +SELECT * FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.455'); +SELECT * FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.456'); +SELECT * FROM money_data; + +DELETE FROM money_data; +INSERT INTO money_data VALUES ('$123.459'); +SELECT * FROM money_data; +