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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXF3003.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 statically identifiable picture strings can be used to
28
--      produce correctly formatted edited output.
29
--
30
-- TEST DESCRIPTION:
31
--      This test defines several picture strings that are statically
32
--      identifiable, (i.e.,  Pic : Picture := To_Picture("..."); ).
33
--      These picture strings are used in conjunction with decimal data
34
--      as parameters in calls to functions Valid and Image.  These
35
--      functions are created by an instantiation of the generic package
36
--      Ada.Text_IO.Editing.Decimal_Output.
37
--
38
--
39
-- CHANGE HISTORY:
40
--      04 Apr 96   SAIC    Initial release for 2.1.
41
--      13 Feb 97   PWB.CTA corrected incorrect picture strings.
42
--!
43
 
44
with Report;
45
with Ada.Text_IO.Editing;
46
with Ada.Exceptions;
47
 
48
procedure CXF3003 is
49
begin
50
 
51
   Report.Test ("CXF3003", "Check that statically identifiable "     &
52
                           "picture strings can be used to produce " &
53
                           "correctly formatted edited output");
54
 
55
   Test_Block:
56
   declare
57
 
58
      use Ada.Exceptions;
59
      use Ada.Text_IO.Editing;
60
 
61
      Def_Cur   : constant String    := "$";
62
      Def_Fill  : constant Character := '*';
63
      Def_Sep   : constant Character := Default_Separator;
64
      Def_Radix : constant Character :=
65
                    Ada.Text_IO.Editing.Default_Radix_Mark;
66
 
67
      type Str_Ptr is access String;
68
      type Edited_Output_Array_Type is array (Integer range <>) of Str_Ptr;
69
 
70
      -- Define a decimal data type, and instantiate the Decimal_Output
71
      -- generic package for the data type.
72
 
73
      type Decimal_Data_Type is delta 0.01 digits 16;
74
 
75
      package Image_IO is
76
        new Decimal_Output(Num                => Decimal_Data_Type,
77
                           Default_Currency   => Def_Cur,
78
                           Default_Fill       => '*',
79
                           Default_Separator  => Default_Separator,
80
                           Default_Radix_Mark => Def_Radix);
81
 
82
 
83
      type Decimal_Data_Array_Type is
84
        array (Integer range <>) of Decimal_Data_Type;
85
 
86
      Decimal_Data : Decimal_Data_Array_Type(1..5) :=
87
          (1 =>  1357.99,
88
           2 => -9029.01,
89
           3 =>     0.00,
90
           4 =>     0.20,
91
           5 =>     3.45);
92
 
93
      -- Statically identifiable picture strings.
94
 
95
      Picture_1  : Picture := To_Picture("-$$_$$9.99");
96
      Picture_2  : Picture := To_Picture("-$$_$$$.$$");
97
      Picture_3  : Picture := To_Picture("-ZZZZ.ZZ");
98
      Picture_5  : Picture := To_Picture("-$$$_999.99");
99
      Picture_6  : Picture := To_Picture("-###**_***_**9.99");
100
      Picture_7  : Picture := To_Picture("-$**_***_**9.99");
101
      Picture_8  : Picture := To_Picture("-$$$$$$.$$");
102
      Picture_9  : Picture := To_Picture("-$$$$$$.$$");
103
      Picture_10 : Picture := To_Picture("+BBBZZ_ZZZ_ZZZ.ZZ");
104
      Picture_11 : Picture := To_Picture("--_---_---_--9");
105
      Picture_12 : Picture := To_Picture("-$_$$$_$$$_$$9.99");
106
      Picture_14 : Picture := To_Picture("$_$$9.99");
107
      Picture_15 : Picture := To_Picture("$$9.99");
108
 
109
 
110
      Picture_1_Output : Edited_Output_Array_Type(1..5) :=
