SET SERVEROUTPUT ON SIZE 1000000;
-- Test lib_string: DECLARE l_string VARCHAR2(100); l_count NUMBER; l_passed BOOLEAN := TRUE; BEGIN dbms_output.put_line('-'); dbms_output.put_line('+- FUNCTION ltrim_chr test start:'); dbms_output.put_line('|');
dbms_output.put_line ('| Test 1: Pass ''AAAB'', ''B'': No leading ' || 'characters to strip.'); dbms_output.put_line ('| Expected result: AAAB');
l_string := lib_string.ltrim_chr('AAAB', 'B');
dbms_output.put_line('| Result = ' || l_string); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_string = 'AAAB' 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('|');
dbms_output.put_line ('| Test 2: Pass ''ABBB'', ''A'': 1 leading character ' || 'to strip.'); dbms_output.put_line ('| Expected result: BBB');
l_string := lib_string.ltrim_chr('ABBB', 'A');
dbms_output.put_line('| Result = ' || l_string); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_string = 'BBB' 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('|');
dbms_output.put_line ('| Test 3: Pass ''AABB'', ''A'': > 1 leading ' || 'character to strip.'); dbms_output.put_line ('| Expected result: BB');
l_string := lib_string.ltrim_chr('AABB', 'A');
dbms_output.put_line('| Result = ' || l_string); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_string = 'BB' 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('|');
dbms_output.put_line ('| Test 4: Pass ''AAAB'', ''A'': All but last ' || 'characters to strip.'); dbms_output.put_line ('| Expected result: B');
l_string := lib_string.ltrim_chr('AAAB', 'A');
dbms_output.put_line('| Result = ' || l_string); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_string = 'B' 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('|');
dbms_output.put_line ('| Test 5: Pass ''AAAA'', ''A'': All leading ' || 'characters to strip.'); dbms_output.put_line ('| Expected result: NULL');
l_string := lib_string.ltrim_chr('AAAA', 'A');
dbms_output.put_line('| Result = ' || l_string); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_string IS NULL 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('|');
dbms_output.put_line('+- FUNCTION ltrim_chr test end:');
dbms_output.put_line('-'); dbms_output.put_line('+- FUNCTION count_chr test start:'); dbms_output.put_line('|');
dbms_output.put_line ('| Test 1: Pass ''A'',''B'', '''''': Count single ' || 'quotes.'); dbms_output.put_line ('| Expected result: 4');
l_count := lib_string.count_chr('''A'',''B''', '''');
dbms_output.put_line('| Result = ' || l_count); dbms_output.put_line('|');
dbms_output.put_line('| +----------+'); IF l_count = 4 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('|');
dbms_output.put_line('-'); dbms_output.put_line('- Overall result:'); dbms_output.put_line('-'); dbms_output.put_line('- +----------+'); IF l_passed = TRUE THEN dbms_output.put_line('- | PASSED |'); ELSE dbms_output.put_line('- | FAILED |'); END IF; dbms_output.put_line('- +----------+'); dbms_output.put_line('-');
END; /
|
0 Comments:
Post a Comment
<< Home