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/] [cxaa008.a] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXAA008.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 provided in instantiations of the
28
--      Ada.Text_IO.Fixed_IO package operate correctly when the mode of
29
--      the file is Append_File.  Check that Fixed_IO procedures Put and Get
30
--      properly transfer fixed 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
33
--      retrieval of data.
34
--
35
-- TEST DESCRIPTION:
36
--      This test simulates order processing, with data values being written
37
--      to a file, in a specific format, using Fixed_IO.  Validation is done
38
--      on this process by reading the data values from the file, and
39
--      comparing them for equality with the values originally written to
40
--      the file.
41
--
42
--      This test verifies issues of create in Append_File mode, appending to
43
--      a file previously appended to, resetting to Append_File mode,
44
--      resetting from Append_File mode to In_File mode, as well as a
45
--      variety of Text_IO and Fixed_IO predefined subprograms.
46
--
47
-- APPLICABILITY CRITERIA:
48
--      This test is applicable only to implementations that support text
49
--      files.
50
--
51
--
52
-- CHANGE HISTORY:
53
--      06 Dec 94   SAIC    ACVC 2.0
54
--      25 Feb 97   PWB.CTA Allowed for non-support of some IO operations
55
--!
56
 
57
with Ada.Text_IO;
58
with Report;
59
 
60
procedure CXAA008 is
61
   use Ada;
62
 
63
   Inventory_File     : Text_IO.File_Type;
64
   Inventory_Filename : constant String :=
65
                          Report.Legal_File_Name ( Nam => "CXAA008" );
66
   Incomplete         : exception;
67
 
68
begin
69
 
70
   Report.Test ("CXAA008", "Check that the capabilities of "               &
71
                           "Text_IO.Fixed_IO operate correctly for files " &
72
                           "with mode Append_File");
73
 
74
   Test_for_Text_IO_Support:
75
   begin
76
 
77
      -- An implementation that does not support Text_IO in a particular
78
      -- environment will raise Use_Error on calls to various
79
      -- Text_IO operations.  This block statement encloses a call to
80
      -- Create, which should raise the exception in a non-supportive
81
      -- environment.  This exception will be handled to produce a
82
      -- Not_Applicable result.
83
 
84
      Text_IO.Create (File => Inventory_File,
85
                      Mode => Text_IO.Append_File,
86
                      Name => Inventory_Filename);
87
 
88
   exception
89
      when Text_IO.Use_Error | Text_IO.Name_Error =>
90
         Report.Not_Applicable
91
            ( "Files not supported - Create with Append_File for Text_IO" );
92
         raise Incomplete;
93
   end Test_For_Text_IO_Support;
94
 
95
   Operational_Test_Block:
96
   declare
97
 
98
      Daily_Orders_Received : constant Natural := 4;
99
 
100
      type Item_Type   is delta 0.1  range    0.0 .. 5000.0;
101
      type Cost_Type   is delta 0.01 range    0.0 .. 10_000.0;
102
      type Profit_Type is delta 0.01 range -100.0 .. 1000.0;
103
 
104
      type Product_Type is record
105
         Item_Number    : Item_Type   := 0.0;
106
         Unit_Cost      : Cost_Type   := 0.00;
107
         Percent_Markup : Profit_Type := 0.00;
108
      end record;
109
 
110
      type Inventory_Type is
111
        array (1 .. Daily_Orders_Received) of Product_Type;
112
 
113
      Daily_Inventory   : Inventory_Type := ((   1.0,   1.75,  50.00),
114
                                             ( 155.0,  20.00,  -5.50),
115
                                             (3343.5,   2.50, 126.50),
116
                                             (4986.0, 180.00,  31.75));
117
 
118
      package Item_IO   is new Text_IO.Fixed_IO (Item_Type);
119
      package Cost_IO   is new Text_IO.Fixed_IO (Cost_Type);
120
      package Markup_IO is new Text_IO.Fixed_IO (Profit_Type);
121
 
122
 
123
      function TC_Mode_Selection (Selector : Integer)
124
        return Text_IO.File_Mode is
125
      begin
126
         case Selector is
127
            when 1       => return Text_IO.In_File;
128
            when 2       => return Text_IO.Out_File;
129
            when others  => return Text_IO.Append_File;
130
         end case;
131
      end TC_Mode_Selection;
132
 
133
 
134
      -- The following function simulates the addition of inventory item
135
      -- information into a data file.  Boolean status of True is returned
136
      -- if all of the data entry was successful, False otherwise.
137
 
138
      function Update_Inventory (The_List : Inventory_Type)
139
        return Boolean is
140
      begin
141
         for I in 1 .. Daily_Orders_Received loop
142
            Item_IO.Put  (Inventory_File, The_List(I).Item_Number);
