-- Test color
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;

begin;

select plan(8);

set search_path to camper, public;

select has_domain('color');
select domain_type_is('color', 'citext');

select lives_ok($$ select '#775544'::color $$, 'Should be able to cast strings to color');
select lives_ok($$ select '#aABbCc'::color $$, 'Should be able to cast hex-strings to color');

select throws_ok(
	$$ select '0775544'::color $$,
	23514, null,
	'Should reject colors without the initial hash character'
);

select throws_ok(
	$$ select '#red'::color $$,
	23514, null,
	'Should reject named colors'
);

select throws_ok(
	$$ select '#0011ag'::color $$,
	23514, null,
	'Should reject colors with invalid hex digits'
);

select throws_ok(
	$$ select '#00112233'::color $$,
	23514, null,
	'Should reject colors with more than three pairs (i.e., no alpha)'
);


select *
from finish();

rollback;
