tbreak.pp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {******************************************}
  2. { Used to check the DOS unit }
  3. {------------------------------------------}
  4. { SetCBreak / GetCBreak routine testing }
  5. {******************************************}
  6. Program tbreak;
  7. uses dos;
  8. const
  9. has_errors : boolean = false;
  10. { verifies that the DOSError variable is equal to }
  11. { the value requested. }
  12. Procedure CheckDosError(err: Integer);
  13. var
  14. x : integer;
  15. s :string;
  16. Begin
  17. Write('Verifying value of DOS Error...');
  18. x := DosError;
  19. case x of
  20. 0 : s := '(0): No Error.';
  21. 2 : s := '(2): File not found.';
  22. 3 : s := '(3): Path not found.';
  23. 5 : s := '(5): Access Denied.';
  24. 6 : s := '(6): Invalid File Handle.';
  25. 8 : s := '(8): Not enough memory.';
  26. 10 : s := '(10) : Invalid Environment.';
  27. 11 : s := '(11) : Invalid format.';
  28. 18 : s := '(18) : No more files.';
  29. else
  30. s := 'INVALID DOSERROR';
  31. end;
  32. if err <> x then
  33. Begin
  34. WriteLn('FAILURE. (Value should be ',err,' '+s+')');
  35. has_errors:=true;
  36. end
  37. else
  38. WriteLn('Success.');
  39. end;
  40. Procedure TestCBreak;
  41. Var
  42. B: Boolean;
  43. s: string;
  44. Begin
  45. WriteLn('----------------------------------------------------------------------');
  46. WriteLn(' GETCBREAK/SETCBREAK ');
  47. WriteLn('----------------------------------------------------------------------');
  48. CheckDosError(0);
  49. s:='Testing GetCBreak...';
  50. SetCBreak(TRUE);
  51. CheckDosError(0);
  52. GetCBreak(b);
  53. CheckDosError(0);
  54. if b then
  55. WriteLn(s+'Success.')
  56. else
  57. Begin
  58. has_errors:=true;
  59. WriteLn(s+'FAILURE.');
  60. end;
  61. { actually setting Ctrl-C only works under DOS }
  62. {$ifdef go32v2}
  63. s:='Testing GetCBreak...';
  64. SetCBreak(FALSE);
  65. CheckDosError(0);
  66. GetCBreak(b);
  67. CheckDosError(0);
  68. if NOT b then
  69. WriteLn(s+'Success.')
  70. else
  71. Begin
  72. has_errors:=true;
  73. WriteLn(s+'FAILURE.');
  74. end;
  75. {$endif}
  76. end;
  77. Begin
  78. testcbreak;
  79. if has_errors then
  80. Halt(1);
  81. end.