1 |
294 |
jeremybenn |
-- CXAA002.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 procedures New_Page, Set_Line, Set_Col, and New_Line
|
28 |
|
|
-- subprograms perform properly on a text file created with mode
|
29 |
|
|
-- Append_File.
|
30 |
|
|
-- Check that the attributes Page, Line, and Column are all set to 1
|
31 |
|
|
-- following the creation of a text file with mode Append_File.
|
32 |
|
|
-- Check that the functions Page, Line, and Col perform properly on a
|
33 |
|
|
-- text file created with mode Append_File.
|
34 |
|
|
-- Check that the procedures Put and Put_Line perform properly on text
|
35 |
|
|
-- files created with mode Append_File.
|
36 |
|
|
-- Check that the procedure Set_Line sets the current line number to
|
37 |
|
|
-- the value specified by the parameter "To" for text files created with
|
38 |
|
|
-- mode Append_File.
|
39 |
|
|
-- Check that the procedure Set_Col sets the current column number to
|
40 |
|
|
-- the value specified by the parameter "To" for text files created with
|
41 |
|
|
-- mode Append_File.
|
42 |
|
|
--
|
43 |
|
|
-- TEST DESCRIPTION:
|
44 |
|
|
-- This test is designed to simulate the text processing that could
|
45 |
|
|
-- occur with files that have been created in Append_File mode. Various
|
46 |
|
|
-- calls to Text_IO formatting subprograms are called to properly
|
47 |
|
|
-- position text appended to a document. The text content and position
|
48 |
|
|
-- are subsequently verified for accuracy.
|
49 |
|
|
--
|
50 |
|
|
-- APPLICABILITY CRITERIA:
|
51 |
|
|
-- This test is applicable only to implementations that support text
|
52 |
|
|
-- files.
|
53 |
|
|
--
|
54 |
|
|
--
|
55 |
|
|
-- CHANGE HISTORY:
|
56 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
57 |
|
|
-- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
58 |
|
|
|
59 |
|
|
--!
|
60 |
|
|
|
61 |
|
|
with Ada.Text_IO;
|
62 |
|
|
with Report;
|
63 |
|
|
|
64 |
|
|
procedure CXAA002 is
|
65 |
|
|
use Ada;
|
66 |
|
|
Data_File : Text_IO.File_Type;
|
67 |
|
|
Data_Filename : constant String :=
|
68 |
|
|
Report.Legal_File_Name ( Nam => "CXAA002" );
|
69 |
|
|
Incomplete : exception;
|
70 |
|
|
begin
|
71 |
|
|
|
72 |
|
|
Report.Test ("CXAA002", "Check that page, line, and column formatting " &
|
73 |
|
|
"subprograms perform properly on text files " &
|
74 |
|
|
"created with mode Append_File");
|
75 |
|
|
|
76 |
|
|
Test_for_Text_IO_Support:
|
77 |
|
|
begin
|
78 |
|
|
|
79 |
|
|
-- An implementation that does not support Text_IO in a particular
|
80 |
|
|
-- environment will raise Use_Error on calls to various
|
81 |
|
|
-- Text_IO operations. This block statement encloses a call to
|
82 |
|
|
-- Create, which should raise the exception in a non-supportive
|
83 |
|
|
-- environment. This exception will be handled to produce a
|
84 |
|
|
-- Not_Applicable result.
|
85 |
|
|
|
86 |
|
|
Text_IO.Create (File => Data_File,
|
87 |
|
|
Mode => Text_IO.Append_File,
|
88 |
|
|
Name => Data_Filename);
|
89 |
|
|
|
90 |
|
|
exception
|
91 |
|
|
|
92 |
|
|
when Text_IO.Use_Error | Text_IO.Name_Error =>
|
93 |
|
|
Report.Not_Applicable
|
94 |
|
|
( "Files not supported - Create as Append_File for Text_IO" );
|
95 |
|
|
raise Incomplete;
|
96 |
|
|
|
97 |
|
|
end Test_for_Text_IO_Support;
|
98 |
|
|
|
99 |
|
|
Operational_Test_Block:
|
100 |
|
|
declare
|
101 |
|
|
Default_Position : constant Text_IO.Positive_Count := 1;
|
102 |
|
|
Section_Header : constant String := "VII. ";
|
103 |
|
|
Appendix_Title : constant String := "Appendix A";
|
104 |
|
|
Appendix_Content : constant String := "TBD";
|
105 |
|
|
|
106 |
|
|
-- The following procedure simulates the addition of an Appendix page
|
107 |
|
|
-- to an existing text file.
|
108 |
|
|
procedure Position_Appendix_Text is
|
109 |
|
|
use Text_IO; -- To provide visibility to the "/=" operator.
|
110 |
|
|
begin
|
111 |
|
|
|
112 |
|
|
-- Test control code.
|
113 |
|
|
-- Verify initial page, line, column number.
|
114 |
|
|
if "/="(Text_IO.Page (Data_File), Default_Position) then
|
115 |
|
|
Report.Failed ("Incorrect default page number");
|
116 |
|
|
end if;
|
117 |
|
|
if Text_IO.Line (Data_File) /= Default_Position then
|
118 |
|
|
Report.Failed ("Incorrect default line number");
|
119 |
|
|
end if;
|
120 |
|
|
if "/="(Text_IO.Col (Data_File), Default_Position) then
|
121 |
|
|
Report.Failed ("Incorrect default column number");
|
122 |
|
|
end if;
|
123 |
|
|
|
124 |
|
|
-- Simulated usage code.
|
125 |
|
|
-- Set new page/line positions.
|
126 |
|
|
Text_IO.Put_Line
|
127 |
|
|
(Data_File, "Add some optional data to the file here");
|
128 |
|
|
Text_IO.New_Page (Data_File);
|
129 |
|
|
Text_IO.New_Line (File => Data_File, Spacing => 2);
|
130 |
|
|
|
131 |
|
|
-- Test control code.
|
132 |
|
|
if Integer(Text_IO.Page (Data_File)) /= Report.Ident_Int(2) or else
|
133 |
|
|
Integer(Text_IO.Line (Data_File)) /= Report.Ident_Int(3) then
|
134 |
|
|
Report.Failed ("Incorrect results from page/line positioning");
|
135 |
|
|
end if;
|
136 |
|
|
|
137 |
|
|
-- Simulated usage code.
|
138 |
|
|
Text_IO.Put (Data_File, Section_Header); -- Position title
|
139 |
|
|
Text_IO.Put_Line (Data_File, Appendix_Title); -- of Appendix.
|
140 |
|
|
|
141 |
|
|
Text_IO.Set_Line (File => Data_File, To => 5); -- Set new
|
142 |
|
|
Text_IO.Set_Col (File => Data_File, To => 8); -- position.
|
143 |
|
|
|
144 |
|
|
-- Test control code.
|
145 |
|
|
if (Integer(Text_IO.Line (Data_File)) /= Report.Ident_Int(5)) or
|
146 |
|
|
(Integer(Text_IO.Col (Data_File)) /= Report.Ident_Int(8)) then
|
147 |
|
|
Report.Failed ("Incorrect results from line/column positioning");
|
148 |
|
|
end if;
|
149 |
|
|
|
150 |
|
|
-- Simulated usage code. -- Position
|
151 |
|
|
Text_IO.Put_Line (Data_File, Appendix_Content); -- content of
|
152 |
|
|
-- Appendix.
|
153 |
|
|
end Position_Appendix_Text;
|
154 |
|
|
|
155 |
|
|
begin
|
156 |
|
|
|
157 |
|
|
-- This code section simulates a scenario that could occur in a
|
158 |
|
|
-- text processing environment:
|
159 |
|
|
-- A document is created/modified/edited Then...
|
160 |
|
|
-- Text is to be appended to the document.
|
161 |
|
|
-- A procedure is called to perform that operation.
|
162 |
|
|
-- The position on the appended page is set, verified, and text is
|
163 |
|
|
-- appended to the existing file.
|
164 |
|
|
--
|
165 |
|
|
-- Note: The text file has been originally created in Append_File
|
166 |
|
|
-- mode, and has not been closed prior to this processing.
|
167 |
|
|
|
168 |
|
|
Position_Appendix_Text;
|
169 |
|
|
|
170 |
|
|
Test_Verification_Block:
|
171 |
|
|
declare
|
172 |
|
|
TC_Page,
|
173 |
|
|
TC_Line,
|
174 |
|
|
TC_Column : Text_IO.Positive_Count;
|
175 |
|
|
TC_Position : Natural := 0;
|
176 |
|
|
Blanks : constant String := " ";
|
177 |
|
|
TC_String : String (1 .. 17) := Blanks;
|
178 |
|
|
begin
|
179 |
|
|
|
180 |
|
|
Reset1:
|
181 |
|
|
begin
|
182 |
|
|
Text_IO.Reset (Data_File, Text_IO.In_File);
|
183 |
|
|
exception
|
184 |
|
|
when Text_IO.Use_Error =>
|
185 |
|
|
Report.Not_Applicable
|
186 |
|
|
( "Reset to In_File not supported for Text_IO" );
|
187 |
|
|
raise Incomplete;
|
188 |
|
|
end Reset1;
|
189 |
|
|
|
190 |
|
|
Text_IO.Skip_Page (Data_File);
|
191 |
|
|
-- Loop to the third line
|
192 |
|
|
for I in 1 .. 3 loop -- and read the contents.
|
193 |
|
|
Text_IO.Get_Line (Data_File, TC_String, TC_Position);
|
194 |
|
|
end loop;
|
195 |
|
|
|
196 |
|
|
if (TC_Position /= 16) or else -- Verify the title line.
|
197 |
|
|
(TC_String (1..4) /= "VII.") or else
|
198 |
|
|
(TC_String (3..16) /= ("I. " & Appendix_Title)) then
|
199 |
|
|
Report.Failed ("Incorrect positioning of title line");
|
200 |
|
|
end if;
|
201 |
|
|
|
202 |
|
|
TC_String := Blanks; -- Clear string.
|
203 |
|
|
-- Loop to the fifth line
|
204 |
|
|
for I in 4 .. 5 loop -- and read the contents.
|
205 |
|
|
Text_IO.Get_Line (Data_File, TC_String, TC_Position);
|
206 |
|
|
end loop;
|
207 |
|
|
|
208 |
|
|
if (TC_Position /= 10) or -- Verify the contents.
|
209 |
|
|
(TC_String (8..10) /= Appendix_Content) then
|
210 |
|
|
Report.Failed ("Incorrect positioning of contents line");
|
211 |
|
|
end if;
|
212 |
|
|
|
213 |
|
|
exception
|
214 |
|
|
|
215 |
|
|
when Incomplete =>
|
216 |
|
|
raise;
|
217 |
|
|
|
218 |
|
|
when others =>
|
219 |
|
|
Report.Failed ("Error raised during data verification");
|
220 |
|
|
|
221 |
|
|
end Test_Verification_Block;
|
222 |
|
|
|
223 |
|
|
exception
|
224 |
|
|
|
225 |
|
|
when Incomplete =>
|
226 |
|
|
raise;
|
227 |
|
|
|
228 |
|
|
when others =>
|
229 |
|
|
Report.Failed ("Exception raised during Text_IO processing");
|
230 |
|
|
|
231 |
|
|
end Operational_Test_Block;
|
232 |
|
|
|
233 |
|
|
Deletion:
|
234 |
|
|
begin
|
235 |
|
|
-- Delete the external file.
|
236 |
|
|
if Text_IO.Is_Open(Data_File) then
|
237 |
|
|
Text_IO.Delete(Data_File);
|
238 |
|
|
else
|
239 |
|
|
Text_IO.Open(Data_File, Text_IO.In_File, Data_Filename);
|
240 |
|
|
Text_IO.Delete(Data_File);
|
241 |
|
|
end if;
|
242 |
|
|
exception
|
243 |
|
|
when others =>
|
244 |
|
|
Report.Failed
|
245 |
|
|
( "Delete not properly implemented for Text_IO" );
|
246 |
|
|
end Deletion;
|
247 |
|
|
|
248 |
|
|
Report.Result;
|
249 |
|
|
|
250 |
|
|
exception
|
251 |
|
|
when Incomplete =>
|
252 |
|
|
Report.Result;
|
253 |
|
|
when others =>
|
254 |
|
|
Report.Failed ( "Unexpected exception" );
|
255 |
|
|
Report.Result;
|
256 |
|
|
|
257 |
|
|
end CXAA002;
|