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 for a bounded line length text file of mode Append_File,
28 -- when the number of characters to be output exceeds the number of
29 -- columns remaining on the current line, a call to Put will output
30 -- characters of the string sufficient to fill the remaining columns of
31 -- the line (up to line length), then output a line terminator, reset the
32 -- column number, increment the line number, then output the balance of
35 -- Check that the procedure Put does not raise Layout_Error when the
36 -- number of characters to be output exceeds the line length of a bounded
37 -- text file of mode Append_File.
40 -- This test demonstrates the situation where an application intends to
41 -- output variable length string elements to a text file in the most
42 -- efficient manner possible. This is the case in a typesetting
43 -- environment where text is compressed and split between lines of a
46 -- The procedure Put will break string parameters placed in the file at
47 -- the point of the line length. Two examples are demonstrated in this
48 -- test, one being the case where only one column remains on a line, and
49 -- the other being the case where a larger portion of the line remains
50 -- unfilled, but still not sufficient to contain the entire output
53 -- During the course of the test, the file is reset to Append_File mode,
54 -- and the bounded line length is modified for different lines of the
57 -- APPLICABILITY CRITERIA:
58 -- This test is applicable to all implementations that support Text_IO
59 -- processing and external files.
63 -- 06 Dec 94 SAIC ACVC 2.0
64 -- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
72 A_Bounded_File
: Ada
.Text_IO
.File_Type
;
73 Bounded_File_Name
: constant String :=
74 Report
.Legal_File_Name
( Nam
=> "CXAA006" );
75 Incomplete
: exception;
79 Report
.Test
("CXAA006", "Check that procedure Put will correctly " &
80 "output string items to a bounded line " &
81 "length text file of mode Append_File");
83 Test_for_Text_IO_Support
:
86 -- An application creates a text file in mode Append_File, with the intention
87 -- of using the procedure Put to compress variable length string data into the
88 -- file in the most efficient manner possible.
90 Ada
.Text_IO
.Create
(File
=> A_Bounded_File
,
91 Mode
=> Ada
.Text_IO
.Append_File
,
92 Name
=> Bounded_File_Name
);
94 when Ada
.Text_IO
.Use_Error | Ada
.Text_IO
.Name_Error
=>
96 ( "Files not supported - Create with Append_File for Text_IO" );
98 end Test_For_Text_IO_Support
;
100 Operational_Test_Block
:
102 Twelve_Characters
: constant String := "12Characters";
103 Nineteen_Characters
: constant String := "Nineteen_Characters";
104 TC_Line
: Natural := 0;
106 function TC_Mode_Selection
(Selector
: Integer)
107 return Ada
.Text_IO
.File_Mode
is
110 when 1 => return Ada
.Text_IO
.In_File
;
111 when 2 => return Ada
.Text_IO
.Out_File
;
112 when others => return Ada
.Text_IO
.Append_File
;
114 end TC_Mode_Selection
;
118 -- The application sets the line length of the file to be bound at 20. All
119 -- lines in this file will be limited to that length.
121 Ada
.Text_IO
.Set_Line_Length
(A_Bounded_File
, 20);
123 Ada
.Text_IO
.Put
(A_Bounded_File
, Nineteen_Characters
);
125 -- Test control code.
126 if (Integer(Ada
.Text_IO
.Line
(A_Bounded_File
)) /=
127 Report
.Ident_Int
(1)) or
128 (Integer(Ada
.Text_IO
.Col
(A_Bounded_File
)) /=
129 Report
.Ident_Int
(20)) then
130 Report
.Failed
("Incorrect position after 1st Put");
133 -- The application finds that there is only one column available on the
134 -- current line, so the next string item to be output must be broken at
135 -- the appropriate place (following the first character).
137 Ada
.Text_IO
.Put
(File
=> A_Bounded_File
,
138 Item
=> Twelve_Characters
);
140 -- Test control code.
141 if (Integer(Ada
.Text_IO
.Line
(A_Bounded_File
)) /=
142 Report
.Ident_Int
(2)) or
143 (Integer(Ada
.Text_IO
.Col
(A_Bounded_File
)) /=
144 Report
.Ident_Int
(12)) then
145 Report
.Failed
("Incorrect position after 2nd Put");
148 -- The application subsequently modifies the processing, resetting the file
149 -- at this point to In_File mode in order to verify data that has been written
150 -- to the file. Following this, the application resets the file to Append_File
151 -- mode in order to continue the placement of data into the file, but modifies
152 -- the original bounded line length for subsequent lines to be appended.
154 -- Reset to Append mode; call outputs page terminator and
155 -- resets line length to Unbounded.
158 Ada
.Text_IO
.Reset
(A_Bounded_File
,
159 TC_Mode_Selection
(Report
.Ident_Int
(3)));
161 when Ada
.Text_IO
.Use_Error
=>
162 Report
.Not_Applicable
163 ( "Reset to Append_File not supported for Text_IO" );
167 Ada
.Text_IO
.Set_Line_Length
(A_Bounded_File
, 15);
169 -- Store line number for later comparison.
170 TC_Line
:= Natural(Ada
.Text_IO
.Line
(A_Bounded_File
));
172 -- The application finds that fifteen columns are available on the current
173 -- line but that the string item to be output exceeds this available space.
174 -- It must be split at the end of the line, and the balance placed on the
177 Ada
.Text_IO
.Put
(File
=> A_Bounded_File
,
178 Item
=> Nineteen_Characters
);
180 -- Test control code.
181 -- Positioned on new line at col 5.
182 if (Natural(Ada
.Text_IO
.Line
(A_Bounded_File
)) /=
184 (Integer(Ada
.Text_IO
.Col
(A_Bounded_File
)) /=
185 Report
.Ident_Int
(5)) then
186 Report
.Failed
("Incorrect position after 3rd Put");
190 Test_Verification_Block
:
192 First_String
: String (1 .. 80);
193 Second_String
: String (1 .. 80);
194 Third_String
: String (1 .. 80);
195 Fourth_String
: String (1 .. 80);
202 -- The application has the capability to reset the file to In_File mode to
203 -- verify some or all of the data that is contained there.
207 Ada
.Text_IO
.Reset
(A_Bounded_File
, Ada
.Text_IO
.In_File
);
210 Report
.Not_Applicable
211 ( "Reset to In_File not supported for Text_IO" );
216 (A_Bounded_File
, First_String
, TC_Width1
);
218 (A_Bounded_File
, Second_String
, TC_Width2
);
220 (A_Bounded_File
, Third_String
, TC_Width3
);
222 (A_Bounded_File
, Fourth_String
, TC_Width4
);
224 -- Test control code.
225 if (First_String
(1..TC_Width1
) /= Nineteen_Characters
& "1") or
226 (Second_String
(1..TC_Width2
) /= "2Characters") or
227 (Third_String
(1..TC_Width3
) /=
228 Nineteen_Characters
(1..15)) or
229 (Fourth_String
(1..TC_Width4
) /= "ters")
231 Report
.Failed
("Data placed incorrectly in file");
239 when Ada
.Text_IO
.End_Error
=>
240 Report
.Failed
("Incorrect number of lines in file");
243 Report
.Failed
("Error raised during data verification");
245 end Test_Verification_Block
;
249 when Ada
.Text_IO
.Layout_Error
=>
250 Report
.Failed
("Layout Error raised when positioning text");
253 Report
.Failed
("Exception in Text_IO processing");
255 end Operational_Test_Block
;
259 -- Delete the external file.
260 if Ada
.Text_IO
.Is_Open
(A_Bounded_File
) then
261 Ada
.Text_IO
.Delete
(A_Bounded_File
);
263 Ada
.Text_IO
.Open
(A_Bounded_File
,
266 Ada
.Text_IO
.Delete
(A_Bounded_File
);
272 ( "Delete not properly implemented for Text_IO" );
282 Report
.Failed
( "Unexpected exception" );