-- CXAA009.A
|
-- CXAA009.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the capabilities provided in instantiations of the
|
-- Check that the capabilities provided in instantiations of the
|
-- Ada.Text_IO.Float_IO package operate correctly when the mode of
|
-- Ada.Text_IO.Float_IO package operate correctly when the mode of
|
-- the file is Append_File. Check that Float_IO procedures Put and Get
|
-- the file is Append_File. Check that Float_IO procedures Put and Get
|
-- properly transfer floating point data to/from data files that are in
|
-- properly transfer floating point data to/from data files that are in
|
-- Append_File mode. Check that the formatting parameters available in
|
-- Append_File mode. Check that the formatting parameters available in
|
-- the package can be used and modified successfully in the appending and
|
-- the package can be used and modified successfully in the appending and
|
-- retrieval of data.
|
-- retrieval of data.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test is designed to simulate an environment where a data file
|
-- This test is designed to simulate an environment where a data file
|
-- that holds floating point information is created, written to, and
|
-- that holds floating point information is created, written to, and
|
-- closed. In the future, the file can be reopened in Append_File mode,
|
-- closed. In the future, the file can be reopened in Append_File mode,
|
-- additional data can be appended to it, and then closed. This process
|
-- additional data can be appended to it, and then closed. This process
|
-- of Open/Append/Close can be repeated as necessary. All data written
|
-- of Open/Append/Close can be repeated as necessary. All data written
|
-- to the file is verified for accuracy when retrieved from the file.
|
-- to the file is verified for accuracy when retrieved from the file.
|
--
|
--
|
-- This test verifies issues of create in Append_File mode, appending to
|
-- This test verifies issues of create in Append_File mode, appending to
|
-- a file previously appended to, opening in Append_File mode, resetting
|
-- a file previously appended to, opening in Append_File mode, resetting
|
-- from Append_File mode to In_File mode, as well as a variety of Text_IO
|
-- from Append_File mode to In_File mode, as well as a variety of Text_IO
|
-- and Float_IO predefined subprograms.
|
-- and Float_IO predefined subprograms.
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- This test is applicable only to implementations that support text
|
-- This test is applicable only to implementations that support text
|
-- files.
|
-- files.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
-- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
--!
|
--!
|
|
|
with Ada.Text_IO;
|
with Ada.Text_IO;
|
with Report;
|
with Report;
|
|
|
procedure CXAA009 is
|
procedure CXAA009 is
|
|
|
use Ada;
|
use Ada;
|
Loan_File : Text_IO.File_Type;
|
Loan_File : Text_IO.File_Type;
|
Loan_Filename : constant String :=
|
Loan_Filename : constant String :=
|
Report.Legal_File_Name ( Nam => "CXAA009" );
|
Report.Legal_File_Name ( Nam => "CXAA009" );
|
Incomplete : exception;
|
Incomplete : exception;
|
|
|
begin
|
begin
|
|
|
Report.Test ("CXAA009", "Check that the capabilities of " &
|
Report.Test ("CXAA009", "Check that the capabilities of " &
|
"Text_IO.Float_IO operate correctly for files " &
|
"Text_IO.Float_IO operate correctly for files " &
|
"with mode Append_File");
|
"with mode Append_File");
|
|
|
Test_for_Text_IO_Support:
|
Test_for_Text_IO_Support:
|
begin
|
begin
|
|
|
-- An implementation that does not support Text_IO in a particular
|
-- An implementation that does not support Text_IO in a particular
|
-- environment will raise Use_Error on calls to various
|
-- environment will raise Use_Error on calls to various
|
-- Text_IO operations. This block statement encloses a call to
|
-- Text_IO operations. This block statement encloses a call to
|
-- Create, which should raise the exception in a non-supportive
|
-- Create, which should raise the exception in a non-supportive
|
-- environment. This exception will be handled to produce a
|
-- environment. This exception will be handled to produce a
|
-- Not_Applicable result.
|
-- Not_Applicable result.
|
|
|
Text_IO.Create (File => Loan_File, -- Create in
|
Text_IO.Create (File => Loan_File, -- Create in
|
Mode => Text_IO.Out_File, -- Out_File mode.
|
Mode => Text_IO.Out_File, -- Out_File mode.
|
Name => Loan_Filename);
|
Name => Loan_Filename);
|
|
|
exception
|
exception
|
|
|
when Text_IO.Use_Error | Text_IO.Name_Error =>
|
when Text_IO.Use_Error | Text_IO.Name_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Files not supported - Create as Out_File for Text_IO" );
|
( "Files not supported - Create as Out_File for Text_IO" );
|
raise Incomplete;
|
raise Incomplete;
|
|
|
end Test_for_Text_IO_Support;
|
end Test_for_Text_IO_Support;
|
|
|
Operational_Test_Block:
|
Operational_Test_Block:
|
declare
|
declare
|
Total_Loans_Outstanding : constant Natural := 3;
|
Total_Loans_Outstanding : constant Natural := 3;
|
Transaction_Status : Boolean := False;
|
Transaction_Status : Boolean := False;
|
|
|
type Account_Balance_Type is digits 6 range 0.0 .. 1.0E6;
|
type Account_Balance_Type is digits 6 range 0.0 .. 1.0E6;
|
type Loan_Balance_Type is digits 6;
|
type Loan_Balance_Type is digits 6;
|
type Interest_Rate_Type is digits 4 range 0.0 .. 30.00;
|
type Interest_Rate_Type is digits 4 range 0.0 .. 30.00;
|
|
|
type Loan_Info_Type is record
|
type Loan_Info_Type is record
|
Account_Balance : Account_Balance_Type := 0.00;
|
Account_Balance : Account_Balance_Type := 0.00;
|
Loan_Balance : Loan_Balance_Type := 0.00;
|
Loan_Balance : Loan_Balance_Type := 0.00;
|
Loan_Interest_Rate : Interest_Rate_Type := 0.00;
|
Loan_Interest_Rate : Interest_Rate_Type := 0.00;
|
end record;
|
end record;
|
|
|
Home_Refinance_Loan : Loan_Info_Type :=
|
Home_Refinance_Loan : Loan_Info_Type :=
|
(14_500.00, 135_000.00, 6.875);
|
(14_500.00, 135_000.00, 6.875);
|
Line_Of_Credit_Loan : Loan_Info_Type :=
|
Line_Of_Credit_Loan : Loan_Info_Type :=
|
( 5490.00, -3000.00, 13.75);
|
( 5490.00, -3000.00, 13.75);
|
Small_Business_Loan : Loan_Info_Type :=
|
Small_Business_Loan : Loan_Info_Type :=
|
(Account_Balance => 45_000.00,
|
(Account_Balance => 45_000.00,
|
Loan_Balance => 10_500.00,
|
Loan_Balance => 10_500.00,
|
Loan_Interest_Rate => 5.875);
|
Loan_Interest_Rate => 5.875);
|
|
|
package Acct_IO is new Text_IO.Float_IO (Account_Balance_Type);
|
package Acct_IO is new Text_IO.Float_IO (Account_Balance_Type);
|
package Loan_IO is new Text_IO.Float_IO (Loan_Balance_Type);
|
package Loan_IO is new Text_IO.Float_IO (Loan_Balance_Type);
|
package Rate_IO is new Text_IO.Float_IO (Interest_Rate_Type);
|
package Rate_IO is new Text_IO.Float_IO (Interest_Rate_Type);
|
|
|
|
|
-- The following procedure performs the addition of loan information
|
-- The following procedure performs the addition of loan information
|
-- into a data file. Boolean status of True is returned if all of
|
-- into a data file. Boolean status of True is returned if all of
|
-- the data entry was successful, False otherwise.
|
-- the data entry was successful, False otherwise.
|
-- This demonstrates use of Float_IO using a variety of data formats.
|
-- This demonstrates use of Float_IO using a variety of data formats.
|
|
|
procedure Update_Loan_Info (The_File : in out Text_IO.File_Type;
|
procedure Update_Loan_Info (The_File : in out Text_IO.File_Type;
|
The_Loan : in Loan_Info_Type;
|
The_Loan : in Loan_Info_Type;
|
Status : out Boolean ) is
|
Status : out Boolean ) is
|
begin
|
begin
|
Acct_IO.Put (The_File, The_Loan.Account_Balance);
|
Acct_IO.Put (The_File, The_Loan.Account_Balance);
|
Loan_IO.Put (The_File, The_Loan.Loan_Balance, 15, 2, 0);
|
Loan_IO.Put (The_File, The_Loan.Loan_Balance, 15, 2, 0);
|
Rate_IO.Put (File => The_File,
|
Rate_IO.Put (File => The_File,
|
Item => The_Loan.Loan_Interest_Rate,
|
Item => The_Loan.Loan_Interest_Rate,
|
Fore => 6,
|
Fore => 6,
|
Aft => 3,
|
Aft => 3,
|
Exp => 0);
|
Exp => 0);
|
Text_IO.New_Line (The_File);
|
Text_IO.New_Line (The_File);
|
Status := True;
|
Status := True;
|
exception
|
exception
|
when others => Status := False;
|
when others => Status := False;
|
end Update_Loan_Info;
|
end Update_Loan_Info;
|
|
|
|
|
begin
|
begin
|
|
|
-- This code section simulates a bank maintaining a data file
|
-- This code section simulates a bank maintaining a data file
|
-- containing information on loans that have been made.
|
-- containing information on loans that have been made.
|
-- The scenario:
|
-- The scenario:
|
-- The loan file was created in Out_File mode.
|
-- The loan file was created in Out_File mode.
|
-- Some number of data records are added.
|
-- Some number of data records are added.
|
-- The file is closed.
|
-- The file is closed.
|
-- The file is subsequently reopened in Append_File mode.
|
-- The file is subsequently reopened in Append_File mode.
|
-- Data is appended to the file.
|
-- Data is appended to the file.
|
-- The file is closed.
|
-- The file is closed.
|
-- Repeat the Open/Append/Close process as required.
|
-- Repeat the Open/Append/Close process as required.
|
-- Verify data in the file.
|
-- Verify data in the file.
|
-- etc.
|
-- etc.
|
|
|
Update_Loan_Info(Loan_File, Home_Refinance_Loan, Transaction_Status);
|
Update_Loan_Info(Loan_File, Home_Refinance_Loan, Transaction_Status);
|
|
|
if not Transaction_Status then
|
if not Transaction_Status then
|
Report.Failed ("Failure in update of first loan data");
|
Report.Failed ("Failure in update of first loan data");
|
end if;
|
end if;
|
|
|
Text_IO.Close (Loan_File);
|
Text_IO.Close (Loan_File);
|
|
|
-- When subsequent data items are to be added to the file, the file
|
-- When subsequent data items are to be added to the file, the file
|
-- is opened in Append_File mode.
|
-- is opened in Append_File mode.
|
|
|
Text_IO.Open (Loan_File, -- Open with
|
Text_IO.Open (Loan_File, -- Open with
|
Text_IO.Append_File, -- Append mode.
|
Text_IO.Append_File, -- Append mode.
|
Loan_Filename);
|
Loan_Filename);
|
|
|
Update_Loan_Info(Loan_File, Line_Of_Credit_Loan, Transaction_Status);
|
Update_Loan_Info(Loan_File, Line_Of_Credit_Loan, Transaction_Status);
|
|
|
if not Transaction_Status then
|
if not Transaction_Status then
|
Report.Failed("Failure in update of first loan data");
|
Report.Failed("Failure in update of first loan data");
|
end if;
|
end if;
|
|
|
Text_IO.Close(Loan_File);
|
Text_IO.Close(Loan_File);
|
|
|
-- To add additional data to the file, the file
|
-- To add additional data to the file, the file
|
-- is again opened in Append_File mode (appending to a file
|
-- is again opened in Append_File mode (appending to a file
|
-- previously appended to).
|
-- previously appended to).
|
|
|
Text_IO.Open (Loan_File, -- Open with
|
Text_IO.Open (Loan_File, -- Open with
|
Text_IO.Append_File, -- Append mode.
|
Text_IO.Append_File, -- Append mode.
|
Loan_Filename);
|
Loan_Filename);
|
|
|
Update_Loan_Info(Loan_File, Small_Business_Loan, Transaction_Status);
|
Update_Loan_Info(Loan_File, Small_Business_Loan, Transaction_Status);
|
|
|
if not Transaction_Status then
|
if not Transaction_Status then
|
Report.Failed("Failure in update of first loan data");
|
Report.Failed("Failure in update of first loan data");
|
end if;
|
end if;
|
|
|
Test_Verification_Block:
|
Test_Verification_Block:
|
declare
|
declare
|
type Ledger_Type is
|
type Ledger_Type is
|
array (1 .. Total_Loans_Outstanding) of Loan_Info_Type;
|
array (1 .. Total_Loans_Outstanding) of Loan_Info_Type;
|
TC_Bank_Ledger : Ledger_Type;
|
TC_Bank_Ledger : Ledger_Type;
|
TC_Item_Count : Natural := 0;
|
TC_Item_Count : Natural := 0;
|
begin
|
begin
|
|
|
Reset1:
|
Reset1:
|
begin
|
begin
|
Text_IO.Reset (Loan_File, Text_IO.In_File); -- Reset for
|
Text_IO.Reset (Loan_File, Text_IO.In_File); -- Reset for
|
-- reading.
|
-- reading.
|
exception
|
exception
|
when Text_IO.Use_Error =>
|
when Text_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Reset to In_File not supported for Text_IO" );
|
( "Reset to In_File not supported for Text_IO" );
|
raise Incomplete;
|
raise Incomplete;
|
end Reset1;
|
end Reset1;
|
|
|
while not Text_IO.End_Of_File (Loan_File) loop
|
while not Text_IO.End_Of_File (Loan_File) loop
|
TC_Item_Count := TC_Item_Count + 1;
|
TC_Item_Count := TC_Item_Count + 1;
|
Acct_IO.Get (Loan_File,
|
Acct_IO.Get (Loan_File,
|
TC_Bank_Ledger(TC_Item_Count).Account_Balance);
|
TC_Bank_Ledger(TC_Item_Count).Account_Balance);
|
Loan_IO.Get (Loan_File,
|
Loan_IO.Get (Loan_File,
|
TC_Bank_Ledger(TC_Item_Count).Loan_Balance,
|
TC_Bank_Ledger(TC_Item_Count).Loan_Balance,
|
0);
|
0);
|
Rate_IO.Get(File => Loan_File,
|
Rate_IO.Get(File => Loan_File,
|
Item =>
|
Item =>
|
TC_Bank_Ledger(TC_Item_Count).Loan_Interest_Rate,
|
TC_Bank_Ledger(TC_Item_Count).Loan_Interest_Rate,
|
Width => 0);
|
Width => 0);
|
Text_IO.Skip_Line(Loan_File);
|
Text_IO.Skip_Line(Loan_File);
|
|
|
end loop;
|
end loop;
|
|
|
-- Verify all of the data fields read from the file. Compare
|
-- Verify all of the data fields read from the file. Compare
|
-- with the values that were originally entered into the file.
|
-- with the values that were originally entered into the file.
|
|
|
if (TC_Bank_Ledger(1) /= Home_Refinance_Loan) or
|
if (TC_Bank_Ledger(1) /= Home_Refinance_Loan) or
|
(TC_Bank_Ledger(2) /= Line_Of_Credit_Loan) or
|
(TC_Bank_Ledger(2) /= Line_Of_Credit_Loan) or
|
(TC_Bank_Ledger(3) /= Small_Business_Loan) then
|
(TC_Bank_Ledger(3) /= Small_Business_Loan) then
|
Report.Failed("Error in data read from file");
|
Report.Failed("Error in data read from file");
|
end if;
|
end if;
|
|
|
if (TC_Item_Count /= Total_Loans_Outstanding) then
|
if (TC_Item_Count /= Total_Loans_Outstanding) then
|
Report.Failed ("Incorrect number of records read from file");
|
Report.Failed ("Incorrect number of records read from file");
|
end if;
|
end if;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
raise;
|
raise;
|
when others =>
|
when others =>
|
Report.Failed ("Error raised during data verification");
|
Report.Failed ("Error raised during data verification");
|
end Test_Verification_Block;
|
end Test_Verification_Block;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
raise;
|
raise;
|
when others =>
|
when others =>
|
Report.Failed ("Exception in Text_IO.Float_IO processing");
|
Report.Failed ("Exception in Text_IO.Float_IO processing");
|
end Operational_Test_Block;
|
end Operational_Test_Block;
|
|
|
Final_Block:
|
Final_Block:
|
begin
|
begin
|
-- Delete the external file.
|
-- Delete the external file.
|
if Text_IO.Is_Open(Loan_File) then
|
if Text_IO.Is_Open(Loan_File) then
|
Text_IO.Delete(Loan_File);
|
Text_IO.Delete(Loan_File);
|
else
|
else
|
Text_IO.Open(Loan_File, Text_IO.In_File, Loan_Filename);
|
Text_IO.Open(Loan_File, Text_IO.In_File, Loan_Filename);
|
Text_IO.Delete(Loan_File);
|
Text_IO.Delete(Loan_File);
|
end if;
|
end if;
|
|
|
exception
|
exception
|
|
|
when Text_IO.Use_Error =>
|
when Text_IO.Use_Error =>
|
Report.Failed
|
Report.Failed
|
( "Delete not properly implemented for Text_IO" );
|
( "Delete not properly implemented for Text_IO" );
|
|
|
end Final_Block;
|
end Final_Block;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
Report.Result;
|
Report.Result;
|
when others =>
|
when others =>
|
Report.Failed ( "Unexpected exception" );
|
Report.Failed ( "Unexpected exception" );
|
Report.Result;
|
Report.Result;
|
|
|
end CXAA009;
|
end CXAA009;
|
|
|