home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progpas
/
tspas18.arj
/
TSUNTD.TST
< prev
next >
Wrap
Text File
|
1989-09-25
|
4KB
|
165 lines
{$R+} (* Index range check on *)
(* This is a test program for the TSUNTD.TPU unit
2-Aug-89, Updated 25-Sep-89 *)
uses TSUNTB,
TSUNTD;
const loop = 200; (* If you do want to make it quickly, change this to 1 *)
var time : real; (* For timing the tests *)
procedure LOGO;
begin
writeln;
writeln ('TSUNTD unit test by Prof. Timo Salmi');
writeln ('University of Vaasa, Finland, ts@chyde.uwasa.fi');
writeln;
end;
(* Dosdelay function, no Ctr unit needed *)
procedure TEST1;
begin
time := TIMERFN;
DOSDELAY (1000);
time := TIMERFN - time;
writeln ('DOSDELAY(1000)');
writeln ('Elapsed ', time:0:2);
writeln;
end; (* test1 *)
(* Justify a string right *)
procedure TEST2;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := 'TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := TRIMRGFN (sj1, 20);
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test2 *)
procedure TEST3;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := 'TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := TRIMRGFN (sj1, 4);
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test3 *)
(* Justify a string left *)
procedure TEST4;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := ' TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := TRIMLFFN (sj1, 20);
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test4 *)
procedure TEST5;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := ' TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := TRIMLFFN (sj1, 4);
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test5 *)
(* Lead a string *)
procedure TEST6;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := 'TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := LEADFN (sj1, 20, '.');
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test6 *)
(* Trail a string *)
procedure TEST7;
var sj1, sj2 : string;
i : word;
begin
writeln ('....:....1....:....2....:....3....:....4....:....5....');
sj1 := 'TSUNTD';
time := TIMERFN;
for i := 1 to loop do sj2 := TRAILFN (sj1, 20, '.');
time := TIMERFN - time;
writeln (sj1); writeln (sj2);
writeln ('Elapsed ', time:0:2);
end; (* test7 *)
(* Extract all substrings from a string *)
procedure TEST8;
{$IFNDEF VER40}
const separators : string = ' ' + ',' + #9;
{$ENDIF}
var sj : string;
partPtr : parseVectorPtrType;
n : integer;
ok : boolean;
i : byte;
{$IFDEF VER40} var separators : string; {$ENDIF}
begin
{$IFDEF VER40} separators := ' ' + ',' + #9; {$ENDIF}
New (partPtr);
sj := 'TSUNTD unit test by Prof. Timo Salmi';
PARSE (sj, parse_parts_max, separators,
n, partPtr, ok);
if not ok then halt; {or whatever you want do in case of an error}
for i := 1 to n do writeln (partPtr^[i]);
Dispose (partPtr); partPtr := nil;
end; (* test8 *)
(* Alternative method: Extract all substrings from a string *)
procedure TEST9;
var sj : string;
n : integer;
i : byte;
var separators : string;
begin
separators := ' ' + ',' + #9;
sj := 'TSUNTD unit test by Prof. Timo Salmi';
n := STRCNTFN (sj, separators);
for i := 1 to n do writeln (SPARTFN(sj, separators, i));
end; (* test9 *)
(* Main program *)
begin
LOGO;
TEST1;
TEST2;
TEST3;
TEST4;
readln;
TEST5;
TEST6;
TEST7;
readln;
TEST8;
readln;
TEST9;
end. (* tsuntd.tst *)