1 |
149 |
jeremybenn |
-- CXAA005.A
|
2 |
|
|
--
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
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
|
14 |
|
|
-- to do so.
|
15 |
|
|
--
|
16 |
|
|
-- DISCLAIMER
|
17 |
|
|
--
|
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.
|
24 |
|
|
--*
|
25 |
|
|
--
|
26 |
|
|
-- OBJECTIVE:
|
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
|
30 |
|
|
-- updated).
|
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.
|
33 |
|
|
--
|
34 |
|
|
-- TEST DESCRIPTION:
|
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.
|
45 |
|
|
--
|
46 |
|
|
-- APPLICABILITY CRITERIA:
|
47 |
|
|
-- This test is applicable to all implementations that support Text_IO
|
48 |
|
|
-- processing and external files.
|
49 |
|
|
--
|
50 |
|
|
--
|
51 |
|
|
-- CHANGE HISTORY:
|
52 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
53 |
|
|
-- 24 Feb 97 CTA.PWB Allowed for non-support of some IO operations.
|
54 |
|
|
--!
|
55 |
|
|
|
56 |
|
|
with Ada.Text_IO;
|
57 |
|
|
with Report;
|
58 |
|
|
|
59 |
|
|
procedure CXAA005 is
|
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;
|
64 |
|
|
|
65 |
|
|
begin
|
66 |
|
|
|
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");
|
70 |
|
|
|
71 |
|
|
Test_for_Text_IO_Support:
|
72 |
|
|
begin
|
73 |
|
|
|
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
|
78 |
|
|
-- operations.
|
79 |
|
|
-- This exception will be handled to produce a Not_Applicable result.
|
80 |
|
|
|
81 |
|
|
Ada.Text_IO.Create (File => An_Unbounded_File,
|
82 |
|
|
Mode => Ada.Text_IO.Out_File,
|
83 |
|
|
Name => Unbounded_File_Name);
|
84 |
|
|
exception
|
85 |
|
|
when Ada.Text_IO.Use_Error | Ada.Text_IO.Name_Error =>
|
86 |
|
|
Report.Not_Applicable
|
87 |
|
|
( "Files not supported - Create for Text_IO" );
|
88 |
|
|
raise Incomplete;
|
89 |
|
|
end Test_For_Text_IO_Support;
|
90 |
|
|
|
91 |
|
|
Operational_Test_Block:
|
92 |
|
|
declare
|
93 |
|
|
subtype String_Sequence_Type is string (1 .. 20);
|
94 |
|
|
type String_Pointer_Type is access String_Sequence_Type;
|
95 |
|
|
|
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.
|
99 |
|
|
|
100 |
|
|
Data_Packet_1 : String_Pointer_Type :=
|
101 |
|
|
new String_Sequence_Type'("One Data Sequence 01");
|
102 |
|
|
|
103 |
|
|
Data_Packet_2 : String_Pointer_Type :=
|
104 |
|
|
new String_Sequence_Type'("New Data Sequence 02");
|
105 |
|
|
|
106 |
|
|
Blank_Data_Packet : String_Pointer_Type :=
|
107 |
|
|
new String_Sequence_Type'(" ");
|
108 |
|
|
|
109 |
|
|
Null_Data_Packet : constant String := "";
|
110 |
|
|
|
111 |
|
|
TC_Line, TC_Col : Natural := 0;
|
112 |
|
|
|
113 |
|
|
function TC_Mode_Selection (Selector : Integer)
|
114 |
|
|
return Ada.Text_IO.File_Mode is
|
115 |
|
|
begin
|
116 |
|
|
case Selector 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;
|
120 |
|
|
end case;
|
121 |
|
|
end TC_Mode_Selection;
|
122 |
|
|
|
123 |
|
|
begin
|
124 |
|
|
|
125 |
|
|
-- The application places some data into the file, using the Put subroutine.
|
126 |
|
|
-- This operation can occur one-to-many times.
|
127 |
|
|
|
128 |
|
|
Ada.Text_IO.Put (An_Unbounded_File, Data_Packet_1.all);
|
129 |
|
|
|
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");
|
136 |
|
|
end if;
|
137 |
|
|
|
138 |
|
|
-- The application may close the file at some point following its initial
|
139 |
|
|
-- entry of data.
|
140 |
|
|
|
141 |
|
|
Ada.Text_IO.Close (An_Unbounded_File);
|
142 |
|
|
|
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.
|
145 |
|
|
|
146 |
|
|
Ada.Text_IO.Open (File => An_Unbounded_File,
|
147 |
|
|
Mode => Ada.Text_IO.Append_File,
|
148 |
|
|
Name => Unbounded_File_Name);
|
149 |
|
|
|
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));
|
154 |
|
|
|
155 |
|
|
-- Additional data items can then be appended to the file.
|
156 |
|
|
|
157 |
|
|
Ada.Text_IO.Put (An_Unbounded_File, Blank_Data_Packet.all);
|
158 |
|
|
|
159 |
|
|
-- Test control code.
|
160 |
|
|
if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
|
161 |
|
|
(TC_Col + 20)) or
|
162 |
|
|
(Natural(Ada.Text_IO.Line (An_Unbounded_File)) /=
|
163 |
|
|
TC_Line) then
|
164 |
|
|
Report.Failed ("Incorrect Col position after 2nd Put");
|
165 |
|
|
end if;
|
166 |
|
|
|
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.
|
171 |
|
|
|
172 |
|
|
Reset1:
|
173 |
|
|
begin
|
174 |
|
|
Ada.Text_IO.Reset (An_Unbounded_File,
|
175 |
|
|
TC_Mode_Selection (Report.Ident_Int(3)));
|
176 |
|
|
exception
|
177 |
|
|
when Ada.Text_IO.Use_Error =>
|
178 |
|
|
Report.Not_Applicable
|
179 |
|
|
( "Reset to Append_File not supported for Text_IO" );
|
180 |
|
|
raise Incomplete;
|
181 |
|
|
end Reset1;
|
182 |
|
|
|
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));
|
187 |
|
|
|
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.
|
191 |
|
|
|
192 |
|
|
-- No measurable effect from Put with null string.
|
193 |
|
|
Ada.Text_IO.Put (An_Unbounded_File, Null_Data_Packet);
|
194 |
|
|
|
195 |
|
|
-- Test control code.
|
196 |
|
|
-- There should be no change following the Put above.
|
197 |
|
|
if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
|
198 |
|
|
TC_Col) or
|
199 |
|
|
(Natural(Ada.Text_IO.Line (An_Unbounded_File)) /=
|
200 |
|
|
TC_Line) then
|
201 |
|
|
Report.Failed ("Incorrect Col position after 3rd Put");
|
202 |
|
|
end if;
|
203 |
|
|
|
204 |
|
|
-- Additional data can be appended to the file.
|
205 |
|
|
|
206 |
|
|
Ada.Text_IO.Put (An_Unbounded_File, Data_Packet_2.all);
|
207 |
|
|
|
208 |
|
|
-- Test control code.
|
209 |
|
|
if (Natural(Ada.Text_IO.Col (An_Unbounded_File)) /=
|
210 |
|
|
(TC_Col + 20)) or
|
211 |
|
|
(Integer(Ada.Text_IO.Line (An_Unbounded_File)) /=
|
212 |
|
|
TC_Line) then
|
213 |
|
|
Report.Failed ("Incorrect Col position after 4th Put");
|
214 |
|
|
end if;
|
215 |
|
|
|
216 |
|
|
Test_Verification_Block:
|
217 |
|
|
declare
|
218 |
|
|
File_Data : String (1 .. 80);
|
219 |
|
|
TC_Width : Natural;
|
220 |
|
|
begin
|
221 |
|
|
|
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.
|
224 |
|
|
|
225 |
|
|
Reset2:
|
226 |
|
|
begin
|
227 |
|
|
Ada.Text_IO.Reset (An_Unbounded_File, Ada.Text_IO.In_File);
|
228 |
|
|
exception
|
229 |
|
|
when Ada.Text_IO.Use_Error =>
|
230 |
|
|
Report.Not_Applicable
|
231 |
|
|
( "Reset to In_File not supported - Text_IO" );
|
232 |
|
|
raise Incomplete;
|
233 |
|
|
end Reset2;
|
234 |
|
|
|
235 |
|
|
Ada.Text_IO.Get_Line (An_Unbounded_File,
|
236 |
|
|
File_Data,
|
237 |
|
|
TC_Width);
|
238 |
|
|
|
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.
|
245 |
|
|
|
246 |
|
|
if (File_Data (File_Data'First) /= 'O') or
|
247 |
|
|
(File_Data (20) /= '1') then
|
248 |
|
|
Report.Failed ("Data placed incorrectly in file");
|
249 |
|
|
end if;
|
250 |
|
|
|
251 |
|
|
exception
|
252 |
|
|
when Incomplete =>
|
253 |
|
|
raise;
|
254 |
|
|
when others =>
|
255 |
|
|
Report.Failed ("Error raised during data verification");
|
256 |
|
|
end Test_Verification_Block;
|
257 |
|
|
|
258 |
|
|
exception
|
259 |
|
|
when Incomplete =>
|
260 |
|
|
raise;
|
261 |
|
|
when others =>
|
262 |
|
|
Report.Failed ("Exception in Text_IO processing");
|
263 |
|
|
end Operational_Test_Block;
|
264 |
|
|
|
265 |
|
|
Final_Block:
|
266 |
|
|
begin
|
267 |
|
|
-- Delete the external file.
|
268 |
|
|
if Ada.Text_IO.Is_Open(An_Unbounded_File) then
|
269 |
|
|
Ada.Text_IO.Delete (An_Unbounded_File);
|
270 |
|
|
else
|
271 |
|
|
Ada.Text_IO.Open(An_Unbounded_File,
|
272 |
|
|
Ada.Text_IO.In_File,
|
273 |
|
|
Unbounded_File_Name);
|
274 |
|
|
Ada.Text_IO.Delete (An_Unbounded_File);
|
275 |
|
|
end if;
|
276 |
|
|
exception
|
277 |
|
|
when others =>
|
278 |
|
|
Report.Failed
|
279 |
|
|
( "Delete not properly implemented -- Text_IO" );
|
280 |
|
|
end Final_Block;
|
281 |
|
|
|
282 |
|
|
Report.Result;
|
283 |
|
|
|
284 |
|
|
exception
|
285 |
|
|
|
286 |
|
|
when Incomplete =>
|
287 |
|
|
Report.Result;
|
288 |
|
|
when others =>
|
289 |
|
|
Report.Failed ( "Unexpected exception" );
|
290 |
|
|
Report.Result;
|
291 |
|
|
|
292 |
|
|
end CXAA005;
|