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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXF3A04.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 edited output string value returned by Function Image
28
--      is correct.
29
--
30
-- TEST DESCRIPTION:
31
--      This test is structured using tables of data, consisting of
32
--      numerical values, picture strings, and expected image
33
--      result strings.  These data tables are found in package FXF3A00.
34
--
35
--      The results of the Image function are examined under a number of
36
--      circumstances.  The generic package Decimal_Output is instantiated
37
--      twice, for decimal data with delta 0.01 and delta 1.0.  Each version
38
--      of Image is called with both default parameters and user-provided
39
--      parameters.  The results of each call to Image are compared to an
40
--      expected edited output result string.
41
--
42
--      In addition, three calls to Image are designed to raise Layout_Error,
43
--      due to the combination of decimal value and picture string provided
44
--      as input parameters.  If Layout_Error is not raised, or an alternate
45
--      exception is raised instead, test failure results.
46
--
47
-- TEST FILES:
48
--      The following files comprise this test:
49
--
50
--         FXF3A00.A   (foundation code)
51
--      => CXF3A04.A
52
--
53
--
54
-- CHANGE HISTORY:
55
--      22 JAN 95   SAIC    Initial prerelease version.
56
--      11 MAR 97   PWB.CTA Corrected incorrect index expression
57
--!
58
 
59
with FXF3A00;
60
with Ada.Text_IO.Editing;
61
with Report;
62
 
63
procedure CXF3A04 is
64
begin
65
 
66
   Report.Test ("CXF3A04", "Check that the string value returned by " &
67
                           "Function Image is correct, based on the " &
68
                           "numerical data and picture formatting "   &
69
                           "parameters provided to the function");
70
 
71
   Test_Block:
72
   declare
73
 
74
      use Ada.Text_IO;
75
 
76
      -- Instantiate the Decimal_Output generic package for the two data
77
      -- types, using the default values for the Default_Currency,
78
      -- Default_Fill, Default_Separator, and Default_Radix_Mark
79
      -- parameters.
80
 
81
      package Pack_NDP is
82
        new Editing.Decimal_Output (FXF3A00.Decimal_Type_NDP);
83
 
84
      package Pack_2DP is
85
        new Editing.Decimal_Output (FXF3A00.Decimal_Type_2DP);
86
 
87
      TC_Currency   : constant String    := "$";
88
      TC_Fill       : constant Character := '*';
89
      TC_Separator  : constant Character := ',';
90
      TC_Radix_Mark : constant Character := '.';
91
 
92
      TC_Picture    : Editing.Picture;
93
 
94
 
95
   begin
96
 
97
      Two_Decimal_Place_Data:
98
      -- Use a decimal fixed point type with delta 0.01 (two decimal places)
99
      -- and valid picture strings. Evaluate the result of function Image
100
      -- with the expected edited output result string.
101
      declare
102
 
103
         TC_Loop_End : constant :=                                     -- 10
104
           FXF3A00.Number_Of_2DP_Items - FXF3A00.Number_Of_Foreign_Strings;
105
 
106
      begin
107
         -- The first 10 picture strings in the Valid_Strings array
108
         -- correspond to data values of a decimal type with delta 0.01.
109
 
110
         -- Compare string result of Image with expected edited output
111
         -- string.  Evaluate data using both default parameters of Image
112
         -- and user-provided parameter values.
113
         for i in 1..TC_Loop_End loop
114
 
115
            -- Create the picture object from the picture string.
116
            TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
117
 
118
            -- Use the default parameters for this loop evaluation of Image.
119
            if Pack_2DP.Image(FXF3A00.Data_With_2DP(i), TC_Picture) /=
120
               FXF3A00.Edited_Output(i).all
121
            then
122
               Report.Failed("Incorrect result from Function Image, "    &
123
                             "when used with a decimal type with delta " &
124
                             "0.01, picture string "                     &
125
                             FXF3A00.Valid_Strings(i).all                &
126
                             ", and the default parameters of Image");
127
            end if;
128
 
129
            -- Use user-provided parameters for this loop evaluation of Image.
130
 
131
            if Pack_2DP.Image(Item       => FXF3A00.Data_With_2DP(i),
132
                              Pic        => TC_Picture,
133
                              Currency   => TC_Currency,
134
                              Fill       => TC_Fill,
135
                              Separator  => TC_Separator,
136
                              Radix_Mark => TC_Radix_Mark) /=
137
               FXF3A00.Edited_Output(i).all
138
            then
139
               Report.Failed("Incorrect result from Function Image, "    &
140
                             "when used with a decimal type with delta " &
141
                             "0.01, picture string "                     &
142
                             FXF3A00.Valid_Strings(i).all                &
143
                             ", and user-provided parameters");
144
            end if;
145
 
146
         end loop;
147
 
148
      exception
149
         when others =>
150
           Report.Failed("Exception raised in Two_Decimal_Place_Data block");
151
      end Two_Decimal_Place_Data;
152
 
153
 
154
 
155
      No_Decimal_Place_Data:
156
      -- Use a decimal fixed point type with delta 1.00 (no decimal places)
157
      -- and valid picture strings. Evaluate the result of function Image
158
      -- with the expected result string.
159
      declare
160
 
161
         use Editing, FXF3A00;
