-- CXA8001.A
|
-- CXA8001.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 all elements to be transferred to a sequential file of
|
-- Check that all elements to be transferred to a sequential file of
|
-- mode Append_File will be placed following the last element currently
|
-- mode Append_File will be placed following the last element currently
|
-- in the file.
|
-- in the file.
|
-- Check that it is possible to append data to a file that has been
|
-- Check that it is possible to append data to a file that has been
|
-- previously appended to.
|
-- previously appended to.
|
-- Check that the predefined procedure Write will place an element after
|
-- Check that the predefined procedure Write will place an element after
|
-- the last element in the file in mode Append_File.
|
-- the last element in the file in mode Append_File.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test implements a sequential file system that has the capability
|
-- This test implements a sequential file system that has the capability
|
-- to store data records at the end of a file. Initially, the file is
|
-- to store data records at the end of a file. Initially, the file is
|
-- opened with mode Out_File, and data is written to the file. The file
|
-- opened with mode Out_File, and data is written to the file. The file
|
-- is closed, then reopened with mode Append_File. An additional record
|
-- is closed, then reopened with mode Append_File. An additional record
|
-- is written, and again the file is closed. The file is then reopened,
|
-- is written, and again the file is closed. The file is then reopened,
|
-- again with mode Append_File, and another record is written to the
|
-- again with mode Append_File, and another record is written to the
|
-- file.
|
-- file.
|
-- The file is closed again, the reopened with mode In_File, and the data
|
-- The file is closed again, the reopened with mode In_File, and the data
|
-- in the file is read and checked for proper ordering within the file.
|
-- in the file is read and checked for proper ordering within the file.
|
--
|
--
|
-- An expected common usage of Append_File mode would be in the opening
|
-- An expected common usage of Append_File mode would be in the opening
|
-- of a file that currently contains data. Likewise, the reopening of
|
-- of a file that currently contains data. Likewise, the reopening of
|
-- files in Append_Mode that have been previously appended to for the
|
-- files in Append_Mode that have been previously appended to for the
|
-- addition of more data would be frequently encountered. This test
|
-- addition of more data would be frequently encountered. This test
|
-- attempts to simulate both situations. (Of course, in an actual user
|
-- attempts to simulate both situations. (Of course, in an actual user
|
-- environment, the open/write/close processing would be performed using
|
-- environment, the open/write/close processing would be performed using
|
-- looping structures, rather than the straight-line processing displayed
|
-- looping structures, rather than the straight-line processing displayed
|
-- here.)
|
-- here.)
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- Applicable to all systems capable of supporting IO operations on
|
-- Applicable to all systems capable of supporting IO operations on
|
-- external Sequential_IO files.
|
-- external Sequential_IO files.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
-- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
|
--!
|
--!
|
|
|
with Sequential_IO;
|
with Sequential_IO;
|
with Report;
|
with Report;
|
|
|
procedure CXA8001 is
|
procedure CXA8001 is
|
|
|
-- Declare data types and objects to be stored in the file.
|
-- Declare data types and objects to be stored in the file.
|
subtype Name_Type is String (1 .. 10);
|
subtype Name_Type is String (1 .. 10);
|
type Tickets is range 0 .. 1000;
|
type Tickets is range 0 .. 1000;
|
|
|
type Order_Type is record
|
type Order_Type is record
|
Name : Name_Type;
|
Name : Name_Type;
|
No_of_Tickets : Tickets;
|
No_of_Tickets : Tickets;
|
end record;
|
end record;
|
|
|
package Order_IO is new Sequential_IO (Order_Type); -- Declare Seq_IO
|
package Order_IO is new Sequential_IO (Order_Type); -- Declare Seq_IO
|
-- package,
|
-- package,
|
Order_File : Order_IO.File_Type; -- and file object.
|
Order_File : Order_IO.File_Type; -- and file object.
|
Order_Filename : constant String :=
|
Order_Filename : constant String :=
|
Report.Legal_File_Name ( Nam => "CXA8001" );
|
Report.Legal_File_Name ( Nam => "CXA8001" );
|
Incomplete : exception;
|
Incomplete : exception;
|
|
|
begin
|
begin
|
|
|
Report.Test ("CXA8001", "Check that all elements to be transferred to a " &
|
Report.Test ("CXA8001", "Check that all elements to be transferred to a " &
|
"sequential file of mode Append_File will be " &
|
"sequential file of mode Append_File will be " &
|
"placed following the last element currently " &
|
"placed following the last element currently " &
|
"in the file");
|
"in the file");
|
|
|
Test_for_Sequential_IO_Support:
|
Test_for_Sequential_IO_Support:
|
begin
|
begin
|
|
|
-- An implementation that does not support Sequential_IO in a particular
|
-- An implementation that does not support Sequential_IO in a particular
|
-- environment will raise Use_Error or Name_Error on calls to various
|
-- environment will raise Use_Error or Name_Error on calls to various
|
-- Sequential_IO operations. This block statement encloses a call to
|
-- Sequential_IO operations. This block statement encloses a call to
|
-- Create, which should produce an exception in a non-supportive
|
-- Create, which should produce an exception in a non-supportive
|
-- environment. These exceptions will be handled to produce a
|
-- environment. These exceptions will be handled to produce a
|
-- Not_Applicable result.
|
-- Not_Applicable result.
|
|
|
Order_IO.Create (File => Order_File, -- Create Sequential_IO file
|
Order_IO.Create (File => Order_File, -- Create Sequential_IO file
|
Mode => Order_IO.Out_File, -- with mode Out_File.
|
Mode => Order_IO.Out_File, -- with mode Out_File.
|
Name => Order_Filename);
|
Name => Order_Filename);
|
|
|
exception
|
exception
|
|
|
when Order_IO.Use_Error | Order_IO.Name_Error =>
|
when Order_IO.Use_Error | Order_IO.Name_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Files not supported - Create as Out_File for Sequential_IO" );
|
( "Files not supported - Create as Out_File for Sequential_IO" );
|
raise Incomplete;
|
raise Incomplete;
|
|
|
end Test_for_Sequential_IO_Support;
|
end Test_for_Sequential_IO_Support;
|
|
|
Operational_Test_Block:
|
Operational_Test_Block:
|
declare
|
declare
|
-- Assign values into the component fields of the data objects.
|
-- Assign values into the component fields of the data objects.
|
Buyer_1 : constant Order_Type := ("John Smith", 3);
|
Buyer_1 : constant Order_Type := ("John Smith", 3);
|
Buyer_2 : constant Order_Type :=
|
Buyer_2 : constant Order_Type :=
|
(Name => "Jane Jones", No_of_Tickets => 2);
|
(Name => "Jane Jones", No_of_Tickets => 2);
|
Buyer_3 : Order_Type := ("Mike Brown", 5);
|
Buyer_3 : Order_Type := ("Mike Brown", 5);
|
|
|
begin
|
begin
|
Order_IO.Write (File => Order_File, -- Write initial data item
|
Order_IO.Write (File => Order_File, -- Write initial data item
|
Item => Buyer_1); -- to file.
|
Item => Buyer_1); -- to file.
|
|
|
Order_IO.Close (File => Order_File); -- Close file.
|
Order_IO.Close (File => Order_File); -- Close file.
|
|
|
--
|
--
|
-- Enter additional data records into the file. (Append to a file of
|
-- Enter additional data records into the file. (Append to a file of
|
-- previous mode Out_File).
|
-- previous mode Out_File).
|
--
|
--
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.Append_File, -- with mode Append_File.
|
Order_IO.Append_File, -- with mode Append_File.
|
Order_Filename);
|
Order_Filename);
|
|
|
Order_IO.Write (Order_File, Buyer_2); -- Write second data item
|
Order_IO.Write (Order_File, Buyer_2); -- Write second data item
|
-- to file.
|
-- to file.
|
Order_IO.Close (File => Order_File); -- Close file.
|
Order_IO.Close (File => Order_File); -- Close file.
|
|
|
-- Check to determine whether file is actually closed.
|
-- Check to determine whether file is actually closed.
|
begin
|
begin
|
Order_IO.Write (Order_File, Buyer_2);
|
Order_IO.Write (Order_File, Buyer_2);
|
Report.Failed("Exception not raised on Write to Closed file");
|
Report.Failed("Exception not raised on Write to Closed file");
|
exception
|
exception
|
when Order_IO.Status_Error => null; -- Expected exception.
|
when Order_IO.Status_Error => null; -- Expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Incorrect exception on Write to Closed file");
|
Report.Failed("Incorrect exception on Write to Closed file");
|
end;
|
end;
|
|
|
--
|
--
|
-- The following code segment demonstrates appending data to a file
|
-- The following code segment demonstrates appending data to a file
|
-- that has been previously appended to.
|
-- that has been previously appended to.
|
--
|
--
|
|
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.Append_File, -- with mode Append_File.
|
Order_IO.Append_File, -- with mode Append_File.
|
Order_Filename );
|
Order_Filename );
|
|
|
Order_IO.Write (Order_File, Buyer_3); -- Write third data item
|
Order_IO.Write (Order_File, Buyer_3); -- Write third data item
|
-- to file.
|
-- to file.
|
Order_IO.Close (File => Order_File); -- Close file.
|
Order_IO.Close (File => Order_File); -- Close file.
|
|
|
|
|
Test_Verification_Block:
|
Test_Verification_Block:
|
declare
|
declare
|
TC_Order1, TC_Order2, TC_Order3 : Order_Type;
|
TC_Order1, TC_Order2, TC_Order3 : Order_Type;
|
begin
|
begin
|
|
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.Open (Order_File, -- Open Sequential_IO file
|
Order_IO.In_File, -- with mode In_File.
|
Order_IO.In_File, -- with mode In_File.
|
Order_Filename );
|
Order_Filename );
|
|
|
Order_IO.Read (File => Order_File, -- Read records from file.
|
Order_IO.Read (File => Order_File, -- Read records from file.
|
Item => TC_Order1);
|
Item => TC_Order1);
|
Order_IO.Read (Order_File, TC_Order2);
|
Order_IO.Read (Order_File, TC_Order2);
|
Order_IO.Read (Order_File, TC_Order3);
|
Order_IO.Read (Order_File, TC_Order3);
|
|
|
-- Compare the contents of each with the individual data items.
|
-- Compare the contents of each with the individual data items.
|
-- If items read from file do not match the items placed into
|
-- If items read from file do not match the items placed into
|
-- the file, in the appropriate order, then fail.
|
-- the file, in the appropriate order, then fail.
|
|
|
if ((TC_Order1 /= Buyer_1) or
|
if ((TC_Order1 /= Buyer_1) or
|
(TC_Order2.Name /= Buyer_2.Name) or
|
(TC_Order2.Name /= Buyer_2.Name) or
|
(TC_Order2.No_of_Tickets /= Buyer_2.No_of_Tickets) or
|
(TC_Order2.No_of_Tickets /= Buyer_2.No_of_Tickets) or
|
not ((TC_Order3.Name = "Mike Brown") and
|
not ((TC_Order3.Name = "Mike Brown") and
|
(TC_Order3.No_of_Tickets = 5))) then
|
(TC_Order3.No_of_Tickets = 5))) then
|
Report.Failed ("Incorrect appending of record data in file");
|
Report.Failed ("Incorrect appending of record data in file");
|
end if;
|
end if;
|
|
|
-- Check to determine that no more than three data records were
|
-- Check to determine that no more than three data records were
|
-- actually written to the file.
|
-- actually written to the file.
|
if not Order_IO.End_Of_File (Order_File) then
|
if not Order_IO.End_Of_File (Order_File) then
|
Report.Failed("File not empty after three reads");
|
Report.Failed("File not empty after three reads");
|
end if;
|
end if;
|
|
|
exception
|
exception
|
|
|
when Order_IO.End_Error => -- If three items not in
|
when Order_IO.End_Error => -- If three items not in
|
-- file (data overwritten),
|
-- file (data overwritten),
|
-- then fail.
|
-- then fail.
|
Report.Failed ("Incorrect number of record elements in file");
|
Report.Failed ("Incorrect number of record elements in file");
|
|
|
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 others =>
|
when others =>
|
Report.Failed("Exception raised during Sequential_IO processing");
|
Report.Failed("Exception raised during Sequential_IO processing");
|
|
|
end Operational_Test_Block;
|
end Operational_Test_Block;
|
|
|
Deletion:
|
Deletion:
|
begin
|
begin
|
-- Check that file is open prior to deleting it.
|
-- Check that file is open prior to deleting it.
|
if Order_IO.Is_Open(Order_File) then
|
if Order_IO.Is_Open(Order_File) then
|
Order_IO.Delete (Order_File);
|
Order_IO.Delete (Order_File);
|
else
|
else
|
Order_IO.Open(Order_File, Order_IO.In_File, Order_Filename);
|
Order_IO.Open(Order_File, Order_IO.In_File, Order_Filename);
|
Order_IO.Delete (Order_File);
|
Order_IO.Delete (Order_File);
|
end if;
|
end if;
|
|
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed
|
Report.Failed
|
( "Delete not properly implemented for Sequential_IO" );
|
( "Delete not properly implemented for Sequential_IO" );
|
|
|
end Deletion;
|
end Deletion;
|
|
|
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 CXA8001;
|
end CXA8001;
|
|
|