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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxac004.a] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXAC004.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 Stream_Access type and Stream function found in package
28
--      Ada.Text_IO.Text_Streams allows a text file to be processed with the
29
--      functionality of streams.
30
--
31
-- TEST DESCRIPTION:
32
--      This test verifies that the package Ada.Text_IO.Text_Streams is
33
--      available and that the functionality it contains allows a text file to
34
--      be manipulated as a stream.
35
--      The test defines data objects of a variety of types that can be stored
36
--      in a text file.  A text file and associated text stream are then
37
--      defined, and the 'Write attribute is used to enter the individual data
38
--      items into the text stream.  Once all the individual data items have
39
--      been written to the stream, the 'Output attribute is used to write
40
--      arrays of these same data objects to the stream.
41
--      The text file is reset to serve as an input file, and the 'Read
42
--      attribute is used to extract the individual data items from the
43
--      stream.  These items are then verified against the data originally
44
--      written to the stream. Finally, the 'Input attribute is used to
45
--      extract the data arrays from the stream. These arrays are then
46
--      verified against the original data written to the stream.
47
--
48
-- APPLICABILITY CRITERIA:
49
--      Applicable to implementations that support external text files.
50
--
51
-- CHANGE HISTORY:
52
--      06 Jul 95   SAIC    Initial prerelease version.
53
--      26 Feb 97   PWB.CTA Allowed for non-support of some IO operations;
54
--                          removed requirement for support of decimal types.
55
--!
56
 
57
with Report;
58
with Ada.Text_IO;
59
with Ada.Text_IO.Text_Streams;
60
with Ada.Characters.Latin_1;
61
with Ada.Strings.Unbounded;
62
 
63
procedure CXAC004 is
64
 
65
   Data_File     : Ada.Text_IO.File_Type;
66
   Data_Filename : constant String :=
67
                           Report.Legal_File_Name ( Nam => "CXAC004" );
68
   Incomplete : exception;
69
 
70
begin
71
 
72
   Report.Test ("CXAC004", "Check that the Stream_Access type and Stream "   &
73
                           "function found in package "                      &
74
                           "Ada.Text_IO.Text_Streams allows a text file to " &
75
                           "be processed with the functionality of streams");
76
 
77
   Test_for_IO_Support:
78
   begin
79
 
80
      -- Check for Text_IO support in creating the data file.  If the
81
      -- implementation does not support external files, Name_Error or
82
      -- Use_Error will be raised at the point of the following call to
83
      -- Create, resulting in a Not_Applicable test result.
84
 
85
      Ada.Text_IO.Create(Data_File, Ada.Text_IO.Out_File, Data_Filename);
86
 
87
   exception
88
 
89
       when Ada.Text_IO.Use_Error | Ada.Text_IO.Name_Error =>
90
          Report.Not_Applicable
91
             ( "Files not supported - Create as Out_File for Text_IO" );
92
          raise Incomplete;
93
 
94
   end Test_for_IO_Support;
95
 
96
   Test_Block:
97
   declare
98
      use Ada.Characters.Latin_1, Ada.Strings.Unbounded;
99
      TC_Items  : constant := 3;
100
 
101
      -- Declare types and objects that will be used as data values to be
102
      -- written to and read from the text file/stream.
103
 
104
      type Enum_Type          is (Red, Yellow, Green, Blue, Indigo);
105
      type Fixed_Type         is delta 0.125 range 0.0..255.0;
106
      type Float_Type         is digits 7 range 0.0..1.0E5;
107
      type Modular_Type       is mod 256;
108
      subtype Str_Type        is String(1..4);
109
 
110
      type Char_Array_Type    is array (1..TC_Items) of Character;
111
      type Enum_Array_Type    is array (1..TC_Items) of Enum_Type;
112
      type Fixed_Array_Type   is array (1..TC_Items) of Fixed_Type;
113
      type Float_Array_Type   is array (1..TC_Items) of Float_Type;
114
      type Int_Array_Type     is array (1..TC_Items) of Integer;
115
      type Mod_Array_Type     is array (1..TC_Items) of Modular_Type;
116
      type Str_Array_Type     is array (1..TC_Items) of Str_Type;
117
      type Unb_Str_Array_Type is array (1..TC_Items) of Unbounded_String;
118
 
119
      Char_Array      : Char_Array_Type    := ('A', 'z', Yen_Sign);
120
      TC_Char_Array_1,
121
      TC_Char_Array_2 : Char_Array_Type    := (others => Space);
122
 
123
      Enum_Array      : Enum_Array_Type    := (Blue, Yellow, Indigo);
