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.Float_IO package operate correctly when the mode of
29 -- the file is Append_File. Check that Float_IO procedures Put and Get
30 -- properly transfer floating 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 is designed to simulate an environment where a data file
37 -- that holds floating point information is created, written to, and
38 -- closed. In the future, the file can be reopened in Append_File mode,
39 -- additional data can be appended to it, and then closed. This process
40 -- of Open/Append/Close can be repeated as necessary. All data written
41 -- to the file is verified for accuracy when retrieved from the file.
43 -- This test verifies issues of create in Append_File mode, appending to
44 -- a file previously appended to, opening in Append_File mode, resetting
45 -- from Append_File mode to In_File mode, as well as a variety of Text_IO
46 -- and Float_IO predefined subprograms.
48 -- APPLICABILITY CRITERIA:
49 -- This test is applicable only to implementations that support text
54 -- 06 Dec 94 SAIC ACVC 2.0
55 -- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
64 Loan_File
: Text_IO
.File_Type
;
65 Loan_Filename
: constant String :=
66 Report
.Legal_File_Name
( Nam
=> "CXAA009" );
67 Incomplete
: exception;
71 Report
.Test
("CXAA009", "Check that the capabilities of " &
72 "Text_IO.Float_IO operate correctly for files " &
73 "with mode Append_File");
75 Test_for_Text_IO_Support
:
78 -- An implementation that does not support Text_IO in a particular
79 -- environment will raise Use_Error on calls to various
80 -- Text_IO operations. This block statement encloses a call to
81 -- Create, which should raise the exception in a non-supportive
82 -- environment. This exception will be handled to produce a
83 -- Not_Applicable result.
85 Text_IO
.Create
(File
=> Loan_File
, -- Create in
86 Mode
=> Text_IO
.Out_File
, -- Out_File mode.
87 Name
=> Loan_Filename
);
91 when Text_IO
.Use_Error | Text_IO
.Name_Error
=>
93 ( "Files not supported - Create as Out_File for Text_IO" );
96 end Test_for_Text_IO_Support
;
98 Operational_Test_Block
:
100 Total_Loans_Outstanding
: constant Natural := 3;
101 Transaction_Status
: Boolean := False;
103 type Account_Balance_Type
is digits 6 range 0.0 .. 1.0E6
;
104 type Loan_Balance_Type
is digits 6;
105 type Interest_Rate_Type
is digits 4 range 0.0 .. 30.00;
107 type Loan_Info_Type
is record
108 Account_Balance
: Account_Balance_Type
:= 0.00;
109 Loan_Balance
: Loan_Balance_Type
:= 0.00;
110 Loan_Interest_Rate
: Interest_Rate_Type
:= 0.00;
113 Home_Refinance_Loan
: Loan_Info_Type
:=
114 (14_500
.00
, 135_000
.00
, 6.875);
115 Line_Of_Credit_Loan
: Loan_Info_Type
:=
116 ( 5490.00, -3000.00, 13.75);
117 Small_Business_Loan
: Loan_Info_Type
:=
118 (Account_Balance
=> 45_000
.00
,
119 Loan_Balance
=> 10_500
.00
,
120 Loan_Interest_Rate
=> 5.875);
122 package Acct_IO
is new Text_IO
.Float_IO
(Account_Balance_Type
);
123 package Loan_IO
is new Text_IO
.Float_IO
(Loan_Balance_Type
);
124 package Rate_IO
is new Text_IO
.Float_IO
(Interest_Rate_Type
);
127 -- The following procedure performs the addition of loan information
128 -- into a data file. Boolean status of True is returned if all of
129 -- the data entry was successful, False otherwise.
130 -- This demonstrates use of Float_IO using a variety of data formats.
132 procedure Update_Loan_Info
(The_File
: in out Text_IO
.File_Type
;
133 The_Loan
: in Loan_Info_Type
;
134 Status
: out Boolean ) is
136 Acct_IO
.Put
(The_File
, The_Loan
.Account_Balance
);
137 Loan_IO
.Put
(The_File
, The_Loan
.Loan_Balance
, 15, 2, 0);
138 Rate_IO
.Put
(File
=> The_File
,
139 Item
=> The_Loan
.Loan_Interest_Rate
,
143 Text_IO
.New_Line
(The_File
);
146 when others => Status
:= False;
147 end Update_Loan_Info
;
152 -- This code section simulates a bank maintaining a data file
153 -- containing information on loans that have been made.
155 -- The loan file was created in Out_File mode.
156 -- Some number of data records are added.
157 -- The file is closed.
158 -- The file is subsequently reopened in Append_File mode.
159 -- Data is appended to the file.
160 -- The file is closed.
161 -- Repeat the Open/Append/Close process as required.
162 -- Verify data in the file.
165 Update_Loan_Info
(Loan_File
, Home_Refinance_Loan
, Transaction_Status
);
167 if not Transaction_Status
then
168 Report
.Failed
("Failure in update of first loan data");
171 Text_IO
.Close
(Loan_File
);
173 -- When subsequent data items are to be added to the file, the file
174 -- is opened in Append_File mode.
176 Text_IO
.Open
(Loan_File
, -- Open with
177 Text_IO
.Append_File
, -- Append mode.
180 Update_Loan_Info
(Loan_File
, Line_Of_Credit_Loan
, Transaction_Status
);
182 if not Transaction_Status
then
183 Report
.Failed
("Failure in update of first loan data");
186 Text_IO
.Close
(Loan_File
);
188 -- To add additional data to the file, the file
189 -- is again opened in Append_File mode (appending to a file
190 -- previously appended to).
192 Text_IO
.Open
(Loan_File
, -- Open with
193 Text_IO
.Append_File
, -- Append mode.
196 Update_Loan_Info
(Loan_File
, Small_Business_Loan
, Transaction_Status
);
198 if not Transaction_Status
then
199 Report
.Failed
("Failure in update of first loan data");
202 Test_Verification_Block
:
205 array (1 .. Total_Loans_Outstanding
) of Loan_Info_Type
;
206 TC_Bank_Ledger
: Ledger_Type
;
207 TC_Item_Count
: Natural := 0;
212 Text_IO
.Reset
(Loan_File
, Text_IO
.In_File
); -- Reset for
215 when Text_IO
.Use_Error
=>
216 Report
.Not_Applicable
217 ( "Reset to In_File not supported for Text_IO" );
221 while not Text_IO
.End_Of_File
(Loan_File
) loop
222 TC_Item_Count
:= TC_Item_Count
+ 1;
223 Acct_IO
.Get
(Loan_File
,
224 TC_Bank_Ledger
(TC_Item_Count
).Account_Balance
);
225 Loan_IO
.Get
(Loan_File
,
226 TC_Bank_Ledger
(TC_Item_Count
).Loan_Balance
,
228 Rate_IO
.Get
(File
=> Loan_File
,
230 TC_Bank_Ledger
(TC_Item_Count
).Loan_Interest_Rate
,
232 Text_IO
.Skip_Line
(Loan_File
);
236 -- Verify all of the data fields read from the file. Compare
237 -- with the values that were originally entered into the file.
239 if (TC_Bank_Ledger
(1) /= Home_Refinance_Loan
) or
240 (TC_Bank_Ledger
(2) /= Line_Of_Credit_Loan
) or
241 (TC_Bank_Ledger
(3) /= Small_Business_Loan
) then
242 Report
.Failed
("Error in data read from file");
245 if (TC_Item_Count
/= Total_Loans_Outstanding
) then
246 Report
.Failed
("Incorrect number of records read from file");
253 Report
.Failed
("Error raised during data verification");
254 end Test_Verification_Block
;
260 Report
.Failed
("Exception in Text_IO.Float_IO processing");
261 end Operational_Test_Block
;
265 -- Delete the external file.
266 if Text_IO
.Is_Open
(Loan_File
) then
267 Text_IO
.Delete
(Loan_File
);
269 Text_IO
.Open
(Loan_File
, Text_IO
.In_File
, Loan_Filename
);
270 Text_IO
.Delete
(Loan_File
);
275 when Text_IO
.Use_Error
=>
277 ( "Delete not properly implemented for Text_IO" );
287 Report
.Failed
( "Unexpected exception" );