Database definition & tests organisation
* The main loader script has been updated to generate the list of files it needs to load automatically. As a consequence, files that contained manually-maintained lists of scripts have been removed, and definition directories have been renamed accordingly. * PostgreSQL extension loading and configuration has been moved to a separate script to be loaded automatically in the main transaction. * Data and function definition scripts that had the -data or -functions suffix have been renamed (the suffix is unnecessary). * Unit tests have been reorganised to follow the definition's structure. * Documentation has been improved
This commit is contained in:
parent
b054a379a9
commit
e50775ec76
112 changed files with 78 additions and 144 deletions
legacyworlds-server-data/db-structure/tests/admin/040-functions/050-computation
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Test the verse.get_random_part() function
|
||||
*/
|
||||
BEGIN;
|
||||
SELECT plan( 6 );
|
||||
|
||||
/* First set of tests: results of the function with a fake
|
||||
* verse.random_deviation() that always returns the minimal possible
|
||||
* value.
|
||||
*/
|
||||
CREATE OR REPLACE FUNCTION verse.random_deviation( _mean DOUBLE PRECISION , _deviation DOUBLE PRECISION )
|
||||
RETURNS DOUBLE PRECISION
|
||||
STRICT VOLATILE
|
||||
AS $$
|
||||
SELECT $1 - $2;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Single part, minimal random value' );
|
||||
SELECT is( verse.get_random_part( 0.5 , 1 , 0.5 , 0.25 ) , 0.5::DOUBLE PRECISION );
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Two parts, some extra quantity, minimal random value' );
|
||||
SELECT is( verse.get_random_part( 0.75 , 2 , 0.5 , 0.25 ) , 0.25::DOUBLE PRECISION );
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Two parts, maximal quantity, minimal random value' );
|
||||
SELECT is( verse.get_random_part( 1.5 , 2 , 0.5 , 0.25 ) , 0.75::DOUBLE PRECISION );
|
||||
|
||||
/* Second set of tests: results of the function with a fake
|
||||
* verse.random_deviation() that always returns the maximal possible
|
||||
* value.
|
||||
*/
|
||||
CREATE OR REPLACE FUNCTION verse.random_deviation( _mean DOUBLE PRECISION , _deviation DOUBLE PRECISION )
|
||||
RETURNS DOUBLE PRECISION
|
||||
STRICT VOLATILE
|
||||
AS $$
|
||||
SELECT $1 + $2;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Single part, maximal random value' );
|
||||
SELECT is( verse.get_random_part( 0.5 , 1 , 0.5 , 0.25 ) , 0.5::DOUBLE PRECISION );
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Two parts, some extra quantity, maximal random value' );
|
||||
SELECT is( verse.get_random_part( 1 , 2 , 0.5 , 0.25 ) , 0.75::DOUBLE PRECISION );
|
||||
SELECT diag_test_name( 'verse.get_random_part() - Two parts, minimal quantity, maximal random value' );
|
||||
SELECT is( verse.get_random_part( 0.5 , 2 , 0.5 , 0.25 ) , 0.25::DOUBLE PRECISION );
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
Reference in a new issue