124
      TC_Enum_Array_1,
125
      TC_Enum_Array_2 : Enum_Array_Type    := (others => Red);
126
 
127
      Fix_Array       : Fixed_Array_Type   := (0.125, 123.5, 250.750);
128
      TC_Fix_Array_1,
129
      TC_Fix_Array_2  : Fixed_Array_Type   := (others => 0.0);
130
 
131
      Flt_Array       : Float_Array_Type   := (1.0, 150.0, 1500.0);
132
      TC_Flt_Array_1,
133
      TC_Flt_Array_2  : Float_Array_Type   := (others => 0.0);
134
 
135
      Int_Array       : Int_Array_Type     := (124, 2349, -24_001);
136
      TC_Int_Array_1,
137
      TC_Int_Array_2  : Int_Array_Type     := (others => -99);
138
 
139
      Mod_Array       : Mod_Array_Type     := (10, 127, 255);
140
      TC_Mod_Array_1,
141
      TC_Mod_Array_2  : Mod_Array_Type     := (others => 0);
142
 
143
      Str_Array       : Str_Array_Type     := ("abcd", "klmn", "wxyz");
144
      TC_Str_Array_1,
145
      TC_Str_Array_2  : Str_Array_Type     := (others => "    ");
146
 
147
      UStr_Array      : Unb_Str_Array_Type :=
148
                                        (To_Unbounded_String("cat"),
149
                                         To_Unbounded_String("testing"),
150
                                         To_Unbounded_String("ACVC"));
151
      TC_UStr_Array_1,
152
      TC_UStr_Array_2 : Unb_Str_Array_Type :=
153
                                        (others => Null_Unbounded_String);
154
 
155
      -- Create a stream access object pointing to the data file.
156
 
157
      Data_Stream : Ada.Text_IO.Text_Streams.Stream_Access :=
158
                      Ada.Text_IO.Text_Streams.Stream(File => Data_File);
159
 
160
   begin
161
 
162
      -- Use the 'Write attribute to enter the three sets of data items
163
      -- into the data stream.
164
      -- Note that the data will be mixed within the text file.
165
 
166
      for i in 1..TC_Items loop
167
         Character'Write       (Data_Stream, Char_Array(i));
168
         Enum_Type'Write       (Data_Stream, Enum_Array(i));
169
         Fixed_Type'Write      (Data_Stream, Fix_Array(i));
170
         Float_Type'Write      (Data_Stream, Flt_Array(i));
171
         Integer'Write         (Data_Stream, Int_Array(i));
172
         Modular_Type'Write    (Data_Stream, Mod_Array(i));
173
         Str_Type'Write        (Data_Stream, Str_Array(i));
174
         Unbounded_String'Write(Data_Stream, UStr_Array(i));
175
      end loop;
176
 
177
      -- Use the 'Output attribute to enter the entire arrays of each
178
      -- type of data items into the data stream.
179
      -- Note that the array bounds will be written to the stream as part
180
      -- of the action of the 'Output attribute.
181
 
182
      Char_Array_Type'Output    (Data_Stream, Char_Array);
183
      Enum_Array_Type'Output    (Data_Stream, Enum_Array);
184
      Fixed_Array_Type'Output   (Data_Stream, Fix_Array);
185
      Float_Array_Type'Output   (Data_Stream, Flt_Array);
186
      Int_Array_Type'Output     (Data_Stream, Int_Array);
187
      Mod_Array_Type'Output     (Data_Stream, Mod_Array);
188
      Str_Array_Type'Output     (Data_Stream, Str_Array);
189
      Unb_Str_Array_Type'Output (Data_Stream, UStr_Array);
190
 
191
      -- Reset the data file to mode In_File.  The data file will now serve
192
      -- as the source of data which will be compared to the original data
193
      -- written to the file above.
194
      Reset1:
195
      begin
196
         Ada.Text_IO.Reset (File => Data_File, Mode => Ada.Text_IO.In_File);
197
      exception
198
         when Ada.Text_IO.Use_Error =>
199
            Report.Not_Applicable
200
               ( "Reset to In_File not supported for Text_IO" );
201
            raise Incomplete;
202
      end Reset1;
203
 
204
      -- Extract and validate all the single data items from the stream.
205
 
206
      for i in 1..TC_Items loop
207
         Character'Read        (Data_Stream, TC_Char_Array_1(i));
208
         Enum_Type'Read        (Data_Stream, TC_Enum_Array_1(i));
209
         Fixed_Type'Read       (Data_Stream, TC_Fix_Array_1(i));
