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 capabilities provided in instantiations of the
28 -- Ada.Text_IO.Fixed_IO package operate correctly when the mode of
29 -- the file is Append_File. Check that Fixed_IO procedures Put and Get
30 -- properly transfer fixed point data to/from data files that are in
31 -- Append_File mode. Check that the formatting parameters available in
32 -- the package can be used and modified successfully in the appending and
36 -- This test simulates order processing, with data values being written
37 -- to a file, in a specific format, using Fixed_IO. Validation is done
38 -- on this process by reading the data values from the file, and
39 -- comparing them for equality with the values originally written to
42 -- This test verifies issues of create in Append_File mode, appending to
43 -- a file previously appended to, resetting to Append_File mode,
44 -- resetting from Append_File mode to In_File mode, as well as a
45 -- variety of Text_IO and Fixed_IO predefined subprograms.
47 -- APPLICABILITY CRITERIA:
48 -- This test is applicable only to implementations that support text
53 -- 06 Dec 94 SAIC ACVC 2.0
54 -- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
63 Inventory_File
: Text_IO
.File_Type
;
64 Inventory_Filename
: constant String :=
65 Report
.Legal_File_Name
( Nam
=> "CXAA008" );
66 Incomplete
: exception;
70 Report
.Test
("CXAA008", "Check that the capabilities of " &
71 "Text_IO.Fixed_IO operate correctly for files " &
72 "with mode Append_File");
74 Test_for_Text_IO_Support
:
77 -- An implementation that does not support Text_IO in a particular
78 -- environment will raise Use_Error on calls to various
79 -- Text_IO operations. This block statement encloses a call to
80 -- Create, which should raise the exception in a non-supportive
81 -- environment. This exception will be handled to produce a
82 -- Not_Applicable result.
84 Text_IO
.Create
(File
=> Inventory_File
,
85 Mode
=> Text_IO
.Append_File
,
86 Name
=> Inventory_Filename
);
89 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
91 ( "Files not supported - Create with Append_File for Text_IO" );
93 end Test_For_Text_IO_Support
;
95 Operational_Test_Block
:
98 Daily_Orders_Received
: constant Natural := 4;
100 type Item_Type
is delta 0.1 range 0.0 .. 5000.0;
101 type Cost_Type
is delta 0.01 range 0.0 .. 10_000
.0
;
102 type Profit_Type
is delta 0.01 range -100.0 .. 1000.0;
104 type Product_Type
is record
105 Item_Number
: Item_Type
:= 0.0;
106 Unit_Cost
: Cost_Type
:= 0.00;
107 Percent_Markup
: Profit_Type
:= 0.00;
110 type Inventory_Type
is
111 array (1 .. Daily_Orders_Received
) of Product_Type
;
113 Daily_Inventory
: Inventory_Type
:= (( 1.0, 1.75, 50.00),
114 ( 155.0, 20.00, -5.50),
115 (3343.5, 2.50, 126.50),
116 (4986.0, 180.00, 31.75));
118 package Item_IO
is new Text_IO
.Fixed_IO
(Item_Type
);
119 package Cost_IO
is new Text_IO
.Fixed_IO
(Cost_Type
);
120 package Markup_IO
is new Text_IO
.Fixed_IO
(Profit_Type
);
123 function TC_Mode_Selection
(Selector
: Integer)
124 return Text_IO
.File_Mode
is
127 when 1 => return Text_IO
.In_File
;
128 when 2 => return Text_IO
.Out_File
;
129 when others => return Text_IO
.Append_File
;
131 end TC_Mode_Selection
;
134 -- The following function simulates the addition of inventory item
135 -- information into a data file. Boolean status of True is returned
136 -- if all of the data entry was successful, False otherwise.
138 function Update_Inventory
(The_List
: Inventory_Type
)
141 for I
in 1 .. Daily_Orders_Received
loop
142 Item_IO
.Put
(Inventory_File
, The_List
(I
).Item_Number
);
143 Cost_IO
.Put
(Inventory_File
, The_List
(I
).Unit_Cost
, 10, 4, 0);
144 Markup_IO
.Put
(File
=> Inventory_File
,
145 Item
=> The_List
(I
).Percent_Markup
,
149 Text_IO
.New_Line
(Inventory_File
);
151 return (True); -- Return a Status value.
153 when others => return False;
154 end Update_Inventory
;
159 -- This code section simulates a receiving department maintaining a
160 -- data file containing information on items that have been ordered
163 -- Whenever items are received, the file is reset to Append_File
164 -- mode. Data is taken from an inventory list and entered into the
165 -- file, in specific format.
169 Text_IO
.Reset
(Inventory_File
, -- Append mode.
170 TC_Mode_Selection
(Report
.Ident_Int
(3)));
172 when Text_IO
.Use_Error
=>
173 Report
.Not_Applicable
174 ( "Reset to Append_File not supported for Text_IO" );
178 if not Update_Inventory
(The_List
=> Daily_Inventory
) then
179 Report
.Failed
("Exception occurred during inventory update");
183 Test_Verification_Block
:
187 TC_Markup
: Profit_Type
;
188 TC_Item_Count
: Natural := 0;
193 Text_IO
.Reset
(Inventory_File
, Text_IO
.In_File
); -- Reset for
196 when Text_IO
.Use_Error
=>
197 Report
.Not_Applicable
198 ( "Reset to In_File not supported for Text_IO" );
202 while not Text_IO
.End_Of_File
(Inventory_File
) loop
203 Item_IO
.Get
(Inventory_File
, TC_Item
);
204 Cost_IO
.Get
(Inventory_File
, TC_Cost
);
205 Markup_IO
.Get
(File
=> Inventory_File
,
208 Text_IO
.Skip_Line
(Inventory_File
);
209 TC_Item_Count
:= TC_Item_Count
+ 1;
211 -- Verify all of the data fields read from the file. Compare
212 -- with the values that were originally entered into the file.
214 if (TC_Item
/= Daily_Inventory
(TC_Item_Count
).Item_Number
) then
215 Report
.Failed
("Error in Item_Number read from file");
217 if (TC_Cost
/= Daily_Inventory
(TC_Item_Count
).Unit_Cost
) then
218 Report
.Failed
("Error in Unit_Cost read from file");
221 Daily_Inventory
(TC_Item_Count
).Percent_Markup
) then
222 Report
.Failed
("Error in Percent_Markup read from file");
227 if (TC_Item_Count
/= Daily_Orders_Received
) then
228 Report
.Failed
("Incorrect number of records read from file");
235 Report
.Failed
("Error raised during data verification");
236 end Test_Verification_Block
;
242 Report
.Failed
("Exception in Text_IO.Fixed_IO processing");
243 end Operational_Test_Block
;
247 -- Delete the external file.
248 if Text_IO
.Is_Open
(Inventory_File
) then
249 Text_IO
.Delete
(Inventory_File
);
251 Text_IO
.Open
(Inventory_File
, Text_IO
.In_File
, Inventory_Filename
);
252 Text_IO
.Delete
(Inventory_File
);
258 Report
.Failed
( "Delete not properly implemented for Text_IO" );
268 Report
.Failed
( "Unexpected exception" );