ProcessPath.pas 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 11269: ProcessPath.pas
  11. {
  12. { Rev 1.0 11/12/2002 09:19:26 PM JPMugaas
  13. { Initial check in. Import from FTP VC.
  14. }
  15. unit ProcessPath;
  16. interface
  17. {
  18. 2001-Nov-18 Peter Mee
  19. - Created.
  20. }
  21. uses
  22. IndyBox;
  23. type
  24. TProcessPathBox = class(TIndyBox)
  25. public
  26. procedure Test; override;
  27. end;
  28. implementation
  29. uses
  30. Classes,
  31. IdGlobal,
  32. SysUtils;
  33. procedure TProcessPathBox.Test;
  34. var
  35. TestData : TStringList;
  36. Base, Path, Delim, Res, RRes : String;
  37. index : Integer;
  38. TestNum : Integer;
  39. begin
  40. TestData := TStringList.Create;
  41. try
  42. TestData.LoadFromFile(GetDataDir + 'ProcessPath.dat');
  43. Index := 0;
  44. TestNum := 1;
  45. while Index < TestData.Count - 1 do
  46. begin
  47. Base := TestData[Index];
  48. if Length(Base) > 0 then
  49. begin
  50. if Base[1] = ':' then
  51. begin
  52. if Index >= TestData.Count - 4 then
  53. begin
  54. raise Exception.Create('Insufficient data for test ' + IntToStr(TestNum));
  55. end;
  56. // Have sufficient data for test.
  57. Base := TestData[Index + 1];
  58. Status('Test ' + IntToStr(TestNum) + ', Base: ' + Base);
  59. Path := TestData[Index + 2];
  60. Status('Test ' + IntToStr(TestNum) + ', Path: ' + Path);
  61. Delim := TestData[Index + 3];
  62. Status('Test ' + IntToStr(TestNum) + ', Delim: ' + Delim);
  63. Res := TestData[Index + 4];
  64. Status('Test ' + IntToStr(TestNum) + ', Ex. Result: ' + Res);
  65. RRes := IdGlobal.ProcessPath(Base, Path, Delim);
  66. Status('Test ' + IntToStr(TestNum) + ', Result: '
  67. + RRes);
  68. Check(Res = RRes,
  69. 'Test ' + IntToStr(TestNum) + ' failed');
  70. Inc(TestNum);
  71. end;
  72. end;
  73. Inc(index);
  74. end;
  75. finally
  76. FreeAndNil(TestData);
  77. end;
  78. end;
  79. initialization
  80. TIndyBox.RegisterBox(TProcessPathBox, 'ProcessPath', 'Misc');
  81. end.