111
          ( 1 => new String'(" $1,357.99"),
112
            2 => new String'("-$9,029.01"),
113
            3 => new String'("     $0.00"),
114
            4 => new String'("     $0.20"),
115
            5 => new String'("     $3.45"));
116
 
117
      Picture_2_Output : Edited_Output_Array_Type(1..5) :=
118
           (1 => new String'(" $1,357.99"),
119
            2 => new String'("-$9,029.01"),
120
            3 => new String'("          "),
121
            4 => new String'("      $.20"),
122
            5 => new String'("     $3.45"));
123
 
124
      Picture_3_Output : Edited_Output_Array_Type(1..5) :=
125
           (1 => new String'(" 1357.99"),
126
            2 => new String'("-9029.01"),
127
            3 => new String'("        "),
128
            4 => new String'("     .20"),
129
            5 => new String'("    3.45"));
130
 
131
      Picture_5_Output : Edited_Output_Array_Type(1..5) :=
132
           (1 => new String'("  $1,357.99"),
133
            2 => new String'("- $9,029.01"),
134
            3 => new String'("   $ 000.00"),
135
            4 => new String'("   $ 000.20"),
136
            5 => new String'("   $ 003.45"));
137
 
138
   begin
139
 
140
      -- Check the results of function Valid, using the first five decimal
141
      -- data items and picture strings.
142
 
143
      if not Image_IO.Valid(Decimal_Data(1), Picture_1) then
144
         Report.Failed("Picture string 1 not valid");
145
      elsif not Image_IO.Valid(Decimal_Data(2), Picture_2) then
146
         Report.Failed("Picture string 2 not valid");
147
      elsif not Image_IO.Valid(Decimal_Data(3), Picture_3) then
148
         Report.Failed("Picture string 3 not valid");
149
      elsif not Image_IO.Valid(Decimal_Data(5), Picture_5) then
150
         Report.Failed("Picture string 5 not valid");
151
      end if;
152
 
153
 
154
      -- Check the results of function Image, using the picture strings
155
      -- constructed above, with a variety of named vs. positional
156
      -- parameter notation and defaulted parameters.
157
 
158
      for i in 1..5 loop
159
         if Image_IO.Image(Item => Decimal_Data(i), Pic => Picture_1) /=
160
            Picture_1_Output(i).all
161
         then
162
            Report.Failed("Incorrect result from function Image with "    &
163
                          "decimal data item #" & Integer'Image(i) & ", " &
164
                          "combined with Picture_1 picture string."       &
165
                          "Expected: " & Picture_1_Output(i).all & ", "   &
166
                          "Found: " &
167
                          Image_IO.Image(Decimal_Data(i),Picture_1));
168
         end if;
169
 
170
         if Image_IO.Image(Decimal_Data(i), Pic => Picture_2) /=
171
            Picture_2_Output(i).all
172
         then
173
            Report.Failed("Incorrect result from function Image with "    &
174
                          "decimal data item #" & Integer'Image(i) & ", " &
175
                          "combined with Picture_2 picture string."       &
176
                          "Expected: " & Picture_2_Output(i).all & ", "   &
177
                          "Found: " &
178
                          Image_IO.Image(Decimal_Data(i),Picture_2));
179
         end if;
180
 
181
         if Image_IO.Image(Decimal_Data(i), Picture_3) /=
182
            Picture_3_Output(i).all
183
         then
184
            Report.Failed("Incorrect result from function Image with "    &
185
                          "decimal data item #" & Integer'Image(i) & ", " &
186
                          "combined with Picture_3 picture string."       &
187
                          "Expected: " & Picture_3_Output(i).all & ", "   &
188
                          "Found: " &
189
                          Image_IO.Image(Decimal_Data(i),Picture_3));
190
         end if;
191
 
192
         if Image_IO.Image(Decimal_Data(i), Picture_5) /=
193
            Picture_5_Output(i).all
194
         then
195
            Report.Failed("Incorrect result from function Image with "    &
196
                          "decimal data item #" & Integer'Image(i) & ", " &
197
                          "combined with Picture_5 picture string."       &
198
                          "Expected: " & Picture_5_Output(i).all & ", "   &
199
                          "Found: " &
200
                          Image_IO.Image(Decimal_Data(i),Picture_5));
201
         end if;
202
      end loop;
203
 
204
 
205
      if Image_IO.Image(Item       => 123456.78,
206
                        Pic        => Picture_6,
207
                        Currency   => "$",
208
                        Fill       => Def_Fill,
209
                        Separator  => Def_Sep,
210
                        Radix_Mark => Def_Radix) /= "   $***123,456.78"
211
      then
212
         Report.Failed("Incorrect result from Fn. Image using Picture_6");
213
      end if;
214
 
215
      if Image_IO.Image(123456.78,
216
                        Pic        => Picture_7,
217
                        Currency   => Def_Cur,
218
                        Fill       => '*',
219
                        Separator  => Def_Sep,
220
                        Radix_Mark => Def_Radix) /= " $***123,456.78"
221
      then
222
         Report.Failed("Incorrect result from Fn. Image using Picture_7");
223
      end if;
224
 
225
      if Image_IO.Image(0.0,
226
                        Picture_8,
227
                        Currency   => "$",
228
                        Fill       => '*',
229
                        Separator  => Def_Sep,
230
                        Radix_Mark => Def_Radix) /= "          "
231
      then
232
         Report.Failed("Incorrect result from Fn. Image using Picture_8");
233
      end if;
234
 
235
      if Image_IO.Image(0.20,
236
                        Picture_9,
237
                        Def_Cur,
238
                        Fill       => Def_Fill,
239
                        Separator  => Default_Separator,
240
                        Radix_Mark => Default_Radix_Mark) /= "      $.20"
241
      then
242
         Report.Failed("Incorrect result from Fn. Image using Picture_9");
243
      end if;
244
 
245
      if Image_IO.Image(123456.00,
246
                        Picture_10,
247
                        "$",
248
                        '*',
249
                        Separator  => Def_Sep,
250
                        Radix_Mark => Def_Radix) /= "+      123,456.00"
251
      then
252
         Report.Failed("Incorrect result from Fn. Image using Picture_10");
253
      end if;
254
 
255
      if Image_IO.Image(-123456.78,
256
                        Picture_11,
257
                        Default_Currency,
258
                        Default_Fill,
259
                        Default_Separator,
260
                        Radix_Mark => Def_Radix) /= "      -123,457"
261
      then
262
         Report.Failed("Incorrect result from Fn. Image using Picture_11");
263
      end if;
264
 
265
      if Image_IO.Image(123456.78, Picture_12, "$", '*', ',', '.') /=
266
         "      $123,456.78"
267
      then
268
         Report.Failed("Incorrect result from Fn. Image using Picture_12");
269
      end if;
270
 
271
      if Image_IO.Image(1.23,
272
                        Picture_14,
273
                        Currency => Def_Cur,
274
                        Fill     => Def_Fill) /= "   $1.23"
275
      then
276
         Report.Failed("Incorrect result from Fn. Image using Picture_14");
277
      end if;
278
 
279
      if Image_IO.Image(12.34, Pic => Picture_15) /= "$12.34"
280
      then
281
         Report.Failed("Incorrect result from Fn. Image using Picture_15");
282
      end if;
283
 
284
   exception
285
      when The_Error : others =>
286
         Report.Failed("The following exception was raised in the " &
287
                       "Test_Block: " & Exception_Name(The_Error));
288
   end Test_Block;
289
 
290
   Report.Result;
291
 
292
end CXF3003;

powered by: WebSVN 2.1.0

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