tverify.pp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. { not anymore (JM) }
  72. if NOT b then
  73. WriteLn(s+'Success.')
  74. else
  75. Begin
  76. WriteLn(s+'FAILURE.');
  77. has_errors:=true;
  78. end;
  79. end;
  80. Begin
  81. testverify;
  82. if has_errors then
  83. halt(1);
  84. end.