campingmontagut/test/nonnegative_integer.sql
jordi fita mas af31daba8a Add positive_integer and nonnegative_integer domains
This is easier to read and requires less unit tests, but i only used
them in the new relations and fields for HEAD, because i do not see any
point on creating migrations just for that.
2024-02-13 22:12:30 +01:00

38 lines
882 B
PL/PgSQL

-- Test nonnegative_integer
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(10);
set search_path to camper, public;
select has_domain('nonnegative_integer');
select domain_type_is('nonnegative_integer', 'integer');
select lives_ok($$ select 0::nonnegative_integer $$);
select lives_ok($$ select 1::nonnegative_integer $$);
select lives_ok($$ select 2::nonnegative_integer $$);
select lives_ok($$ select 10::nonnegative_integer $$);
select lives_ok($$ select 31289::nonnegative_integer $$);
select lives_ok($$ select 8891892::nonnegative_integer $$);
select throws_ok(
$$ select (-1)::nonnegative_integer $$,
23514, null,
'No negative numbers allowed'
);
select is(
1.123::nonnegative_integer,
1::nonnegative_integer,
'Integers only'
);
select *
from finish();
rollback;