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 created with mode
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
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
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.
50 -- APPLICABILITY CRITERIA:
51 -- This test is applicable only to implementations that support text
56 -- 06 Dec 94 SAIC ACVC 2.0
57 -- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
66 Data_File
: Text_IO
.File_Type
;
67 Data_Filename
: constant String :=
68 Report
.Legal_File_Name
( Nam
=> "CXAA002" );
69 Incomplete
: exception;
72 Report
.Test
("CXAA002", "Check that page, line, and column formatting " &
73 "subprograms perform properly on text files " &
74 "created with mode Append_File");
76 Test_for_Text_IO_Support
:
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.
86 Text_IO
.Create
(File
=> Data_File
,
87 Mode
=> Text_IO
.Append_File
,
88 Name
=> Data_Filename
);
92 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
94 ( "Files not supported - Create as Append_File for Text_IO" );
97 end Test_for_Text_IO_Support
;
99 Operational_Test_Block
:
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";
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.
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");
117 if Text_IO
.Line
(Data_File
) /= Default_Position
then
118 Report
.Failed
("Incorrect default line number");
120 if "/="(Text_IO
.Col
(Data_File
), Default_Position
) then
121 Report
.Failed
("Incorrect default column number");
124 -- Simulated usage code.
125 -- Set new page/line positions.
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);
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");
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.
141 Text_IO
.Set_Line
(File
=> Data_File
, To
=> 5); -- Set new
142 Text_IO
.Set_Col
(File
=> Data_File
, To
=> 8); -- position.
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");
150 -- Simulated usage code. -- Position
151 Text_IO
.Put_Line
(Data_File
, Appendix_Content
); -- content of
153 end Position_Appendix_Text
;
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.
165 -- Note: The text file has been originally created in Append_File
166 -- mode, and has not been closed prior to this processing.
168 Position_Appendix_Text
;
170 Test_Verification_Block
:
174 TC_Column
: Text_IO
.Positive_Count
;
175 TC_Position
: Natural := 0;
176 Blanks
: constant String := " ";
177 TC_String
: String (1 .. 17) := Blanks
;
182 Text_IO
.Reset
(Data_File
, Text_IO
.In_File
);
184 when Text_IO
.Use_Error
=>
185 Report
.Not_Applicable
186 ( "Reset to In_File not supported for Text_IO" );
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
);
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");
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
);
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");
219 Report
.Failed
("Error raised during data verification");
221 end Test_Verification_Block
;
229 Report
.Failed
("Exception raised during Text_IO processing");
231 end Operational_Test_Block
;
235 -- Delete the external file.
236 if Text_IO
.Is_Open
(Data_File
) then
237 Text_IO
.Delete
(Data_File
);
239 Text_IO
.Open
(Data_File
, Text_IO
.In_File
, Data_Filename
);
240 Text_IO
.Delete
(Data_File
);
245 ( "Delete not properly implemented for Text_IO" );
254 Report
.Failed
( "Unexpected exception" );