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 procedures New_Page, Set_Line, Set_Col, and New_Line
28 -- subprograms perform properly on a text file reset (from Out_File)
29 -- with mode Append_File.
30 -- Check that the attributes Page, Line, and Column are all set to 1
31 -- following the reset of a text file with mode Append_File.
32 -- Check that the functions Page, Line, and Col perform properly on a
33 -- text file reset with mode Append_File.
34 -- Check that the procedures Put and Put_Line perform properly on text
35 -- files reset 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 reset with
38 -- mode Append_File. Check that Set_Line has no effect if the specified
39 -- line equals the current line.
40 -- Check that the procedure Set_Col sets the current column number to
41 -- the value specified by the parameter "To" for text files reset with
45 -- This test is designed to simulate the text processing that could
46 -- occur with files that have been created in Out_File mode,
47 -- and then reset to Append_File mode.
48 -- Various calls to Text_IO formatting subprograms are called to properly
49 -- position text appended to a document. The text content and position
50 -- are subsequently verified for accuracy.
52 -- APPLICABILITY CRITERIA:
53 -- This test is applicable only to implementations that support text
58 -- 06 Dec 94 SAIC ACVC 2.0
59 -- 24 Feb 97 PWB.CTA Allowed for non-support of some IO operations.
67 Data_File
: Text_IO
.File_Type
;
68 Data_Filename
: constant String :=
69 Report
.Legal_File_Name
( Nam
=> "CXAA003" );
70 Incomplete
: exception;
74 Report
.Test
("CXAA003", "Check that page, line, and column formatting " &
75 "subprograms perform properly on text files " &
76 "reset with mode Append_File");
78 Test_for_Text_IO_Support
:
81 -- An implementation that does not support Text_IO in a particular
82 -- environment will raise Use_Error on calls to various
83 -- Text_IO operations. This block statement encloses a call to
84 -- Create, which should raise the exception in a non-supportive
85 -- environment. This exception will be handled to produce a
86 -- Not_Applicable result.
88 Text_IO
.Create
(File
=> Data_File
,
89 Mode
=> Text_IO
.Out_File
,
90 Name
=> Data_Filename
);
92 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
94 ( "Text files not supported - Create as Out_File" );
96 end Test_for_Text_IO_Support
;
98 Operational_Test_Block
:
101 Default_Position
: constant Text_IO
.Positive_Count
:= 1;
103 Section_Header
: constant String := "IX. ";
104 Glossary_Title
: constant String := "GLOSSARY";
105 Glossary_Content
: constant String := "TBD";
107 -- The following procedure simulates the addition of a Glossary page
108 -- to an existing text file that has been reset with mode
111 procedure Position_Glossary_Text
112 (The_File
: in out Text_IO
.File_Type
) is
113 use Text_IO
; -- To provide visibility to the "/=" operator.
116 -- Test control code.
117 -- Verify initial page value.
118 if (Text_IO
.Page
(The_File
) /= Default_Position
) then
119 Report
.Failed
("Incorrect default page number");
121 -- Verify initial line number.
122 if (Text_IO
.Line
(The_File
) /= Default_Position
) then
123 Report
.Failed
("Incorrect default line number");
125 -- Verify initial column number.
126 if (Text_IO
.Col
(The_File
) /= Default_Position
) then
127 Report
.Failed
("Incorrect default column number");
129 -- Simulated usage code. Set new page/line positions.
130 Text_IO
.New_Page
(The_File
);
131 Text_IO
.New_Page
(The_File
);
132 Text_IO
.New_Line
(File
=> The_File
, Spacing
=> 1);
134 -- Test control code.
135 if (Integer(Text_IO
.Page
(The_File
)) /=
136 Report
.Ident_Int
(3)) or else
137 (Integer(Text_IO
.Line
(The_File
)) /=
138 Report
.Ident_Int
(2)) then
139 Report
.Failed
("Incorrect results from page/line positioning");
142 -- Simulated usage code. Position title of Glossary.
143 Text_IO
.Put
(The_File
, Section_Header
);
144 Text_IO
.Put_Line
(The_File
, Glossary_Title
);
145 -- Set line to the current line.
146 Text_IO
.Set_Line
(File
=> The_File
, To
=> 3);
148 -- Test control code.
149 if (Integer(Text_IO
.Page
(The_File
)) /= Report
.Ident_Int
(3)) or
150 (Integer(Text_IO
.Line
(The_File
)) /= Report
.Ident_Int
(3)) or
151 (Integer(Text_IO
.Col
(The_File
)) /= Report
.Ident_Int
(1)) then
152 Report
.Failed
("Set_Line failed for current line");
155 -- Simulated usage code.
156 Text_IO
.Set_Line
(File
=> The_File
, To
=> 4); -- Set new
157 Text_IO
.Set_Col
(File
=> The_File
, To
=> 10); -- position.
159 -- Test control code.
160 if (Integer(Text_IO
.Line
(The_File
)) /= Report
.Ident_Int
(4)) or
161 (Integer(Text_IO
.Col
(The_File
)) /= Report
.Ident_Int
(10)) then
163 ("Incorrect results from line/column positioning");
166 -- Simulated usage code. -- Position
167 Text_IO
.Put_Line
(The_File
, Glossary_Content
); -- content of
169 end Position_Glossary_Text
;
174 -- In the scenario, data is added to the file here.
175 Text_IO
.Put_Line
(File
=> Data_File
, Item
=> "Some optional data");
177 -- This code section simulates a scenario that could occur in a
178 -- text processing environment. Text is to be appended to an
179 -- existing document:
180 -- The file is reset to append mode.
181 -- A procedure is called to perform the positioning and placement
183 -- The position on the appended page is set, verified, and text is
184 -- placed in the file.
186 -- Note: The text file has been originally created in Out_File
187 -- mode, and has subsequently been reset to Append_File mode.
191 -- Reset has effect of calling New_Page.
192 Text_IO
.Reset
(Data_File
, Text_IO
.Append_File
);
194 when Text_IO
.Use_Error
=>
195 Report
.Not_Applicable
196 ( "Reset to Append_File not supported for Text_IO" );
200 Position_Glossary_Text
(The_File
=> Data_File
);
202 Test_Verification_Block
:
204 TC_Page
, TC_Line
, TC_Column
: Text_IO
.Positive_Count
;
205 TC_Position
: Natural := 0;
206 Blanks
: constant String :=
208 TC_String
: String (1 .. 15) := Blanks
;
212 Text_IO
.Reset
(Data_File
, Text_IO
.In_File
);
214 when Text_IO
.Use_Error
=>
215 Report
.Not_Applicable
216 ( "Reset to In_File not supported for Text_IO" );
220 Text_IO
.Skip_Page
(Data_File
);
221 Text_IO
.Skip_Page
(Data_File
);
223 -- If the Reset to Append_File mode actually put a page terminator
224 -- on the file, as allowed (but not required) by RM A.10.2(4), then
225 -- we are now on page 3, an empty page. We'll need to skip one more.
227 if Text_IO
.End_Of_Page
(Data_File
) then
228 Text_IO
.Skip_Page
(Data_File
);
231 -- Now we're on the Glossary page.
233 -- Loop to the second line
234 for I
in 1 .. 2 loop -- and read the contents.
235 Text_IO
.Get_Line
(Data_File
, TC_String
, TC_Position
);
237 if (TC_Position
/= 13) or else -- Verify the title line.
238 (TC_String
(1..2) /= "IX") or else
239 (TC_String
(3..13) /= (". " & Glossary_Title
)) then
240 Report
.Failed
("Incorrect positioning of title line");
243 TC_String
:= Blanks
; -- Clear string.
244 -- Loop to the fourth line
245 for I
in 3 .. 4 loop -- and read the contents.
246 Text_IO
.Get_Line
(Data_File
, TC_String
, TC_Position
);
249 if (TC_Position
/= 12) or -- Verify the contents.
250 (TC_String
(8..12) /= " " & Glossary_Content
) then
251 Report
.Failed
("Incorrect positioning of contents line");
258 Report
.Failed
("Error raised during data verification");
260 end Test_Verification_Block
;
266 Report
.Failed
("Exception raised during Text_IO processing");
268 end Operational_Test_Block
;
272 -- Delete the external file.
273 if Text_IO
.Is_Open
(Data_File
) then
274 Text_IO
.Delete
(Data_File
);
276 Text_IO
.Open
(Data_File
, Text_IO
.In_File
, Data_Filename
);
277 Text_IO
.Delete
(Data_File
);
281 Report
.Failed
( "Delete not properly implemented for Text_IO" );
290 Report
.Failed
( "Unexpected exception" );