162
 
163
         TC_Offset     : constant := 10;
164
         TC_Loop_Start : constant := TC_Offset + 1;                   -- 11
165
         TC_Loop_End   : constant := TC_Loop_Start +
166
                                     Number_Of_NDP_Items - 1;         -- 22
167
 
168
      begin
169
         -- The following evaluations correspond to data values of a
170
         -- decimal type with delta 1.0.
171
 
172
         -- Compare string result of Image with expected edited output
173
         -- string.  Evaluate data using both default parameters of Image
174
         -- and user-provided parameter values.
175
         -- Note: TC_Offset is used to align corresponding data the various
176
         --       data tables in foundation package FXF3A00.
177
 
178
         for i in TC_Loop_Start..TC_Loop_End loop
179
 
180
            -- Create the picture object from the picture string.
181
            TC_Picture := To_Picture(Valid_Strings(i).all);
182
 
183
            -- Use the default parameters for this loop evaluation of Image.
184
            if not (Pack_NDP.Image(Data_With_NDP(i-TC_Offset), TC_Picture) =
185
                    Edited_Output(TC_Offset+i).all)
186
            then
187
               Report.Failed("Incorrect result from Function Image, "    &
188
                             "when used with a decimal type with delta " &
189
                             "1.0, picture string "                      &
190
                             Valid_Strings(i).all                        &
191
                             ", and the default parameters of Image");
192
            end if;
193
 
194
            -- Use user-provided parameters for this loop evaluation of Image.
195
            if Pack_NDP.Image(Item       => Data_With_NDP(i - TC_Offset),
196
                              Pic        => TC_Picture,
197
                              Currency   => TC_Currency,
198
                              Fill       => TC_Fill,
199
                              Separator  => TC_Separator,
200
                              Radix_Mark => TC_Radix_Mark) /=
201
               Edited_Output(TC_Offset+i).all
202
            then
203
               Report.Failed("Incorrect result from Function Image, "    &
204
                             "when used with a decimal type with delta " &
205
                             "1.0, picture string "                      &
206
                             Valid_Strings(i).all                        &
207
                             ", and user-provided parameters");
208
            end if;
209
 
210
         end loop;
211
 
212
      exception
213
         when others =>
214
           Report.Failed("Exception raised in No_Decimal_Place_Data block");
215
      end No_Decimal_Place_Data;
216
 
217
 
218
 
219
      Exception_Block:
220
      -- The following three calls of Function Image, using the specific
221
      -- decimal values and picture strings provided, will cause
222
      -- a Layout_Error to be raised.
223
      -- The first two evaluations use the instantiation of Decimal_Output
224
      -- with a decimal type with delta 0.01, while the last evaluation
225
      -- uses the instantiation with decimal type with delta 1.0.
226
 
227
      -- Note: The data and the picture strings used in the following
228
      --       evaluations are not themselves erroneous, but when used in
229
      --       combination will cause Layout_Error to be raised.
230
 
231
      begin
232
 
233
         for i in 1..FXF3A00.Number_Of_Erroneous_Conditions loop    -- 1..3
234
            begin
235
               -- Create the picture object from the picture string.
236
               TC_Picture :=
237
                 Editing.To_Picture(FXF3A00.Erroneous_Strings(i).all);
238
 
239
               -- Layout_Error must be raised by the following calls to
240
               -- Function Image.
241
 
242
               if i < 3 then  -- Choose the appropriate instantiation.
243
                  declare
244
                     N : constant Natural := Pack_2DP.Length(TC_Picture);
245
                     TC_String : String(1..N);
246
                  begin
247
                     TC_String := Pack_2DP.Image(FXF3A00.Erroneous_Data(i),
248
                                                 TC_Picture);
249
                  end;
250
               else
251
                  declare
252
                     use FXF3A00;
253
                     N : constant Natural := Pack_NDP.Length(TC_Picture,
254
                                                             TC_Currency);
255
                     TC_String : String(1..N);
256
                  begin
257
                     TC_String :=
258
                       Pack_NDP.Image(Item       => Decimal_Type_NDP(
259
                                                      Erroneous_Data(i)),
260
                                      Pic        => TC_Picture,
261
                                      Currency   => TC_Currency,
262
                                      Fill       => TC_Fill,
263
                                      Separator  => TC_Separator,
264
                                      Radix_Mark => TC_Radix_Mark);
265
                  end;
266
               end if;
267
 
268
               Report.Failed("Layout_Error not raised by combination "  &
269
                             "# " & Integer'Image(i) & " "              &
270
                             "of decimal data and picture string");
271
 
272
            exception
273
               when Layout_Error => null;    -- Expected exception.
274
               when others       =>
275
                 Report.Failed("Incorrect exception raised by combination " &
276
                               "# " & Integer'Image(i) & " "                &
277
                               "of decimal data and picture string");
278
            end;
279
         end loop;
280
 
281
      exception
282
         when others =>
283
           Report.Failed("Unexpected exception raised in Exception_Block");
284
      end Exception_Block;
285
 
286
 
287
   exception
288
      when others => Report.Failed ("Exception raised in Test_Block");
289
   end Test_Block;
290
 
291
   Report.Result;
292
 
293
end CXF3A04;

powered by: WebSVN 2.1.0

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