home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / TPSTR121.ZIP / TSUITE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-12-18  |  11.7 KB  |  241 lines

  1. program test_suite;
  2. uses crt,strings;
  3. var s1,s2,s3,scale,lstr:string;
  4.     c1,c2,c3:char; i,j,k:integer; w:word; h:xstr;
  5. begin
  6.    clrscr;
  7.    writeln('This program should print ONLY THIS line.');
  8.    lstr:=xrange(#1,#255);
  9.    if not abbrev('delete','del',3) then writeln('ab1');
  10.    if abbrev('delete','del ',3) then writeln('ab2');
  11.    if abbrev('delete','delete ',3) then writeln('ab3');
  12.    if not abbrev('delete','delete',3) then writeln('ab4');
  13.    if not abbrev('','',0) then writeln('ab5');
  14.    if abbrev('',' ',0) then writeln('ab5.1');
  15.    if not abbrev(lstr,copy(lstr,1,254),253) then writeln('ab6');
  16.    if abbrev(lstr,substr(lstr,1,254)+' ',254) then writeln('ab7');
  17.  
  18.    if center('ABC',5,' ')<>' ABC ' then writeln('ct1');
  19.    if center('ABC',4,' ')<>'ABC ' then writeln('ct2');
  20.    if center('ABC',2,' ')<>'AB' then writeln('ct3');
  21.    if center('ABC',255,' ')<>left('',126,' ')+'ABC'+left('',126,' ') then
  22.        writeln('ct4');
  23.    if center('',3,'-')<>'---' then writeln('ct5');
  24.    if center('ABC',0,'-')<>'' then writeln('ct6');
  25.    if center(lstr,255,'-')<>lstr then writeln('ct7');
  26.  
  27.    if compare('abcdef','abcxxx')<>4 then writeln('cm1');
  28.    if compare('abcdef','')<>1 then writeln('cm2');
  29.    if compare('','abcdef')<>1 then writeln('cm3');
  30.    if compare('abcdef','abcdef')<>0 then writeln('cm4');
  31.    if compare('','')<>0 then writeln('cm5');
  32.    if compare(lstr,lstr)<>0 then writeln('cm6');
  33.    if compare(lstr,copy(lstr,1,254)+' ')<>255 then writeln('cm7');
  34.  
  35.    if copies('x',4)<>'xxxx' then writeln('cp1');
  36.    if copies('',255)<>'' then writeln('cp2');
  37.    if copies('xxxx',0)<>'' then writeln('cp3');
  38.    if copies('ab',3)<>'ababab' then writeln('cp4');
  39.    if copies(' ',255)<>left('',255,' ') then writeln('cp5');
  40.    if copies('abcd',64)<>copies('abcd',63) then writeln('cp6');
  41.  
  42.    if d2x(0)<>'0000' then writeln('dx1');
  43.    if d2x(256)<>'0100' then writeln('dx2');
  44.    if d2x(16)<>'0010' then writeln('dx3');
  45.    if d2x(word(-1))<>'FFFF' then writeln('dx4');
  46.  
  47.    if delstr(lstr,100,5)<>xrange(#1,#99)+xrange(#105,#255) then writeln('ds1');
  48.    if delstr(lstr,250,5)<>xrange(#1,#249)+#255 then writeln('ds2');
  49.    if delstr('abcde',1,2)<>'cde' then writeln('ds3');
  50.    if delstr('abcde',6,20)<>'abcde' then writeln('ds4');
  51.    if delstr('abcde',2,0)<>'abcde' then writeln('ds5');
  52.    if delstr('abcde',0,1)<>'bcde' then writeln('ds6');
  53.  
  54.    if delword('',2,255)<>'' then writeln('dw1');
  55.    if delword('one two three four five',2,3)<>'one five' then writeln('dw2');
  56.    if delword('one',1,0)<>'one' then writeln('dw3');
  57.    if delword('one two',2,2)<>'one ' then writeln('dw4');
  58.    if delword(' one ',1,1)<>' ' then writeln('dw5');
  59.    if delword(lstr,1,2)<>'' then writeln('dw6');
  60.    if delword(lstr,2,1)<>xrange(#1,#32) then writeln('dw7');
  61.  
  62.    if firstpos('','hello',0)<>0 then writeln('fp1');
  63.    if firstpos('one','',1)<>0 then writeln('fp2');
  64.    if firstpos('one','one two',2)<>0 then writeln('fp3');
  65.    if firstpos('one','one two',1)<>1 then writeln('fp4');
  66.    if firstpos('two ','one two',1)<>0 then writeln('fp5');
  67.    if firstpos('two','one two',3)<>5 then writeln('fp6');
  68.    if firstpos(xrange(#250,#255),lstr,1)<>250 then writeln('fp7');
  69.    if firstpos(#255,lstr,1)<>255 then writeln('fp8');
  70.  
  71.    if instr('xx','',5,'a')<>'aaaaxx' then writeln('is1');
  72.    if instr('','abcde',2,' ')<>'abcde' then writeln('is2');
  73.    if instr('123',lstr,253,' ')<>substr(lstr,1,252)+'123' then writeln('is3');
  74.    if instr('abcd','123',0,' ')<>'abcd123' then writeln('is4');
  75.    if instr('1',lstr,255,' ')<>substr(lstr,1,254)+'1' then writeln('is5');
  76.    if instr('',lstr,255,' ')<>lstr then writeln('is6');
  77.  
  78.    if justify('',10)<>left('',10,' ') then writeln('jf1');
  79.    if justify('one',10)<>'one       ' then writeln('jf2');
  80.    if justify(copies('12345',51),255)<>copies('12345',51) then writeln('jf3');
  81.    if justify(copies('123 ',51),253)<>copies('123  ',50)+'123' then
  82.        writeln('jf4');
  83.    if justify('a b',80)<>'a'+left('',78,' ')+'b' then writeln('jf5');
  84.  
  85.    if lastpos('','the quick brown fox etc.',0)<>0 then writeln('lp1');
  86.    if lastpos('t','the fox etc.',0)<>10 then writeln('lp2');
  87.    if lastpos('t','the fox etc.',9)<>1 then writeln('lp3');
  88.    if lastpos('th','the fox etc.',2)<>1 then writeln('lp4');
  89.    if lastpos('th','the fox etc.',1)<>0 then writeln('lp5');
  90.    if lastpos(#254+#255,lstr,0)<>254 then writeln('lp6');
  91.    if lastpos(#254+#255,lstr,254)<>0 then writeln('lp6.1');
  92.    if lastpos('the','',1)<>0 then writeln('lp7');
  93.    if lastpos(lstr,lstr,0)<>1 then writeln('lp8');
  94.  
  95.    if left('',1,' ')<>' ' then writeln('lf1');
  96.    if left('',0,' ')<>'' then writeln('lf2');
  97.    if left('x',255,' ')<>'x'+left('',254,' ') then writeln('lf3');
  98.    if left('xx',0,' ')<>'' then writeln('lf4');
  99.    if left(lstr,255,' ')<>lstr then writeln('lf5');
  100.    if left('hello',10,'x')<>'helloxxxxx' then writeln('lf6');
  101.  
  102.    if lowercase('AbCdEf123')<>'abcdef123' then writeln('lc1');
  103.    if lowercase('')<>'' then writeln('lc2');
  104.    if lowercase('A')<>'a' then writeln('lc3');
  105.    if lowercase(lstr)<>ovrstr(xrange('a','z'),lstr,65,' ') then writeln('lc4');
  106.  
  107.    if ovrstr('','abcdef',1,' ')<>'abcdef' then writeln('ol1');
  108.    if ovrstr('','',1,' ')<>'' then writeln('ol2');
  109.    if ovrstr(lstr,lstr,5,' ')<>xrange(#1,#4)+xrange(#1,#251) then writeln('ol3');
  110.    if ovrstr('x',lstr,255,' ')<>substr(lstr,1,254)+'x' then writeln('ol4');
  111.    if ovrstr('hello','',5,'x')<>'xxxxhello' then writeln('ol5');
  112.    if ovrstr('hello',' ',5,'x')<>' xxxhello' then writeln('ol6');
  113.  
  114.    if pos2word('',1)<>0 then writeln('pw1');
  115.    if pos2word('x',1)<>1 then writeln('pw2');
  116.    if pos2word(copies('1234 ',51),255)<>0 then writeln('pw3');
  117.    if pos2word(copies('1234 ',51),254)<>51 then writeln('pw4');
  118.    if pos2word(copies('1234 ',51),250)<>51 then writeln('pw5');
  119.    if pos2word(copies('1234 ',51),249)<>50 then writeln('pw6');
  120.    if pos2word('123',4)<>0 then writeln('pw7');
  121.  
  122.    if reverse('x')<>'x' then writeln('rv1');
  123.    if reverse('')<>'' then writeln('rv2');
  124.    if reverse('ab')<>'ba' then writeln('rv3');
  125.    if reverse('abc')<>'cba' then writeln('rv4');
  126.    if reverse(xrange(#1,#255))<>xrange(#255,#1) then writeln('rv5');
  127.  
  128.    if right('',1,' ')<>' ' then writeln('rt1');
  129.    if right('',0,' ')<>'' then writeln('rt2');
  130.    if right('x',255,' ')<>right('',254,' ')+'x' then writeln('rt3');
  131.    if right('xx',0,' ')<>'' then writeln('rt4');
  132.    if right(lstr,255,' ')<>lstr then writeln('rt5');
  133.    if right(lstr,254,' ')<>xrange(#2,#255) then writeln('rt5.1');
  134.    if right('hello',10,'x')<>'xxxxxhello' then writeln('rt6');
  135.  
  136.    if scanmem(#20,@lstr,255)<>20 then writeln('sm1');
  137.    if scanmem(#254+#255,@lstr,256)<>254 then writeln('sm2');
  138.    if scanmem(#254+#255,@lstr,255)<>$FFFF then writeln('sm3');
  139.    if scanmem(#255+#1,@lstr,2)<>0 then writeln('sm4');
  140.    if scanmem(#255+#1,@lstr,1)<>$FFFF then writeln('sm5');
  141.    if scanmem(lstr,ptr(dseg,0),$FFFF)=$FFFF then writeln('sm6');
  142.  
  143.    if space(copies('123 ',51),2)<>copies('123  ',50)+'123' then writeln('sp1');
  144.    if space(copies('1234 ',51),0)<>copies('1234',51) then writeln('sp2');
  145.    if space('    abcd   ',50)<>'abcd' then writeln('sp3');
  146.    if space(lstr,2)<>substr(lstr,1,31) then writeln('sp4');
  147.    if space('     ',1)<>'' then writeln('sp5');
  148.    if space('',1)<>'' then writeln('sp5.1');
  149.    if space(copies('1234 ',51),2)<>copies('1234  ',41)+'1234' then writeln('sp6');
  150.    if space(copies('1234 ',51),0)<>copies('1234',51) then writeln('sp7');
  151.    if space('a b',253)<>'a'+left('',253,' ')+'b' then writeln('sp8');
  152.    if space('a b',254)<>'a' then writeln('sp9');
  153.    if space('     a',1)<>'a' then writeln('sp10');
  154.  
  155.    if strip('--hello----','l','-')<>'hello----' then writeln('st1');
  156.    if strip('--hello----','t','-')<>'--hello' then writeln('st2');
  157.    if strip('--h----','b','-')<>'h' then writeln('st3');
  158.    if strip('------','l','-')<>'' then writeln('st4');
  159.    if strip('------','t','-')<>'' then writeln('st5');
  160.    if strip('------','b','-')<>'' then writeln('st6');
  161.    if strip('','b','-')<>'' then writeln('st7');
  162.    if strip('---h---','l','-')<>'h---' then writeln('st8');
  163.  
  164.    if substr(lstr,1,0)<>'' then writeln('ss1');
  165.    if substr(lstr,1,255)<>lstr then writeln('ss2');
  166.    if substr('',1,20)<>'' then writeln('ss3');
  167.    if substr(lstr,255,5)<>#255 then writeln('ss4');
  168.    if substr(lstr,1,1)<>#1 then writeln('ss5');
  169.  
  170.    if subword(lstr,1,1)<>xrange(#1,#31) then writeln('sw1');
  171.    if subword('    one    two    three',1,2)<>'one    two' then writeln('sw2');
  172.    if subword(lstr,2,5)<>xrange(#33,#255) then writeln('sw3');
  173.    if subword('    one    two    three ',4,1)<>'' then writeln('sw4');
  174.    if subword('    one    two three ',2,2)<>'two three' then writeln('sw5');
  175.    if subword('    ',1,1)<>'' then writeln('sw6');
  176.    if subword(' a   one    two    three ',1,1)<>'a' then writeln('sw7');
  177.  
  178.    if translate(lstr,lstr,reverse(lstr))<>reverse(lstr) then writeln('tr1');
  179.    if translate(lstr,'','')<>lstr then writeln('tr2');
  180.    if translate('',lstr,reverse(lstr))<>'' then writeln('tr3');
  181.    if translate('a','abc','bca')<>'b' then writeln('tr4');
  182.    if translate(lstr,lstr,lstr)<>lstr then writeln('tr5');
  183.  
  184.    if uppercase('AbCdEf123')<>'ABCDEF123' then writeln('uc1');
  185.    if uppercase('')<>'' then writeln('uc2');
  186.    if uppercase('a')<>'A' then writeln('uc3');
  187.    if uppercase(lstr)<>ovrstr(xrange('A','Z'),lstr,97,' ') then writeln('uc4');
  188.  
  189.    if verify('a',lstr,'m',1)<>1 then writeln('vr1');
  190.    if verify(lstr,'a','m',1)<>97 then writeln('vr2');
  191.    if verify(lstr,ovrstr(' ',lstr,100,' '),'n',1)<>100 then writeln('vr3');
  192.    if verify('a',lstr,'m',1)<>1 then writeln('vr4');
  193.    if verify('',lstr,'m',1)<>0 then writeln('vr5');
  194.    if verify(lstr,'','m',1)<>0 then writeln('vr6');
  195.    if verify(lstr,lstr,'n',1)<>0 then writeln('vr7');
  196.    if verify(lstr,ovrstr(' ',lstr,255,' '),'n',255)<>255 then writeln('vr7.1');
  197.    if verify('abcdef','zyxwvuc','m',4)<>0 then writeln('vr8');
  198.    if verify('abcdef','czyxwvu','m',3)<>3 then writeln('vr9');
  199.    if verify('abcdef',lstr,'n',1)<>0 then writeln('vr10');
  200.    if verify('abc1def','abcdef','n',5)<>0 then writeln('vr11');
  201.    if verify('abc1def','abcdef','n',4)<>4 then writeln('vr12');
  202.  
  203.    if werd('',1)<>'' then writeln('wd1');
  204.    if werd('a b c',1)<>'a' then writeln('wd2');
  205.    if werd('a b c',3)<>'c' then writeln('wd3');
  206.    if werd(lstr,2)<>substr(lstr,33,223) then writeln('wd4');
  207.    if werd(lstr,3)<>'' then writeln('wd5');
  208.    if werd(lstr,1)<>substr(lstr,1,31) then writeln('wd6');
  209.    if werd(ovrstr(' ',lstr,254,' '),3)<>#255 then writeln('wd7');
  210.    if werd('one two three four five six',6)<>'six' then writeln('wd8');
  211.  
  212.    if word2pos('',1)<>0 then writeln('wp1');
  213.    if word2pos(lstr,2)<>33 then writeln('wp2');
  214.    if word2pos(ovrstr(' ',lstr,254,' '),3)<>255 then writeln('wp3');
  215.    if word2pos('one two three four five six',3)<>9 then writeln('wp4');
  216.    if word2pos('one two three four five six',1)<>1 then writeln('wp5');
  217.    if word2pos('one two three four five six',7)<>0 then writeln('wp6');
  218.  
  219.    if words(ovrstr(' ',lstr,254,' '))<>3 then writeln('wds1');
  220.    if words(lstr)<>2 then writeln('wds2');
  221.    if words(' ')<>0 then writeln('wds3');
  222.    if words('')<>0 then writeln('wds4');
  223.    if words('one two three four five six')<>6 then writeln('wds5');
  224.    if words(left('',255,' '))<>0 then writeln('wds6');
  225.    if words(left('',255,'x'))<>1 then writeln('wds7');
  226.  
  227.    if x2d('ff')<>255 then writeln('xd1');
  228.    if x2d('0')<>0 then writeln('xd2');
  229.    if x2d('10')<>16 then writeln('xd3');
  230.    if x2d('100')<>256 then writeln('xd4');
  231.    if x2d('111')<>273 then writeln('xd5');
  232.    if x2d('1000')<>4096 then writeln('xd6');
  233.    if x2d('0001')<>1 then writeln('xd7');
  234.  
  235.    if xrange(#1,#1)<>#1 then writeln('xr1');
  236.    if xrange(#0,#255)<>xrange(#0,#254) then writeln('xr2');
  237.    if xrange(#255,#1)<>reverse(xrange(#1,#255)) then writeln('xr3');
  238.    if xrange(#2,#1)<>#2+#1 then writeln('xr4');
  239.  
  240. end.
  241.