HeaderCoder.pas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: 11255: HeaderCoder.pas
  11. {
  12. { Rev 1.1 2003.07.11 4:07:42 PM czhower
  13. { Removed deprecated BXBoxster reference.
  14. }
  15. {
  16. { Rev 1.0 11/12/2002 09:18:16 PM JPMugaas
  17. { Initial check in. Import from FTP VC.
  18. }
  19. unit HeaderCoder;
  20. interface
  21. uses
  22. IndyBox;
  23. type
  24. THeaderCoderBox = class(TIndyBox)
  25. public
  26. procedure TestString(const AIn, AOut: string);
  27. procedure Test; override;
  28. end;
  29. implementation
  30. uses
  31. IdCoderHeader,
  32. IniFiles,
  33. SysUtils;
  34. { THeaderCoderBox }
  35. procedure THeaderCoderBox.Test;
  36. var
  37. inifile: TMemIniFile;
  38. i: integer;
  39. begin
  40. inifile := TMemIniFile.Create(GetDataDir+'headers.ini');
  41. try
  42. i := inifile.ReadInteger('main','count',-1);
  43. while i > 0 do begin
  44. TestString(inifile.ReadString('test '+inttostr(i), 'encoded',''),
  45. inifile.ReadString('test '+inttostr(i), 'decoded',''));
  46. Dec(i);
  47. end;
  48. finally
  49. inifile.free;
  50. end;
  51. end;
  52. procedure THeaderCoderBox.TestString(const AIn, AOut: string);
  53. begin
  54. Status('Testing '+AIn);
  55. Check(IdCoderHeader.DecodeHeader(AIn) = AOut, 'Header '+AIn+' failed to decode into '+AOut);
  56. end;
  57. initialization
  58. TIndyBox.RegisterBox(THeaderCoderBox, 'Header', 'Coders');
  59. end.