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 procedure Put, when called with string parameters, does
28 -- not update the line number of a text file of mode Append_File, when
29 -- the line length is unbounded (i.e., only the column number is
31 -- Check that a call to the procedure Put with a null string argument
32 -- has no measurable effect on a text file of mode Append_File.
35 -- This test is designed to ensure that when a string is appended to an
36 -- unbounded text file, it is placed following the last element currently
37 -- in the file. For an unbounded text file written with Put procedures
38 -- only (not Put_Line), the line number should not be incremented by
39 -- subsequent calls to Put in Append_File mode. Only the column number
40 -- should be incremented based on the length of the string parameter
41 -- placed in the file. If a call to Put with a null string argument is
42 -- made, no change to the line or column number should occur, and no
43 -- element(s) should be added to the file, so that there would be no
44 -- measurable change to the file.
46 -- APPLICABILITY CRITERIA:
47 -- This test is applicable to all implementations that support Text_IO
48 -- processing and external files.
52 -- 06 Dec 94 SAIC ACVC 2.0
53 -- 24 Feb 97 CTA.PWB Allowed for non-support of some IO operations.
60 An_Unbounded_File
: Ada
.Text_IO
.File_Type
;
61 Unbounded_File_Name
: constant String :=
62 Report
.Legal_File_Name
( Nam
=> "CXAA005" );
63 Incomplete
: exception;
67 Report
.Test
("CXAA005", "Check that the procedure Put does not " &
68 "increment line numbers when used with " &
69 "unbounded text files of mode Append_File");
71 Test_for_Text_IO_Support
:
74 -- An application creates a text file in mode Out_File, with the intention
75 -- of entering string data packets into the file as appropriate. In the
76 -- event that the particular environment where the application is running
77 -- does not support Text_IO, Use_Error will be raised on calls to Text_IO
79 -- This exception will be handled to produce a Not_Applicable result.
81 Ada
.Text_IO
.Create
(File
=> An_Unbounded_File
,
82 Mode
=> Ada
.Text_IO
.Out_File
,
83 Name
=> Unbounded_File_Name
);
85 when Ada
.Text_IO
.Use_Error | Ada
.Text_IO
.Name_Error
=>
87 ( "Files not supported - Create for Text_IO" );
89 end Test_For_Text_IO_Support
;
91 Operational_Test_Block
:
93 subtype String_Sequence_Type
is string (1 .. 20);
94 type String_Pointer_Type
is access String_Sequence_Type
;
96 -- During the course of processing, the application creates a variety of data
97 -- pointers that refer to particular data items. The possibility of having
98 -- null data values in this environment exists.
100 Data_Packet_1
: String_Pointer_Type
:=
101 new String_Sequence_Type
'("One Data Sequence 01");
103 Data_Packet_2 : String_Pointer_Type :=
104 new String_Sequence_Type'("New Data Sequence 02");
106 Blank_Data_Packet
: String_Pointer_Type
:=
107 new String_Sequence_Type
'(" ");
109 Null_Data_Packet : constant String := "";
111 TC_Line, TC_Col : Natural := 0;
113 function TC_Mode_Selection (Selector : Integer)
114 return Ada.Text_IO.File_Mode is
117 when 1 => return Ada.Text_IO.In_File;
118 when 2 => return Ada.Text_IO.Out_File;
119 when others => return Ada.Text_IO.Append_File;
121 end TC_Mode_Selection;
125 -- The application places some data into the file, using the Put subroutine.
126 -- This operation can occur one-to-many times.
128 Ada.Text_IO.Put (An_Unbounded_File, Data_Packet_1.all);
130 -- Test control code.
131 if (Integer(Ada.Text_IO.Col (An_Unbounded_File)) /=
132 Report.Ident_Int(21)) or
133 (Integer(Ada.Text_IO.Line (An_Unbounded_File)) /=
134 Report.Ident_Int(1)) then
135 Report.Failed ("Incorrect Col position after 1st Put");
138 -- The application may close the file at some point following its initial
141 Ada.Text_IO.Close (An_Unbounded_File);
143 -- At some later point in the processing, more data needs to be added to the
144 -- file, so the application opens the file in Append_File mode.
146 Ada.Text_IO.Open (File => An_Unbounded_File,
147 Mode => Ada.Text_IO.Append_File,
148 Name => Unbounded_File_Name);
150 -- Test control code.
151 -- Store line/column number for later comparison.
152 TC_Line := Natural(Ada.Text_IO.Line(An_Unbounded_File));
153 TC_Col := Natural(Ada.Text_IO.Col(An_Unbounded_File));
155 -- Additional data items can then be appended to the file.
157 Ada.Text_IO.Put (An_Unbounded_File, Blank_Data_Packet.all);
159 -- Test control code.
160 if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
162 (Natural(Ada.Text_IO.Line (An_Unbounded_File)) /=
164 Report.Failed ("Incorrect Col position after 2nd Put");
167 -- In order to accommodate various scenarios, the application may have changed
168 -- the mode of the data file to In_File in order to retrieve/verify some of
169 -- the data contained there. However, with the need to place more data into
170 -- the file, the file can be reset to Append_File mode.
174 Ada.Text_IO.Reset (An_Unbounded_File,
175 TC_Mode_Selection (Report.Ident_Int(3)));
177 when Ada.Text_IO.Use_Error =>
178 Report.Not_Applicable
179 ( "Reset to Append_File not supported for Text_IO" );
183 -- Test control code.
184 -- Store line/column number for later comparison.
185 TC_Line := Natural(Ada.Text_IO.Line(An_Unbounded_File));
186 TC_Col := Natural(Ada.Text_IO.Col(An_Unbounded_File));
188 -- Additional data can then be appended to the file. On some occasions, an
189 -- attempt to enter a null string value into the file may occur. This should
190 -- have no effect on the file, leaving it unchanged.
192 -- No measurable effect from Put with null string.
193 Ada.Text_IO.Put (An_Unbounded_File, Null_Data_Packet);
195 -- Test control code.
196 -- There should be no change following the Put above.
197 if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
199 (Natural(Ada.Text_IO.Line (An_Unbounded_File)) /=
201 Report.Failed ("Incorrect Col position after 3rd Put");
204 -- Additional data can be appended to the file.
206 Ada.Text_IO.Put (An_Unbounded_File, Data_Packet_2.all);
208 -- Test control code.
209 if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
211 (Integer(Ada.Text_IO.Line (An_Unbounded_File)) /=
213 Report.Failed ("Incorrect Col position after 4th Put");
216 Test_Verification_Block:
218 File_Data : String (1 .. 80);
222 -- The application has the capability to reset the file to In_File mode to
223 -- verify some of the data that is contained there.
227 Ada.Text_IO.Reset (An_Unbounded_File, Ada.Text_IO.In_File);
229 when Ada.Text_IO.Use_Error =>
230 Report.Not_Applicable
231 ( "Reset to In_File not supported - Text_IO" );
235 Ada.Text_IO.Get_Line (An_Unbounded_File,
239 -- Test control code.
240 -- Since it is implementation defined whether a page
241 -- terminator separates preexisting text from new text
242 -- following an open in append mode (as occurred above),
243 -- verify only that the first data item written to the
244 -- file was not overwritten by any subsequent call to Put.
246 if (File_Data (File_Data'First) /= 'O
') or
247 (File_Data (20) /= '1') then
248 Report.Failed ("Data placed incorrectly in file");
255 Report.Failed ("Error raised during data verification");
256 end Test_Verification_Block;
262 Report.Failed ("Exception in Text_IO processing");
263 end Operational_Test_Block;
267 -- Delete the external file.
268 if Ada.Text_IO.Is_Open(An_Unbounded_File) then
269 Ada.Text_IO.Delete (An_Unbounded_File);
271 Ada.Text_IO.Open(An_Unbounded_File,
273 Unbounded_File_Name);
274 Ada.Text_IO.Delete (An_Unbounded_File);
279 ( "Delete not properly implemented -- Text_IO" );
289 Report.Failed ( "Unexpected exception" );