210
         Float_Type'Read       (Data_Stream, TC_Flt_Array_1(i));
211
         Integer'Read          (Data_Stream, TC_Int_Array_1(i));
212
         Modular_Type'Read     (Data_Stream, TC_Mod_Array_1(i));
213
         Str_Type'Read         (Data_Stream, TC_Str_Array_1(i));
214
         Unbounded_String'Read (Data_Stream, TC_UStr_Array_1(i));
215
      end loop;
216
 
217
      if TC_Char_Array_1 /= Char_Array then
218
         Report.Failed("Character values do not match");
219
      end if;
220
      if TC_Enum_Array_1 /= Enum_Array then
221
         Report.Failed("Enumeration values do not match");
222
      end if;
223
      if TC_Fix_Array_1 /= Fix_Array then
224
         Report.Failed("Fixed point values do not match");
225
      end if;
226
      if TC_Flt_Array_1 /= Flt_Array then
227
         Report.Failed("Floating point values do not match");
228
      end if;
229
      if TC_Int_Array_1 /= Int_Array then
230
         Report.Failed("Integer values do not match");
231
      end if;
232
      if TC_Mod_Array_1 /= Mod_Array then
233
         Report.Failed("Modular values do not match");
234
      end if;
235
      if TC_Str_Array_1 /= Str_Array then
236
         Report.Failed("String values do not match");
237
      end if;
238
      if TC_UStr_Array_1 /= UStr_Array then
239
         Report.Failed("Unbounded_String values do not match");
240
      end if;
241
 
242
      -- Extract and validate all data arrays from the data stream.
243
      -- Note that the 'Input attribute denotes a function, whereas the
244
      -- other stream oriented attributes in this test denote procedures.
245
 
246
      TC_Char_Array_2 := Char_Array_Type'Input(Data_Stream);
247
      TC_Enum_Array_2 := Enum_Array_Type'Input(Data_Stream);
248
      TC_Fix_Array_2  := Fixed_Array_Type'Input(Data_Stream);
249
      TC_Flt_Array_2  := Float_Array_Type'Input(Data_Stream);
250
      TC_Int_Array_2  := Int_Array_Type'Input(Data_Stream);
251
      TC_Mod_Array_2  := Mod_Array_Type'Input(Data_Stream);
252
      TC_Str_Array_2  := Str_Array_Type'Input(Data_Stream);
253
      TC_UStr_Array_2 := Unb_Str_Array_Type'Input(Data_Stream);
254
 
255
      if TC_Char_Array_2 /= Char_Array then
256
         Report.Failed("Character array values do not match");
257
      end if;
258
      if TC_Enum_Array_2 /= Enum_Array then
259
         Report.Failed("Enumeration array values do not match");
260
      end if;
261
      if TC_Fix_Array_2 /= Fix_Array then
262
         Report.Failed("Fixed point array values do not match");
263
      end if;
264
      if TC_Flt_Array_2 /= Flt_Array then
265
         Report.Failed("Floating point array values do not match");
266
      end if;
267
      if TC_Int_Array_2 /= Int_Array then
268
         Report.Failed("Integer array values do not match");
269
      end if;
270
      if TC_Mod_Array_2 /= Mod_Array then
271
         Report.Failed("Modular array values do not match");
272
      end if;
273
      if TC_Str_Array_2 /= Str_Array then
274
         Report.Failed("String array values do not match");
275
      end if;
276
      if TC_UStr_Array_2 /= UStr_Array then
277
         Report.Failed("Unbounded_String array values do not match");
278
      end if;
279
 
280
   exception
281
      when Incomplete =>
282
         raise;
283
      when others => Report.Failed ("Exception raised in Test_Block");
284
   end Test_Block;
285
 
286
   Deletion:
287
   begin
288
      -- Delete the data file.
289
      if not Ada.Text_IO.Is_Open(Data_File) then
290
         Ada.Text_IO.Open(Data_File, Ada.Text_IO.In_File, Data_Filename);
291
      end if;
292
      Ada.Text_IO.Delete(Data_File);
293
 
294
   exception
295
      when others =>
296
         Report.Failed
297
            ( "Delete not properly implemented for Text_IO" );
298
 
299
   end Deletion;
300
 
301
   Report.Result;
302
 
303
exception
304
   when Incomplete =>
305
      Report.Result;
306
   when others     =>
307
      Report.Failed ( "Unexpected exception" );
308
      Report.Result;
309
 
310
end CXAC004;

powered by: WebSVN 2.1.0

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