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).
This commit is contained in:
jordi fita mas 2023-02-10 19:00:46 +01:00
parent fa3ffdf19b
commit 96cfee6f56
1 changed files with 2 additions and 2 deletions

View File

@ -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'
);