home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / sk210f.zip / TESTUTIL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-13  |  5KB  |  191 lines

  1. {$I SHDEFINE.INC}
  2.  
  3. {$I SHUNITSW.INC}
  4.  
  5. unit TestUtil;
  6. {
  7.                        To test the ShUtilPk unit
  8.  
  9.                   Copyright 1991 Madison & Associates
  10.                           All Rights Reserved
  11.  
  12.          This program source file and the associated executable
  13.          file may be  used and distributed  only in  accordance
  14.          with the  provisions  described  on  the title page of
  15.                   the accompanying documentation file
  16.                               SKYHAWK.DOC
  17. }
  18.  
  19. interface
  20.  
  21. uses
  22.   TpCrt,
  23.   TpString,
  24.   TpDos,
  25.   ShUtilPk;
  26.  
  27. procedure UtilTest;
  28.  
  29. implementation
  30.  
  31. procedure UtilTest;
  32.  
  33. const
  34.   S1  : string = '  Now is  the        time  for all good gorps.   ';
  35.  
  36. var
  37.   S2,
  38.   O1,
  39.   O2  : string;
  40.   T1  : LongInt;
  41.   T2  : integer;
  42.   W1,
  43.   W2  : word;
  44.   F1  : file;
  45.  
  46.   O   : text;
  47.  
  48. procedure AnyKey;
  49.   begin
  50.     if HandleIsConsole(1) then begin
  51.       Write(O, 'Any key to continue...');
  52.       if ReadKey = #0 then ;
  53.       WriteLn(O);
  54.       end;
  55.     end;
  56.  
  57. begin
  58.   if OpenStdDev(O, 1) then ;
  59.   WriteLn(O, 'The functions BETWU and BETWS require such a large amount' );
  60.   WriteLn(O, 'of output to test them properly that it is not feasible to');
  61.   WriteLn(O, 'include them in this current test suite. The tests for'    );
  62.   WriteLn(O, 'these two functions will be found in the file TESTBETW, in');
  63.   WriteLn(O, 'both source and executable form.'                          );
  64.   WriteLn(O);
  65.   AnyKey;
  66.   WriteLn(O);
  67.   WriteLn(O, Center('REPALL, DELALL TEST', 75));
  68.   S2 := 'aabcbcabcd';
  69.   WriteLn(O, S2);
  70.   WriteLn(O, 'Replacing ''abc'' by ''12345''');
  71.   O1 := 'abc';
  72.   O2 := '12345';
  73.   WriteLn(O, RepAllF(S2, O1, O2));
  74.   WriteLn(O);
  75.   WriteLn(O, S2);
  76.   WriteLn(O, 'Deleting all ''abc''');
  77.   WriteLn(O, DelAllF(S2, O1));
  78.   WriteLn(O, '  Note: Did not delete strings caused by the DelAll process.');
  79.   WriteLn(O);
  80.   WriteLn(O, 'Deleting all (including incidental) ''abc''');
  81.   repeat
  82.     DelAll(S2, O1, S2);
  83.     until Pos(O1, S2) = 0;
  84.   WriteLn(O, S2);
  85.   AnyKey;
  86.   WriteLn(O);
  87.   WriteLn(O);
  88.   WriteLn(O, Center('GETNEXT TEST', 75));
  89.   WriteLn(O, '|',S1,'|');
  90.   T1 := 0;
  91.   repeat
  92.     inc(T1);
  93.     GetNext(S1, S2);
  94.     WriteLn(O, T1);
  95.     WriteLn(O, '|',S2,'|');
  96.     WriteLn(O, '|',S1,'|');
  97.     WriteLn(O);
  98.     AnyKey;
  99.     until S1 = '';
  100.   WriteLn(O);
  101.   WriteLn(O);
  102.   WriteLn(O, Center('HEX TEST', 75));
  103.   WriteLn(O, 'Inside the following loop, enter a number. When you want');
  104.   WriteLn(O, 'to break out of the loop, enter an alpha string instead.');
  105.   WriteLn(O);
  106.   if HandleIsConsole(1) then
  107.     repeat
  108.       Write(O, 'Enter an integer-type number » ');
  109.       {$I-}ReadLn(T1);{$I+}
  110.       T2 := IoResult;
  111.       if T2 = 0 then begin
  112.         WriteLn(O, '   The HEX equivalent is ',HEX(T1));
  113.         WriteLn(O);
  114.         end;
  115.       until T2 <> 0
  116.   else
  117.     WriteLn(O, 'HEX test not available under redirection.');
  118.   AnyKey;
  119.   WriteLn(O);
  120.   WriteLn(O);
  121.   WriteLn(O, Center('HIWORD, LOWORD, LI TEST', 75));
  122.   T1 := $DCBA9876;
  123.   WriteLn(O, Hex(T1),',   ',T1);
  124.   W1 := HiWord(T1);
  125.   W2 := LoWord(T1);
  126.   WriteLn(O, '':3,'HiWord(T1) = ',Hex(W1));
  127.   WriteLn(O, '':3,'LoWord(T1) = ',Hex(W2));
  128.   WriteLn(O, 'Re-assembling in reverse order:');
  129.   T1 := LI(W1, W2);
  130.   WriteLn(O, Hex(T1),',   ',T1);
  131.   AnyKey;
  132.   WriteLn(O);
  133.   WriteLn(O);
  134.   WriteLn(O, Center('PMOD TEST', 75));
  135.   WriteLn(O);
  136.   T1 := -7;
  137.   T2 := 13;
  138.   WriteLn(O, 'For X = ',T1,'   and M = ',T2);
  139.   WriteLn(O, '':5,'(X mod M) = ',(T1 mod T2));
  140.   WriteLn(O, '':2,'but');
  141.   WriteLn(O, '':5,'Pmod(X,M) = ',Pmod(T1, T2));
  142.   AnyKey;
  143.   WriteLn(O);
  144.   WriteLn(O);
  145.   WriteLn(O, Center('POSSET TEST', 75));
  146.   WriteLn(O, 'Str = ''XIY2C3Z4B'',    A = [''A'', ''B'', ''C'']');
  147.   WriteLn(O, '     PosSet(A, Str) returns ',PosSet(['A', 'B', 'C'], 'XIY2C3Z4B'));
  148.   AnyKey;
  149.   WriteLn(O);
  150.   WriteLn(O);
  151.   WriteLn(O, Center('SEARCHENVIRONMENT TEST', 75));
  152.   WriteLn(O, ^G'You will need to set up this test yourself, since there is no');
  153.   WriteLn(O, 'way for us to know what environment strings you have set up.');
  154.   AnyKey;
  155.   WriteLn(O);
  156.   WriteLn(O);
  157.   WriteLn(O, Center('STARSTRING TEST', 75));
  158.   S2 := 'ABCDEFG';
  159.   O1 := '*B*EFG';
  160.   O2 := '*B*EGF';
  161.   WriteLn(O, 'if');
  162.   WriteLn(O, '':3,'S2 := ''ABCDEFG''');
  163.   WriteLn(O, '':3,'O1 := ''*B*EFG''');
  164.   WriteLn(O, '':3,'O2 := ''*B*EGF''');
  165.   WriteLn(O, '     StarString(O1, S2) = ', StarString(O1, S2));
  166.   WriteLn(O, '     StarString(O2, S2) = ', StarString(O2, S2));
  167.   AnyKey;
  168.   WriteLn(O);
  169.   WriteLn(O);
  170.   WriteLn(O, Center('UNIQUEFILENAME TEST', 75));
  171.   S2 := UniqueFileName('', false);
  172.   WriteLn(O, 'A unique file name in this directory will be ',S2,' and');
  173.   WriteLn(O, '    this file will be temporarily created with a $$$ extension.');
  174.   assign(F1, S2);
  175.   Rewrite(F1);
  176.   Close(F1);
  177.   S2 := UniqueFileName('', true);
  178.   WriteLn(O, 'Another unique name with an extension will be ',S2);
  179.   Erase(F1);
  180.   AnyKey;
  181.   WriteLn(O);
  182.   WriteLn(O);
  183.   WriteLn(O, Center('WHOAMI TEST', 75));
  184.   if Hi(DosVersion) >= $03 then
  185.     WriteLn(O, 'The currently executing file is ',WhoAmI)
  186.   else
  187.     WriteLn(O, 'This function requires Dos version 3.0 or higher.');
  188.   Flush(O);
  189.   end; {UtilTest}
  190. end.
  191.