tenv.pp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {******************************************}
  2. { Used to check the DOS unit }
  3. {------------------------------------------}
  4. { TestEncCount routine testing }
  5. {******************************************}
  6. Program tenv;
  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 TestEnvCount;
  41. Var
  42. I: Integer;
  43. Begin
  44. WriteLn('----------------------------------------------------------------------');
  45. WriteLn(' ENVCOUNT/ENVSTR ');
  46. WriteLn('----------------------------------------------------------------------');
  47. WriteLn(' Note: Environment variables should be of the form VAR=VALUE ');
  48. WriteLn(' Note: Non valid indexes should return empty strings. ');
  49. WriteLn(' Note: Index 0 points to an empty string ');
  50. WriteLn('----------------------------------------------------------------------');
  51. CheckDosError(0);
  52. {*------------------------- NOTE -------------------------------------*}
  53. {* Variables should be of the form VAR=VALUE *}
  54. {*--------------------------------------------------------------------*}
  55. WriteLn('Number of environment variables : ',EnvCount);
  56. WriteLn('CURRENT ENVIRONMENT');
  57. For I:=1 to EnvCount do
  58. WriteLn(EnvStr(i));
  59. CheckDosError(0);
  60. WriteLn('----------------------------------------------------------------------');
  61. WriteLn(' Note: The next few lines should be empty strings, as they are ');
  62. WriteLn(' invalid environment indexes. ');
  63. WriteLn('----------------------------------------------------------------------');
  64. For i:=-5 to 0 do
  65. WriteLn(EnvStr(i));
  66. CheckDosError(0);
  67. For i:=20000 to 20002 do
  68. WriteLn(EnvStr(i));
  69. CheckDosError(0);
  70. end;
  71. Begin
  72. TestEnvCount;
  73. if has_errors then
  74. Halt(1);
  75. end.