tverify.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {******************************************}
  2. { Used to check the DOS unit }
  3. {------------------------------------------}
  4. { SetVerify / GetVerify routine testing }
  5. {******************************************}
  6. Program tverify;
  7. uses dos;
  8. {$IFDEF GO32V2}
  9. {$DEFINE SUPPORTS_VERIFY}
  10. {$ENDIF}
  11. const
  12. has_errors : boolean = false;
  13. { verifies that the DOSError variable is equal to }
  14. { the value requested. }
  15. Procedure CheckDosError(err: Integer);
  16. var
  17. x : integer;
  18. s :string;
  19. Begin
  20. Write('Verifying value of DOS Error...');
  21. x := DosError;
  22. case x of
  23. 0 : s := '(0): No Error.';
  24. 2 : s := '(2): File not found.';
  25. 3 : s := '(3): Path not found.';
  26. 5 : s := '(5): Access Denied.';
  27. 6 : s := '(6): Invalid File Handle.';
  28. 8 : s := '(8): Not enough memory.';
  29. 10 : s := '(10) : Invalid Environment.';
  30. 11 : s := '(11) : Invalid format.';
  31. 18 : s := '(18) : No more files.';
  32. else
  33. s := 'INVALID DOSERROR';
  34. end;
  35. if err <> x then
  36. Begin
  37. WriteLn('FAILURE. (Value should be ',err,' '+s+')');
  38. has_errors:=true;
  39. end
  40. else
  41. WriteLn('Success.');
  42. end;
  43. Procedure TestVerify;
  44. Var
  45. B: Boolean;
  46. s: string;
  47. Begin
  48. WriteLn('----------------------------------------------------------------------');
  49. WriteLn(' GETVERIFY/SETVERIFY ');
  50. WriteLn('----------------------------------------------------------------------');
  51. CheckDosError(0);
  52. s:='Testing GetVerify...';
  53. SetVerify(TRUE);
  54. CheckDosError(0);
  55. GetVerify(b);
  56. CheckDosError(0);
  57. if b then
  58. WriteLn(s+'Success.')
  59. else
  60. Begin
  61. WriteLn(s+'FAILURE.');
  62. has_errors:=true;
  63. end;
  64. s:='Testing GetVerify...';
  65. SetVerify(FALSE);
  66. CheckDosError(0);
  67. GetVerify(b);
  68. CheckDosError(0);
  69. { verify actually only works under dos }
  70. { and always returns TRUE on other platforms }
  71. {$ifdef supports_verify}
  72. if NOT b then
  73. WriteLn(s+'Success.')
  74. else
  75. Begin
  76. WriteLn(s+'FAILURE.');
  77. has_errors:=true;
  78. end;
  79. {$else}
  80. if b then
  81. WriteLn(s+'Success.')
  82. else
  83. Begin
  84. WriteLn(s+'FAILURE.');
  85. has_errors:=true;
  86. end;
  87. {$endif}
  88. end;
  89. Begin
  90. testverify;
  91. if has_errors then
  92. halt(1);
  93. end.
  94. {
  95. $Log$
  96. Revision 1.2 2002-11-18 09:49:49 pierre
  97. * tried to make as many as possible tests non interactive
  98. Revision 1.1 2002/11/08 21:01:18 carl
  99. * separated some tests
  100. * make tfexpand more portable
  101. }