143
            Cost_IO.Put  (Inventory_File, The_List(I).Unit_Cost, 10, 4, 0);
144
            Markup_IO.Put(File => Inventory_File,
145
                          Item => The_List(I).Percent_Markup,
146
                          Fore => 6,
147
                          Aft  => 3,
148
                          Exp  => 2);
149
            Text_IO.New_Line (Inventory_File);
150
         end loop;
151
         return (True);                         -- Return a Status value.
152
      exception
153
         when others => return False;
154
      end Update_Inventory;
155
 
156
 
157
   begin
158
 
159
      -- This code section simulates a receiving department maintaining a
160
      -- data file containing information on items that have been ordered
161
      -- and received.
162
 
163
      -- Whenever items are received, the file is reset to Append_File
164
      -- mode.  Data is taken from an inventory list and entered into the
165
      -- file, in specific format.
166
 
167
      Reset1:
168
      begin                                                -- Reset to
169
         Text_IO.Reset (Inventory_File,                    -- Append mode.
170
                        TC_Mode_Selection (Report.Ident_Int(3)));
171
      exception
172
         when Text_IO.Use_Error =>
173
            Report.Not_Applicable
174
               ( "Reset to Append_File not supported for Text_IO" );
175
      end Reset1;
176
 
177
                                                           -- Enter data.
178
      if not Update_Inventory (The_List => Daily_Inventory) then
179
         Report.Failed ("Exception occurred during inventory update");
180
         raise Incomplete;
181
      end if;
182
 
183
      Test_Verification_Block:
184
      declare
185
         TC_Item       : Item_Type;
186
         TC_Cost       : Cost_Type;
187
         TC_Markup     : Profit_Type;
188
         TC_Item_Count : Natural := 0;
189
      begin
190
 
191
         Reset2:
192
         begin
193
            Text_IO.Reset (Inventory_File, Text_IO.In_File);  -- Reset for
194
                                                              -- reading.
195
         exception
196
            when Text_IO.Use_Error =>
197
               Report.Not_Applicable
198
                  ( "Reset to In_File not supported for Text_IO" );
199
               raise Incomplete;
200
         end Reset2;
201
 
202
         while not Text_IO.End_Of_File (Inventory_File) loop
203
            Item_IO.Get   (Inventory_File, TC_Item);
204
            Cost_IO.Get   (Inventory_File, TC_Cost);
205
            Markup_IO.Get (File  => Inventory_File,
206
                           Item  => TC_Markup,
207
                           Width => 0);
208
            Text_IO.Skip_Line (Inventory_File);
209
            TC_Item_Count := TC_Item_Count + 1;
210
 
211
            -- Verify all of the data fields read from the file.  Compare
212
            -- with the values that were originally entered into the file.
213
 
214
            if (TC_Item /= Daily_Inventory(TC_Item_Count).Item_Number) then
215
               Report.Failed ("Error in Item_Number read from file");
216
            end if;
217
            if (TC_Cost /= Daily_Inventory(TC_Item_Count).Unit_Cost) then
218
               Report.Failed ("Error in Unit_Cost read from file");
219
            end if;
220
            if not (TC_Markup =
221
                    Daily_Inventory(TC_Item_Count).Percent_Markup) then
222
               Report.Failed ("Error in Percent_Markup read from file");
223
            end if;
224
 
225
         end loop;
226
 
227
         if (TC_Item_Count /= Daily_Orders_Received) then
228
            Report.Failed ("Incorrect number of records read from file");
229
         end if;
230
 
231
      exception
232
         when Incomplete =>
233
            raise;
234
         when others =>
235
            Report.Failed ("Error raised during data verification");
236
      end Test_Verification_Block;
237
 
238
   exception
239
      when Incomplete =>
240
         raise;
241
      when others =>
242
         Report.Failed ("Exception in Text_IO.Fixed_IO processing");
243
   end Operational_Test_Block;
244
 
245
   Final_Block:
246
   begin
247
      -- Delete the external file.
248
      if Text_IO.Is_Open (Inventory_File) then
249
         Text_IO.Delete (Inventory_File);
250
      else
251
         Text_IO.Open (Inventory_File, Text_IO.In_File, Inventory_Filename);
252
         Text_IO.Delete (Inventory_File);
253
      end if;
254
 
255
   exception
256
 
257
      when others =>
258
         Report.Failed ( "Delete not properly implemented for Text_IO" );
259
 
260
   end Final_Block;
261
 
262
   Report.Result;
263
 
264
exception
265
   when Incomplete =>
266
      Report.Result;
267
   when others     =>
268
      Report.Failed ( "Unexpected exception" );
269
      Report.Result;
270
 
271
end CXAA008;

powered by: WebSVN 2.1.0

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