utfsearch.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {
  2. This file is part of the Free Pascal test suite.
  3. Copyright (c) 1999-2003 by the Free Pascal development team.
  4. Test for possible bugs in Dos.FSearch
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. unit utfsearch;
  13. interface
  14. uses punit, utrtl;
  15. implementation
  16. uses
  17. Dos;
  18. const
  19. TestDir: string = 'TESTDIR';
  20. TestFile: string = 'testfile';
  21. {$IFDEF MACOS}
  22. RelPathPrefix = ':';
  23. {$ELSE}
  24. RelPathPrefix = '';
  25. {$ENDIF}
  26. Function DoTestFSearch : TTestString;
  27. var
  28. R,S: string;
  29. F: file;
  30. begin
  31. Result:='';
  32. S := FSearch (TestDir, '');
  33. If not AssertEquals('FSearch should only find files, not directories!!','',S) then exit;
  34. // Create test file
  35. Assign (F, RelPathPrefix + TestDir + DirectorySeparator + TestFile);
  36. Rewrite (F);
  37. Close (F);
  38. S:=FSearch (TestFile, TestDir);
  39. // expected result
  40. R:=RelPathPrefix + TestDir + DirectorySeparator + TestFile;
  41. If not AssertEquals('FSearch didn''t find the test file!!',R,S) then exit;
  42. end;
  43. Function TestFSearch : TTestString;
  44. var
  45. F: file;
  46. begin
  47. MkDir (TestDir);
  48. Result:=DoTestFSearch;
  49. // Clean up
  50. {$i-}
  51. Assign (F, RelPathPrefix + TestDir + DirectorySeparator + TestFile);
  52. Erase (F);
  53. RmDir (TestDir);
  54. {$i+}
  55. end;
  56. begin
  57. AddTest('TestFSearch',@TestFsearch,EnsureSuite('Dos'));
  58. end.