camper/test/zero_pad.sql

37 lines
1.7 KiB
PL/PgSQL

-- Test zero_pad
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(19);
set search_path to camper, public;
select has_function('camper', 'zero_pad', array['bytea', 'integer']);
select function_lang_is('camper', 'zero_pad', array['bytea', 'integer'], 'sql');
select function_returns('camper', 'zero_pad', array['bytea', 'integer'], 'bytea');
select isnt_definer('camper', 'zero_pad', array['bytea', 'integer']);
select volatility_is('camper', 'zero_pad', array['bytea', 'integer'], 'immutable');
select function_privs_are('camper', 'zero_pad', array ['bytea', 'integer'], 'guest', array['EXECUTE']);
select function_privs_are('camper', 'zero_pad', array ['bytea', 'integer'], 'employee', array['EXECUTE']);
select function_privs_are('camper', 'zero_pad', array ['bytea', 'integer'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'zero_pad', array ['bytea', 'integer'], 'authenticator', array[]::text[]);
select is(zero_pad(''::bytea, 8), '\x'::bytea);
select is(zero_pad('\x11'::bytea, 8), '\x1100000000000000'::bytea);
select is(zero_pad('\x2211'::bytea, 8), '\x2211000000000000'::bytea);
select is(zero_pad('\x332211'::bytea, 8), '\x3322110000000000'::bytea);
select is(zero_pad('\x44332211'::bytea, 8), '\x4433221100000000'::bytea);
select is(zero_pad('\x5544332211'::bytea, 8), '\x5544332211000000'::bytea);
select is(zero_pad('\x665544332211'::bytea, 8), '\x6655443322110000'::bytea);
select is(zero_pad('\x77665544332211'::bytea, 8), '\x7766554433221100'::bytea);
select is(zero_pad('\x8877665544332211'::bytea, 8), '\x8877665544332211'::bytea);
select is(zero_pad('\x998877665544332211'::bytea, 8), '\x99887766554433221100000000000000'::bytea);
select *
from finish();
rollback;