From 96cfee6f5679493857a3e2db98e8d817c7e0804a Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Fri, 10 Feb 2023 19:00:46 +0100 Subject: [PATCH] Correctly test negative tax_rate It turns out that -0.15::tax_rate means -(0.15::tax_rate), but i want (-0.15)::tax_rate, because otherwise i only check the domain [0, 1). --- test/tax_rate.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tax_rate.sql b/test/tax_rate.sql index d738533..49066e1 100644 --- a/test/tax_rate.sql +++ b/test/tax_rate.sql @@ -13,7 +13,7 @@ select has_domain('tax_rate'); select domain_type_is('tax_rate', 'numeric'); select lives_ok($$ select 0.21::tax_rate $$, 'Should be able to cast valid positive decimals to tax rate'); -select lives_ok($$ select -0.15::tax_rate $$, 'Should be able to cast valid negative decimals to tax rate'); +select lives_ok($$ select (-0.15)::tax_rate $$, 'Should be able to cast valid negative decimals to tax rate'); select lives_ok($$ select 0::tax_rate $$, 'Should be able to cast valid zero to tax rate'); select throws_ok( @@ -23,7 +23,7 @@ select throws_ok( ); select throws_ok( - $$ SELECT -1::tax_rate $$, + $$ SELECT (-1)::tax_rate $$, 23514, null, 'Should reject -100 % tax rate' );