Skip to content

Commit

Permalink
Improve casting-fu in our tests, and add a few. Thanks for help from …
Browse files Browse the repository at this point in the history
…theory++
  • Loading branch information
leto committed Jan 27, 2010
1 parent 9209f47 commit c57e0e8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions t/test.sql
Expand Up @@ -13,7 +13,7 @@
BEGIN;
\i pgtap.sql
-- Plan the tests.
SELECT plan(3);
SELECT plan(5);

--DROP FUNCTION plparrot_call_handler() CASCADE;
-- TODO: Make this configurable
Expand Down Expand Up @@ -41,17 +41,15 @@ CREATE FUNCTION test_int() RETURNS int AS $$ select 1 as result $$ LANGUAGE plpa

CREATE FUNCTION test_int_int(int) RETURNS int AS $$ select $1 as result $$ LANGUAGE plparrot;

CREATE FUNCTION test_float() RETURNS float AS $$ select 1.0 as result $$ LANGUAGE plparrot;
CREATE FUNCTION test_float() RETURNS float AS $$ select 1.0::float as result $$ LANGUAGE plparrot;

CREATE FUNCTION test_varchar() RETURNS varchar(5) AS $$ select 'cheese' as result $$ LANGUAGE plparrot;

select test_void();
select is(test_int(),1);
select is(test_int_int(42),42);

-- There does not seem to be any floating point comparison functions in pgTAP
--select like(test_float(), 1.0,1e-6);
select is(test_varchar(), 'cheese');
select is(test_void()::text,''::text,'We can return void');
select is(test_int(),1,'We can return an int');
select is(test_int_int(42),42,'We can return an int that was passed as an arg');
select is(test_float(), 1.0::float ,'We can return a float');
select is(test_varchar(), 'cheese', 'We can return a varchar');

-- Finish the tests and clean up.
SELECT * FROM finish();
Expand Down

0 comments on commit c57e0e8

Please sign in to comment.