OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxaa007.a] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXAA007.A
2
--
3
--                             Grant of Unlimited Rights
4
--
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
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
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.
24
--*
25
--
26
-- OBJECTIVE:
27
--      Check that the capabilities of Text_IO.Integer_IO perform correctly
28
--      on files of Append_File mode, for instantiations with integer and
29
--      user-defined subtypes.
30
--      Check that the formatting parameters available in the package can
31
--      be used and modified successfully in the storage and retrieval of
32
--      data.
33
--
34
-- TEST DESCRIPTION:
35
--      This test simulates a receiving department inventory system.  Data on
36
--      items received is entered into an inventory database. This information
37
--      consists of integer entry number, item number, and bar code.
38
--      One item is placed into the inventory file immediately following file
39
--      creation, subsequent items are entered following file opening in
40
--      Append_File mode.  Data items are validated by reading all data from
41
--      the file and comparing against known values (those used to enter the
42
--      data originally).
43
--
44
--      This test verifies issues of create in Append_File mode, appending to
45
--      a file previously appended to, opening in Append_File mode, resetting
46
--      from Append_File mode to In_File mode, as well as a variety of Text_IO
47
--      and Integer_IO predefined subprograms.
48
--
49
-- APPLICABILITY CRITERIA:
50
--      This test is applicable only to implementations that support text
51
--      files.
52
--
53
--
54
-- CHANGE HISTORY:
55
--      06 Dec 94   SAIC    ACVC 2.0
56
--      25 Feb 97   PWB.CTA Allowed for non-support of some IO operations
57
--!
58
 
59
with Ada.Text_IO;
60
with Report;
61
 
62
procedure CXAA007 is
63
   use Ada;
64
 
65
   Inventory_File     : Text_IO.File_Type;
66
   Inventory_Filename : constant String :=
67
                           Report.Legal_File_Name ( Nam => "CXAA007" );
68
   Incomplete         : exception;
69
 
70
begin
71
 
72
   Report.Test ("CXAA007", "Check that the capabilities of "                 &
73
                           "Text_IO.Integer_IO operate correctly for files " &
74
                           "with mode Append_File");
75
 
76
   Test_for_Text_IO_Support:
77
   begin
78
 
79
      -- An implementation that does not support Text_IO in a particular
80
      -- environment will raise Use_Error on calls to various
81
      -- Text_IO operations.  This block statement encloses a call to
82
      -- Create, which should raise the exception in a non-supportive
83
      -- environment.  This exception will be handled to produce a
84
      -- Not_Applicable result.
85
 
86
      Text_IO.Create (File => Inventory_File,
87
                      Mode => Text_IO.Append_File,
88
                      Name => Inventory_Filename);
89
   exception
90
      when Text_IO.Use_Error | Text_IO.Name_Error =>
91
         Report.Not_Applicable
92
            ( "Files not supported - Create with Append_File for Text_IO" );
93
         raise Incomplete;
94
   end Test_for_Text_IO_Support;
95
 
96
   Operational_Test_Block:
97
   declare
98
 
99
      Max_Entries_Per_Order : constant Natural := 4;
100
 
101
      type Bar_Code_Type is range 0 .. 127; -- Values to be stored as base
102
                                            -- two numbers in file.
103
      type Item_Type is record
104
         Entry_Number : Natural        := 0;
105
         Item_Number  : Integer        := 0;
106
         Bar_Code     : Bar_Code_Type  := 0;
107
      end record;
108
 
109
      type Inventory_Type is
110
        array (1 .. Max_Entries_Per_Order) of Item_Type;
111
 
112
      Inventory_List : Inventory_Type := ((1, 119,  87), -- Items received
113
                                          (2, 206,  44), -- this order.
114
                                          (3, -25, 126),
115
                                          (4, -18, 31));
116
 
117
      Daily_Order        : constant := 1;
118
      Entry_Field_Width  : constant Natural :=  1;
119
      Item_Base          : constant Natural := 16;
120
      Items_Inventoried  : Natural := 1;
121
      Items_To_Inventory : Natural := 4;
122
 
123
      package Entry_IO    is new Text_IO.Integer_IO (Natural);
124
      package Item_IO     is new Text_IO.Integer_IO (Integer);
125
      package Bar_Code_IO is new Text_IO.Integer_IO (Bar_Code_Type);
126
 
127
 
128
      -- The following procedure simulates the addition of inventory item
129
      -- information into a data file.
130
 
131
      procedure Update_Inventory (The_Item : in Item_Type) is
132
         Spacer : constant String := "   ";
133
      begin
134
         -- Enter all the incoming data into the inventory file.
135
         Entry_IO.Put   (Inventory_File, The_Item.Entry_Number);
136
         Text_IO.Put    (Inventory_File, Spacer);
137
         Item_IO.Put    (Inventory_File, The_Item.Item_Number);
138
         Text_IO.Put    (Inventory_File, Spacer);
