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 Line_Length and Page_Length maximums for a Text_IO
28 -- file of mode Append_File are initially zero (unbounded) after a
29 -- Create, Open, or Reset, and that these values can be modified using
30 -- the procedures Set_Line_Length and Set_Page_Length.
31 -- Check that setting the Line_Length and Page_Length attributes to zero
32 -- results in an unbounded Text_IO file.
33 -- Check that setting the line length when in Append_Mode doesn't
34 -- change the length of lines previously written to the Text_IO file.
37 -- This test attempts to simulate a possible text processing environment.
38 -- String values, from a number of different string types, are written to
39 -- a Text_IO file. Prior to the writing of each, the line length is set
40 -- to the particular length of the data being written. In addition, the
41 -- default line and page lengths are checked, to determine whether they
42 -- are unbounded (length = 0) following a create, reset, or open of a
43 -- Text_IO file with mode Append_File.
45 -- APPLICABILITY CRITERIA:
46 -- This test is applicable only to implementations that support text
51 -- 06 Dec 94 SAIC ACVC 2.0
52 -- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
60 Data_File
: Text_IO
.File_Type
;
61 Data_Filename
: constant String :=
62 Report
.Legal_File_Name
( Nam
=> "CXAA001" );
63 Incomplete
: exception;
66 Report
.Test
("CXAA001","Check that the Line_Length and Page_Length " &
67 "maximums for a Text_IO file of mode Append_File " &
68 "are initially zero (unbounded) after a Create, " &
69 "Open, or Reset, and that these values can be " &
70 "modified using the procedures Set_Line_Length " &
71 "and Set_Page_Length");
73 Test_for_Text_IO_Support
:
76 -- An implementation that does not support Text_IO in a particular
77 -- environment will raise Use_Error on calls to various
78 -- Text_IO operations. This block statement encloses a call to
79 -- Create, which should raise an exception in a non-supportive
80 -- environment. This exception will be handled to produce a
81 -- Not_Applicable result.
83 Text_IO
.Create
(File
=> Data_File
,
84 Mode
=> Text_IO
.Append_File
,
85 Name
=> Data_Filename
);
89 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
91 ( "Files not supported - Create as Append_File for Text_IO" );
94 end Test_for_Text_IO_Support
;
96 Operational_Test_Block
:
99 subtype Confidential_Data_Type
is string (1 .. 10);
100 subtype Secret_Data_Type
is string (1 .. 20);
101 subtype Top_Secret_Data_Type
is string (1 .. 30);
103 Zero
: constant Text_IO
.Count
:= 0;
104 Confidential_Data_Size
: constant Text_IO
.Count
:= 10;
105 Secret_Data_Size
: constant Text_IO
.Count
:= 20;
106 Top_Secret_Data_Size
: constant Text_IO
.Count
:= 30;
108 -- The following generic procedure is designed to simulate a text
109 -- processing environment where line and page sizes are set and
110 -- verified prior to the writing of data to a file.
113 Data_Size
: Text_IO
.Count
;
114 procedure Write_Data_To_File
(Data_Item
: in String);
116 procedure Write_Data_To_File
(Data_Item
: in String) is
117 use Text_IO
; -- Used to provide visibility to the "/=" operator.
119 if (Text_IO
.Line_Length
(Data_File
) /= Zero
) then -- Check default
120 Report
.Failed
("Line not of unbounded length"); -- line length,
121 elsif (Text_IO
.Page_Length
(Data_File
) /= Zero
) then -- default
122 Report
.Failed
("Page not of unbounded length"); -- page length.
125 Text_IO
.Set_Line_Length
(File
=> Data_File
, -- Set the line
126 To
=> Data_Size
); -- length.
127 Text_IO
.Set_Page_Length
(File
=> Data_File
, -- Set the page
128 To
=> Data_Size
); -- length.
129 -- Verify the lengths set.
130 if (Integer(Text_IO
.Line_Length
(Data_File
)) /=
131 Report
.Ident_Int
(Integer(Data_Size
))) then
132 Report
.Failed
("Line length not set to appropriate length");
133 elsif (Integer(Text_IO
.Page_Length
(Data_File
)) /=
134 Report
.Ident_Int
(Integer(Data_Size
))) then
135 Report
.Failed
("Page length not set to appropriate length");
138 Text_IO
.Put_Line
(File
=> Data_File
, -- Write data to
139 Item
=> Data_Item
); -- file.
141 end Write_Data_To_File
;
143 -- Instantiation for the three data types/sizes.
145 procedure Write_Confidential_Data
is
146 new Write_Data_To_File
(Data_Size
=> Confidential_Data_Size
);
148 procedure Write_Secret_Data
is
149 new Write_Data_To_File
(Data_Size
=> Secret_Data_Size
);
151 procedure Write_Top_Secret_Data
is
152 new Write_Data_To_File
(Data_Size
=> Top_Secret_Data_Size
);
154 Confidential_Item
: Confidential_Data_Type
:= "Confidenti";
155 Secret_Item
: Secret_Data_Type
:= "Secret Data Values ";
156 Top_Secret_Item
: Top_Secret_Data_Type
:=
157 "Extremely Top Secret Data ";
161 -- The following call simulates processing occurring after the create
162 -- of a Text_IO file with mode Append_File.
164 Write_Confidential_Data
(Confidential_Item
);
166 -- The following call simulates processing occurring after the reset
167 -- of a Text_IO file with mode Append_File.
171 Text_IO
.Reset
(Data_File
, Text_IO
.Append_File
); -- Reset to
174 when Text_IO
.Use_Error
=>
175 Report
.Not_Applicable
176 ( "Reset to Append_File not supported for Text_IO" );
180 Write_Secret_Data
(Data_Item
=> Secret_Item
);
182 Text_IO
.Close
(Data_File
); -- Close file.
184 -- The following processing simulates processing occurring after the
185 -- opening of an existing file with mode Append_File.
187 Text_IO
.Open
(Data_File
, -- Open file in
188 Text_IO
.Append_File
, -- Append_File mode.
191 Write_Top_Secret_Data
(Top_Secret_Item
);
193 Test_Verification_Block
:
197 TC_String3
: String (1..80) := (others => ' ');
200 TC_Length3
: Natural := 0;
205 Text_IO
.Reset
(Data_File
, Text_IO
.In_File
); -- Reset for reading.
207 when Text_IO
.Use_Error
=>
208 Report
.Not_Applicable
209 ( "Reset to In_File not supported for Text_IO" );
213 Text_IO
.Get_Line
(Data_File
, TC_String1
, TC_Length1
);
214 Text_IO
.Get_Line
(Data_File
, TC_String2
, TC_Length2
);
215 Text_IO
.Get_Line
(Data_File
, TC_String3
, TC_Length3
);
217 -- Verify that the line lengths of each line were accurate.
218 -- Note: Each data line was written to the file after the
219 -- particular line length had been set (to the data length).
221 if not ((TC_Length1
= Natural(Confidential_Data_Size
)) and
222 (TC_Length2
= Natural(Secret_Data_Size
)) and
223 (TC_Length3
= Natural(Top_Secret_Data_Size
))) then
224 Report
.Failed
("Inaccurate line lengths read from file");
227 -- Verify that the data read from the file are accurate.
229 if (TC_String1
(1..TC_Length1
) /= Confidential_Item
) or else
230 (TC_String2
(1..TC_Length2
) /= Secret_Item
) or else
231 (TC_String3
(1..TC_Length3
) /= Top_Secret_Item
) then
232 Report
.Failed
("Corrupted data items read from file");
241 Report
.Failed
("Error raised during data verification");
243 end Test_Verification_Block
;
251 Report
.Failed
("Exception raised during Text_IO processing");
253 end Operational_Test_Block
;
257 -- Check that the file is open prior to deleting it.
258 if Text_IO
.Is_Open
(Data_File
) then
259 Text_IO
.Delete
(Data_File
);
261 Text_IO
.Open
(Data_File
, Text_IO
.In_File
, Data_Filename
);
262 Text_IO
.Delete
(Data_File
);
267 ( "Delete not properly implemented for Text_IO" );
276 Report
.Failed
( "Unexpected exception" );