3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that the exception Mode_Error is raised when an attempt is made
28 -- to skip a line or page using the predefined Skip_Line and Skip_Page
29 -- procedures on a text file with mode Append_File.
32 -- A scenario is created that demonstrates the potential for the
33 -- incorrect usage of predefined text processing subprograms, which
34 -- results in the raising of a Mode_Error exception.
35 -- A count is kept to ensure that each anticipated exception is in fact
36 -- raised and handled properly.
38 -- APPLICABILITY CRITERIA:
39 -- This test is applicable only to implementations that support text
44 -- 06 Dec 94 SAIC ACVC 2.0
45 -- 28 Feb 97 PWB.CTA Allowed for non-support of some IO operations
53 Text_File
: Text_IO
.File_Type
;
54 Text_Filename
: constant String :=
55 Report
.Legal_File_Name
( Nam
=> "CXAA013" );
56 Incomplete
: exception;
60 Report
.Test
("CXAA013", "Check that the exception Mode_Error is " &
61 "raised when an attempt is made to skip " &
62 "a line or page using the predefined " &
63 "Skip_Line and Skip_Page procedures on " &
64 "a text file with mode Append_File");
66 Test_for_Text_IO_Support
:
69 -- An application creates a text file with mode Append_File.
70 -- Use_Error will be raised if Text_IO operations or external files are not
73 Text_IO
.Create
(Text_File
, Text_IO
.Append_File
, Text_Filename
);
77 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
79 ( "Files not supported - Create as Append_File for Text_IO" );
82 end Test_for_Text_IO_Support
;
84 -- The application writes some amount of data to the file.
86 Text_IO
.Put_Line
(Text_File
, "Data entered into the file");
88 Operational_Test_Block
:
90 TC_Number_Of_Forced_Mode_Errors
: constant Natural := 2;
91 TC_Mode_Errors
: Natural := 0;
96 TC_Spacing
: constant Text_IO
.Count
:= 3;
99 -- During the course of its processing, the application may attempt to
100 -- invoke the Skip_Line procedure on a file that is currently in Append_File
101 -- mode (instead of the anticipated In_File mode). This results in the
102 -- raising of Mode_Error.
104 Text_IO
.Skip_Line
(Text_File
, TC_Spacing
);
105 Report
.Failed
("Exception not raised by Skip_Line");
107 -- An exception handler present within the application handles the exception
108 -- and processing can continue.
111 when Text_IO
.Mode_Error
=>
112 TC_Mode_Errors
:= TC_Mode_Errors
+ 1;
114 Report
.Failed
("Exception in Skip_Line processing");
115 end Test_for_Skip_Line
;
120 -- Again, during the course of its processing, the application incorrectly
121 -- assumes that the file mode is In_File, this time attempting to call the
122 -- Skip_Page procedure for the file (that is currently in Append_File mode).
124 Text_IO
.Skip_Page
(Text_File
);
125 Report
.Failed
("Exception not raised by Skip_Page");
127 -- Once again, an exception handler present within the application handles
128 -- the exception and processing continues.
131 when Text_IO
.Mode_Error
=>
132 TC_Mode_Errors
:= TC_Mode_Errors
+ 1;
134 Report
.Failed
("Exception in Skip_Page processing");
135 end Test_for_Skip_Page
;
137 if (TC_Mode_Errors
/= TC_Number_Of_Forced_Mode_Errors
) then
138 Report
.Failed
("Incorrect number of exceptions handled");
141 end Operational_Test_Block
;
145 -- Delete the external file.
146 if Text_IO
.Is_Open
(Text_File
) then
147 Text_IO
.Delete
(Text_File
);
149 Text_IO
.Open
(Text_File
, Text_IO
.In_File
, Text_Filename
);
150 Text_IO
.Delete
(Text_File
);
155 ( "Delete not properly implemented for Text_IO" );
164 Report
.Failed
( "Unexpected exception" );