139
         Bar_Code_IO.Put(File  => Inventory_File,
140
                         Item  => The_Item.Bar_Code,
141
                         Width => 13,
142
                         Base  =>  2);
143
         Text_IO.New_Line(Inventory_File);
144
      end Update_Inventory;
145
 
146
 
147
   begin
148
 
149
      -- This code section simulates a receiving department maintaining a
150
      -- data file containing information on items that have been ordered
151
      -- and received.
152
      --
153
      -- As new orders are received, the file is opened in Append_File
154
      -- mode.
155
      -- Data is taken from the inventory list and entered into the file,
156
      -- in specific format.
157
      -- Enter the order into the inventory file.  This is item 1 in
158
      -- the inventory list.
159
      -- The data entry process can be repeated numerous times as required.
160
 
161
      Entry_IO.Put     (Inventory_File,
162
                        Inventory_List(Daily_Order).Entry_Number);
163
      Item_IO.Put      (Inventory_File,
164
                        Inventory_List(Daily_Order).Item_Number);
165
      Bar_Code_IO.Put  (File  => Inventory_File,
166
                        Item  => Inventory_List(Daily_Order).Bar_Code);
167
      Text_IO.New_Line (Inventory_File);
168
 
169
      Text_IO.Close    (Inventory_File);
170
 
171
 
172
      Entry_IO.Default_Width := Entry_Field_Width;  -- Modify the default
173
                                                    -- width of Entry_IO.
174
      Item_IO.Default_Base   := Item_Base;          -- Modify the default
175
                                                    -- number base of
176
                                                    -- Item_IO
177
      Text_IO.Open (Inventory_File,
178
                    Text_IO.Append_File,            -- Open in Append mode.
179
                    Inventory_Filename);
180
                                                          -- Enter items
181
      while (Items_Inventoried < Items_To_Inventory) loop -- 2-4 into the
182
         Items_Inventoried := Items_Inventoried + 1;     -- inventory file.
183
         Update_Inventory (The_Item => Inventory_List (Items_Inventoried));
184
      end loop;
185
 
186
      Test_Verification_Block:                           -- Read and check
187
      declare                                            -- all the data
188
         TC_Entry      : Natural;                        -- values that
189
         TC_Item       : Integer;                        -- have been
190
         TC_Bar_Code   : Bar_Code_Type;                  -- entered in the
191
         TC_Item_Count : Natural := 0;                   -- data file.
192
      begin
193
 
194
         Reset1:
195
         begin
196
            Text_IO.Reset (Inventory_File, Text_IO.In_File);  -- Reset for
197
                                                              -- reading.
198
         exception
199
            when Text_IO.Use_Error =>
200
               Report.Not_Applicable
201
                  ( "Reset to mode In_File not supported for Text_IO" );
202
               raise Incomplete;
203
         end Reset1;
204
 
205
         while not Text_IO.End_Of_File (Inventory_File) loop
206
            Entry_IO.Get      (Inventory_File, TC_Entry);
207
            Item_IO.Get       (Inventory_File, TC_Item);
208
            Bar_Code_IO.Get   (Inventory_File, TC_Bar_Code);
209
            Text_IO.Skip_Line (Inventory_File);
210
            TC_Item_Count := TC_Item_Count + 1;
211
 
212
            if (TC_Item     /= Inventory_List(TC_Entry).Item_Number) or
213
               (TC_Bar_Code /= Inventory_List(TC_Entry).Bar_Code)    then
214
               Report.Failed ("Error in integer data read from file");
215
            end if;
216
         end loop;
217
 
218
         if (TC_Item_Count /= Max_Entries_Per_Order) then
219
            Report.Failed ("Incorrect number of records read from file");
220
         end if;
221
 
222
      exception
223
         when Incomplete =>
224
            raise;
225
        when others =>
226
            Report.Failed ("Error raised during data verification");
227
      end Test_Verification_Block;
228
 
229
   exception
230
      when Incomplete =>
231
         raise;
232
      when others =>
233
         Report.Failed ("Exception in Text_IO.Integer_IO processing");
234
   end Operational_Test_Block;
235
 
236
   Final_Block:
237
   begin
238
      -- Delete the external file.
239
      if Text_IO.Is_Open(Inventory_File) then
240
         Text_IO.Delete (Inventory_File);
241
      else
242
         Text_IO.Open (Inventory_File, Text_IO.In_File, Inventory_Filename);
243
         Text_IO.Delete (Inventory_File);
244
      end if;
245
 
246
   exception
247
 
248
      when others =>
249
         Report.Failed ( "Delete not properly implemented for Text_IO" );
250
 
251
   end Final_Block;
252
 
253
   Report.Result;
254
 
255
exception
256
 
257
   when Incomplete =>
258
      Report.Result;
259
   when others     =>
260
      Report.Failed ( "Unexpected exception" );
261
      Report.Result;
262
 
263
end CXAA007;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.