tfsearch.pp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. program TFSearch;
  12. uses
  13. Dos;
  14. var
  15. S: string;
  16. F: file;
  17. Err: boolean;
  18. const
  19. TestDir: string = 'TESTDIR';
  20. TestFile: string = 'testfile';
  21. {$IFDEF MACOS}
  22. RelPathPrefix = ':';
  23. {$ELSE}
  24. RelPathPrefix = '';
  25. {$ENDIF}
  26. begin
  27. Err := false;
  28. MkDir (TestDir);
  29. S := FSearch (TestDir, '');
  30. if S <> '' then
  31. begin
  32. WriteLn ('FSearch should only find files, not directories!!');
  33. WriteLn ('Returned value = ', S);
  34. Err := true;
  35. end;
  36. Assign (F, RelPathPrefix + TestDir + DirectorySeparator + TestFile);
  37. Rewrite (F);
  38. Close (F);
  39. S := FSearch (TestFile, TestDir);
  40. if S <> RelPathPrefix + TestDir + DirectorySeparator + TestFile then
  41. begin
  42. WriteLn ('FSearch didn''t find the test file!!');
  43. WriteLn ('Returned value = ', S);
  44. Err := true;
  45. end;
  46. Erase (F);
  47. RmDir (TestDir);
  48. if Err then Halt (1);
  49. end.