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 all elements to be transferred to a sequential file of
28 -- mode Append_File will be placed following the last element currently
30 -- Check that it is possible to append data to a file that has been
31 -- previously appended to.
32 -- Check that the predefined procedure Write will place an element after
33 -- the last element in the file in mode Append_File.
36 -- This test implements a sequential file system that has the capability
37 -- to store data records at the end of a file. Initially, the file is
38 -- opened with mode Out_File, and data is written to the file. The file
39 -- is closed, then reopened with mode Append_File. An additional record
40 -- is written, and again the file is closed. The file is then reopened,
41 -- again with mode Append_File, and another record is written to the
43 -- The file is closed again, the reopened with mode In_File, and the data
44 -- in the file is read and checked for proper ordering within the file.
46 -- An expected common usage of Append_File mode would be in the opening
47 -- of a file that currently contains data. Likewise, the reopening of
48 -- files in Append_Mode that have been previously appended to for the
49 -- addition of more data would be frequently encountered. This test
50 -- attempts to simulate both situations. (Of course, in an actual user
51 -- environment, the open/write/close processing would be performed using
52 -- looping structures, rather than the straight-line processing displayed
55 -- APPLICABILITY CRITERIA:
56 -- Applicable to all systems capable of supporting IO operations on
57 -- external Sequential_IO files.
61 -- 06 Dec 94 SAIC ACVC 2.0
62 -- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
70 -- Declare data types and objects to be stored in the file.
71 subtype Name_Type
is String (1 .. 10);
72 type Tickets
is range 0 .. 1000;
74 type Order_Type
is record
76 No_of_Tickets
: Tickets
;
79 package Order_IO
is new Sequential_IO
(Order_Type
); -- Declare Seq_IO
81 Order_File
: Order_IO
.File_Type
; -- and file object.
82 Order_Filename
: constant String :=
83 Report
.Legal_File_Name
( Nam
=> "CXA8001" );
84 Incomplete
: exception;
88 Report
.Test
("CXA8001", "Check that all elements to be transferred to a " &
89 "sequential file of mode Append_File will be " &
90 "placed following the last element currently " &
93 Test_for_Sequential_IO_Support
:
96 -- An implementation that does not support Sequential_IO in a particular
97 -- environment will raise Use_Error or Name_Error on calls to various
98 -- Sequential_IO operations. This block statement encloses a call to
99 -- Create, which should produce an exception in a non-supportive
100 -- environment. These exceptions will be handled to produce a
101 -- Not_Applicable result.
103 Order_IO
.Create
(File
=> Order_File
, -- Create Sequential_IO file
104 Mode
=> Order_IO
.Out_File
, -- with mode Out_File.
105 Name
=> Order_Filename
);
109 when Order_IO
.Use_Error | Order_IO
.Name_Error
=>
110 Report
.Not_Applicable
111 ( "Files not supported - Create as Out_File for Sequential_IO" );
114 end Test_for_Sequential_IO_Support
;
116 Operational_Test_Block
:
118 -- Assign values into the component fields of the data objects.
119 Buyer_1
: constant Order_Type
:= ("John Smith", 3);
120 Buyer_2
: constant Order_Type
:=
121 (Name
=> "Jane Jones", No_of_Tickets
=> 2);
122 Buyer_3
: Order_Type
:= ("Mike Brown", 5);
125 Order_IO
.Write
(File
=> Order_File
, -- Write initial data item
126 Item
=> Buyer_1
); -- to file.
128 Order_IO
.Close
(File
=> Order_File
); -- Close file.
131 -- Enter additional data records into the file. (Append to a file of
132 -- previous mode Out_File).
134 Order_IO
.Open
(Order_File
, -- Open Sequential_IO file
135 Order_IO
.Append_File
, -- with mode Append_File.
138 Order_IO
.Write
(Order_File
, Buyer_2
); -- Write second data item
140 Order_IO
.Close
(File
=> Order_File
); -- Close file.
142 -- Check to determine whether file is actually closed.
144 Order_IO
.Write
(Order_File
, Buyer_2
);
145 Report
.Failed
("Exception not raised on Write to Closed file");
147 when Order_IO
.Status_Error
=> null; -- Expected exception.
149 Report
.Failed
("Incorrect exception on Write to Closed file");
153 -- The following code segment demonstrates appending data to a file
154 -- that has been previously appended to.
157 Order_IO
.Open
(Order_File
, -- Open Sequential_IO file
158 Order_IO
.Append_File
, -- with mode Append_File.
161 Order_IO
.Write
(Order_File
, Buyer_3
); -- Write third data item
163 Order_IO
.Close
(File
=> Order_File
); -- Close file.
166 Test_Verification_Block
:
168 TC_Order1
, TC_Order2
, TC_Order3
: Order_Type
;
171 Order_IO
.Open
(Order_File
, -- Open Sequential_IO file
172 Order_IO
.In_File
, -- with mode In_File.
175 Order_IO
.Read
(File
=> Order_File
, -- Read records from file.
177 Order_IO
.Read
(Order_File
, TC_Order2
);
178 Order_IO
.Read
(Order_File
, TC_Order3
);
180 -- Compare the contents of each with the individual data items.
181 -- If items read from file do not match the items placed into
182 -- the file, in the appropriate order, then fail.
184 if ((TC_Order1
/= Buyer_1
) or
185 (TC_Order2
.Name
/= Buyer_2
.Name
) or
186 (TC_Order2
.No_of_Tickets
/= Buyer_2
.No_of_Tickets
) or
187 not ((TC_Order3
.Name
= "Mike Brown") and
188 (TC_Order3
.No_of_Tickets
= 5))) then
189 Report
.Failed
("Incorrect appending of record data in file");
192 -- Check to determine that no more than three data records were
193 -- actually written to the file.
194 if not Order_IO
.End_Of_File
(Order_File
) then
195 Report
.Failed
("File not empty after three reads");
200 when Order_IO
.End_Error
=> -- If three items not in
201 -- file (data overwritten),
203 Report
.Failed
("Incorrect number of record elements in file");
206 Report
.Failed
("Error raised during data verification");
208 end Test_Verification_Block
;
213 Report
.Failed
("Exception raised during Sequential_IO processing");
215 end Operational_Test_Block
;
219 -- Check that file is open prior to deleting it.
220 if Order_IO
.Is_Open
(Order_File
) then
221 Order_IO
.Delete
(Order_File
);
223 Order_IO
.Open
(Order_File
, Order_IO
.In_File
, Order_Filename
);
224 Order_IO
.Delete
(Order_File
);
230 ( "Delete not properly implemented for Sequential_IO" );
240 Report
.Failed
( "Unexpected exception" );