Program TSTCINTAS;

{ Version
  File:[22,310]TSTCINTAS.PAS
  Author: Phil Hannay.  7-Sep-89.
  History:

  last edit: 22-SEP-1989 12:07:07 

Testing P3UTIL module(s): CINTAS

}

{[a+,b+,l-,k+,r+] Pasmat }

%include pas$ext:general.typ;
%include pas$ext:cintas.ext;
%include pas$ext:swrite.ext;


VAR
  int: integer;
  pos: integer;
  resp: ch5;
  string2: str2;
  string10: str10;
  string100: str100;
  char2: ch2;
  char10: ch10;
  char100: ch100;
  char6: ch6;

Procedure Test_type1;
  { Test type1 strings }

Var
  i: integer;

Begin
writeln('first the standard tests using type1 strings');
int:= 2;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "         2"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "2"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    2"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "2"');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be "    2"');

int:= 2456;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "      2456"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "2456"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    2456"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "" (error)');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be " 2456"');

int:= -2456;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "     -2456"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "-2456"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    -2456"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "" (error)');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be "-2456"');

int:= 0;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "         0"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "0"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    0"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "0"');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be "    0"');

int:= 31002;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "     31002"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "31002"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    31002"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "" (error)');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be "31002"');

int:= -31002;
cintas(int,char10,0);
writeln('value is    "',char10,'"');
writeln('  should be "    -31002"');
cintas(int,char10,1);
writeln('value is    "',char10,'"');
writeln('  should be "-31002"');
cintas(int,char10,5);
writeln('value is    "',char10,'"');
writeln('  should be "    -31002"');
cintas(int,char10,-1);
writeln('value is    "',char10,'"');
writeln('  should be "" (error)');
cintas(int,char10,-5);
writeln('value is    "',char10,'"');
writeln('  should be "" (error)');

int:= -31002;
cintas(int,char2,0);
writeln('value is    "',char2,'"');
writeln('  should be "" (error)');
cintas(int,char2,1);
writeln('value is    "',char2,'"');
writeln('  should be "" (error)');
cintas(int,char2,5);
writeln('value is    "',char2,'"');
writeln('  should be "" (error)');
cintas(int,char2,-1);
writeln('value is    "',char2,'"');
writeln('  should be "" (error)');
cintas(int,char2,-5);
writeln('value is    "',char2,'"');
writeln('  should be "" (error)');

int:= 31002;
cintas(int,char100,0);
writeln('value is ');
write('"');
for i:= 1 to 40 do write(char100[i]);
writeln('"');
write('"');
for i:= 41 to 80 do write(char100[i]);
writeln('"');
write('"');
for i:= 81 to 100 do write(char100[i]);
writeln('"');
writeln('should be ');
writeln('"                                        "');
writeln('"                                        "');
writeln('"               31002"');
cintas(int,char100,1);
writeln('value is ');
write('"');
for i:= 1 to 40 do write(char100[i]);
writeln('"');
write('"');
for i:= 41 to 80 do write(char100[i]);
writeln('"');
write('"');
for i:= 81 to 100 do write(char100[i]);
writeln('"');
writeln('should be ');
writeln('"31002"');
writeln('""');
writeln('""');
cintas(int,char100,5);
writeln('value is ');
write('"');
for i:= 1 to 40 do write(char100[i]);
writeln('"');
write('"');
for i:= 41 to 80 do write(char100[i]);
writeln('"');
write('"');
for i:= 81 to 100 do write(char100[i]);
writeln('"');
writeln('should be ');
writeln('"    31002"');
writeln('""');
writeln('""');
cintas(int,char100,-1);
writeln('value is ');
write('"');
for i:= 1 to 40 do write(char100[i]);
writeln('"');
write('"');
for i:= 41 to 80 do write(char100[i]);
writeln('"');
write('"');
for i:= 81 to 100 do write(char100[i]);
writeln('"');
writeln('should be ');
writeln('""');
writeln('""');
writeln('"" (error)');
cintas(int,char100,-7);
writeln('value is ');
write('"');
for i:= 1 to 40 do write(char100[i]);
writeln('"');
write('"');
for i:= 41 to 80 do write(char100[i]);
writeln('"');
write('"');
for i:= 81 to 100 do write(char100[i]);
writeln('"');
writeln('should be ');
writeln('"  31002"');
writeln('""');
writeln('""');
end;  { procedure Test_type1 }


Procedure Test_type0;
  { Test type0 strings }

Var
  i: integer;

Begin
writeln('then the standard tests using type0 strings');

int:= 2;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "         2"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "2"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    2"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "2"');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    2"');

int:= 2456;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "      2456"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "2456"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    2456"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be " 2456"');

int:= -2456;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "     -2456"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "-2456"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    -2456"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "-2456"');

int:= 0;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "         0"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "0"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    0"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "0"');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    0"');

int:= 31002;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "     31002"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "31002"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    31002"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "31002"');

int:= -31002;
cintas(int,string10,0);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    -31002"');
cintas(int,string10,1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "-31002"');
cintas(int,string10,5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "    -31002"');
cintas(int,string10,-1);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string10,-5);
write('value is    "');
swrite(output,string10);
writeln('"');
writeln('  should be "" (error)');

int:= -31002;
cintas(int,string2,0);
write('value is    "');
swrite(output,string2);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string2,1);
write('value is    "');
swrite(output,string2);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string2,5);
write('value is    "');
swrite(output,string2);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string2,-1);
write('value is    "');
swrite(output,string2);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string2,-5);
write('value is    "');
swrite(output,string2);
writeln('"');
writeln('  should be "" (error)');

int:= 31002;
cintas(int,string100,0);
write('value is    "');
swrite(output,string100);
writeln('"');
writeln('  should be "                             ',
'                                                                  31002"');
cintas(int,string100,1);
write('value is    "');
swrite(output,string100);
writeln('"');
writeln('  should be "31002"');
cintas(int,string100,5);
write('value is    "');
swrite(output,string100);
writeln('"');
writeln('  should be "    31002"');
cintas(int,string100,-1);
write('value is    "');
swrite(output,string100);
writeln('"');
writeln('  should be "" (error)');
cintas(int,string100,-7);
write('value is    "');
swrite(output,string100);
writeln('"');
writeln('  should be "  31002"');
end;  { Procedure Test_type0 }


{ main}

BEGIN
writeln('begin cintas test.');
writeln;
test_type1;

writeln;

writeln;
test_type0;

writeln;
write('Do you want to do some more numbers?> ');
readln(resp);
while resp[1] in ['Y','y'] do
  begin
  { test individul cases }
  writeln;
  write('Enter integer value> ');
  readln(int);
  write('Enter pos value (0=rj at end, - is rj at pos, + is lj at 1)> ');
  readln(pos);
  cintas(int,char6,pos);
  writeln('Alpha value is "',char6,'", int is ',int:1,' and pos is ',pos:1);
  writeln;
  write('Do you want to do some more numbers?> ');
  readln(resp);
  end;
writeln;
writeln;
writeln('end of test.');
writeln;

end.
