Humble Trader

Saturday, February 04, 2006

Number PL/SQL Library Test Script

Paste this code into a .sql script and run it in SQL*PLUS by the owner of the target schema.

SET SERVEROUTPUT ON SIZE 1000000;

-- Test p_number_lib:
DECLARE
l_string VARCHAR2(100);
l_passed BOOLEAN := TRUE;
BEGIN
dbms_output.put_line('-');
dbms_output.put_line('FUNCTION cardinal_num test start:');
dbms_output.put_line('-');

dbms_output.put_line ('Test 1: Pass 1: Example.');
dbms_output.put_line ('Expected result: "1st"');

l_string := lib_number.cardinal_num(1);

dbms_output.put_line('Result = ' || l_string);

IF l_string = '1st'
THEN
dbms_output.put_line('---PASSED---');
ELSE
dbms_output.put_line('---FAILED---');
l_passed := FALSE;
END IF;

dbms_output.put_line('-');

dbms_output.put_line ('Test 2: Pass 22: Example.');
dbms_output.put_line ('Expected result: "22nd"');

l_string := lib_number.cardinal_num(22);

dbms_output.put_line('Result = ' || l_string);

IF l_string = '22nd'
THEN
dbms_output.put_line('---PASSED---');
ELSE
dbms_output.put_line('---FAILED---');
l_passed := FALSE;
END IF;

dbms_output.put_line('-');

dbms_output.put_line ('Test 3: Pass 9753: Example.');
dbms_output.put_line ('Expected result: "9753rd"');

l_string := lib_number.cardinal_num(9753);

dbms_output.put_line('Result = ' || l_string);

IF l_string = '9753rd'
THEN
dbms_output.put_line('---PASSED---');
ELSE
dbms_output.put_line('---FAILED---');
l_passed := FALSE;
END IF;

dbms_output.put_line('-');

dbms_output.put_line ('Test 4: Pass 24680: Example.');
dbms_output.put_line ('Expected result: "24680th"');

l_string := lib_number.cardinal_num(24680);

dbms_output.put_line('Result = ' || l_string);

IF l_string = '24680th'
THEN
dbms_output.put_line('---PASSED---');
ELSE
dbms_output.put_line('---FAILED---');
l_passed := FALSE;
END IF;

dbms_output.put_line('-');

dbms_output.put_line('FUNCTION cardinal_num test end:');

IF l_passed =TRUE
THEN
dbms_output.put_line('---PASSED---');
ELSE
dbms_output.put_line('---FAILED---');
END IF;

dbms_output.put_line('-');
END;
/

0 Comments:

Post a Comment

<< Home