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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxf/] [cxf3a07.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXF3A07.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 Ada.Text_IO.Editing.Put and Ada.Strings.Fixed.Move
28
--      have the same effect in putting edited output results into string
29
--      variables.
30
--
31
-- TEST DESCRIPTION:
32
--      This test is structured using tables of data, consisting of
33
--      numerical values, picture strings, and expected image
34
--      result strings.  These data tables are found in package FXF3A00.
35
--
36
--      The operation of the two above subprograms are examined twice, first
37
--      with the output of an edited output string to a receiving string
38
--      object of equal size, the other to a receiving string object of
39
--      larger size, where justification and padding are considered.
40
--      The procedure Editing.Put will place an edited output string into
41
--      a larger receiving string with right justification and blank fill.
42
--      Procedure Move has parameter control of justification and fill, and
43
--      in this test will mirror Put by specifying right justification and
44
--      blank fill.
45
--
46
--      In the cases where the edited output string is of shorter length
47
--      than the receiving string object, a blank-filled constant string
48
--      will be catenated to the front of the expected edited output string
49
--      for comparison with the receiving string object, enabling direct
50
--      string comparison for result verification.
51
--
52
-- TEST FILES:
53
--      The following files comprise this test:
54
--
55
--         FXF3A00.A   (foundation code)
56
--      => CXF3A07.A
57
--
58
--
59
-- CHANGE HISTORY:
60
--      30 JAN 95   SAIC    Initial prerelease version.
61
--      11 MAR 97   PWB.CTA Fixed string lengths
62
--!
63
 
64
with FXF3A00;
65
with Ada.Text_IO.Editing;
66
with Ada.Strings.Fixed;
67
with Report;
68
 
69
procedure CXF3A07 is
70
begin
71
 
72
   Report.Test ("CXF3A07", "Check that Ada.Text_IO.Editing.Put and "  &
73
                           "Ada.Strings.Fixed.Move have the same "    &
74
                           "effect in putting edited output results " &
75
                           "into string variables");
76
   Test_Block:
77
   declare
78
 
79
      use Ada.Text_IO;
80
 
81
      -- Instantiate the Decimal_Output generic package for two
82
      -- different decimal data types.
83
 
84
      package Pack_2DP is          -- Uses decimal type with delta 0.01.
85
        new Editing.Decimal_Output(FXF3A00.Decimal_Type_2DP);
86
 
87
      package Pack_NDP is          -- Uses decimal type with delta 1.0.
88
        new Editing.Decimal_Output(Num => FXF3A00.Decimal_Type_NDP,
89
                                   Default_Currency   => "$",
90
                                   Default_Fill       => '*',
91
                                   Default_Separator  => ',',
92
                                   Default_Radix_Mark => '.');
93
 
94
      TC_Picture     : Editing.Picture;
95
      TC_Start_Loop  : Integer := 0;
96
      TC_End_Loop    : Integer := 0;
97
      TC_Offset      : Integer := 0;
98
      TC_Length      : Natural := 0;
99
 
100
      TC_Put_String_20,                   -- Longer than the longest edited
101
      TC_Move_String_20 : String(1..20);  -- output string.
102
 
103
      TC_Put_String_17,                   -- Exact length of longest edited
104
      TC_Move_String_17 : String(1..17);  -- output string in 2DP-US data set.
105
 
106
      TC_Put_String_8,                    -- Exact length of longest edited
107
      TC_Move_String_8  : String(1..8);   -- output string in NDP-US data set.
108
 
109
 
110
   begin
111
 
112
      -- Examine cases where the output string is longer than the length
113
      -- of the edited output result.  Use the instantiation of
114
      -- Decimal_Output specific to data with two decimal places.
115
 
116
      TC_Start_Loop := 1;
117
      TC_End_Loop   := FXF3A00.Number_of_2DP_Items -              -- 10
118
                       FXF3A00.Number_Of_Foreign_Strings;
119
 
120
      for i in TC_Start_Loop..TC_End_Loop loop                    -- 1..10
121
 
122
         -- Create the picture object from the picture string.
123
 
124
         TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all,
125
                                          Blank_When_Zero => False);
126
 
127
         -- Determine the actual length of the edited output string
128
         -- that is expected from Put and Image.
129
 
130
         TC_Length := Pack_2DP.Length(Pic      => TC_Picture,
131
                                      Currency => "$");
132
 
133
         -- Determine the difference in length between the receiving string
134
         -- object and the expected length of the edited output string.
135
         -- Define a blank filled string constant with length equal to this
136
         -- length difference.
137
 
138
         declare
139
            TC_Length_Diff   : Integer := TC_Put_String_20'Length -
140
                                          TC_Length;
141
            TC_Buffer_String : constant String(1..TC_Length_Diff) :=
142
                                          (others => ' ');
143
         begin
144
 
145
            -- Fill the two receiving string objects with edited output,
146
            -- using the two different methods (Put and Move).
147
 
148
            Pack_2DP.Put(To         => TC_Put_String_20,
149
                         Item       => FXF3A00.Data_With_2DP(i),
150
                         Pic        => TC_Picture,
151
                         Currency   => "$",
152
                         Fill       => '*',
153
                         Separator  => ',',
154
                         Radix_Mark => '.');
155
 
156
 
157
            Ada.Strings.Fixed.Move
158
              (Source  => Pack_2DP.Image(Item => FXF3A00.Data_With_2DP(i),
159
                                         Pic        => TC_Picture,
160
                                         Currency   => "$",
161
                                         Fill       => '*',
162
                                         Separator  => ',',
163
                                         Radix_Mark => '.'),
164
               Target  => TC_Move_String_20,
165
               Drop    => Ada.Strings.Error,
166
               Justify => Ada.Strings.Right,
167
               Pad     => Ada.Strings.Space);
168
 
169
            -- Each receiving string object is now filled with the edited
170
            -- output result, right justified.
171
            -- Compare these two string objects with the expected edited
172
            -- output value, which is appended to the blank filled string
173
            -- whose length is the difference between the expected edited
174
            -- output length and the length of the receiving strings.
175
 
176
            if TC_Buffer_String & FXF3A00.Edited_Output(i).all  /=
177
               TC_Put_String_20                                    or
178
               TC_Buffer_String & FXF3A00.Edited_Output(i).all  /=
179
               TC_Move_String_20
180
            then
181
               Report.Failed("Failed case where the output string is " &
182
                             "longer than the length of the edited "   &
183
                             "output result, loop #" & Integer'Image(i));
184
            end if;
185
 
186
         exception
187
            when Layout_Error =>
188
               Report.Failed("Layout_Error raised when the output string " &
189
                             "is longer than the length of the edited "    &
190
                             "output result, loop #" & Integer'Image(i));
191
            when others       =>
192
               Report.Failed("Exception raised when the output string is " &
193
                             "longer than the length of the edited "       &
194
                             "output result, loop #" & Integer'Image(i));
195
         end;
196
      end loop;
197
 
198
 
199
      -- Repeat the above loop, but only evaluate three cases - those where
200
      -- the length of the expected edited output string is the exact length
201
      -- of the receiving strings (no justification will be required within
202
      -- the string.  This series of evaluations again uses decimal data
203
      -- with two decimal places.
204
 
205
      for i in TC_Start_Loop..TC_End_Loop loop                    -- 1..10
206
 
207
         case i is
208
            when 1 | 5 | 7 =>
209
 
210
               -- Create the picture object from the picture string.
211
               TC_Picture :=
212
                 Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
213
 
214
               -- Fill the two receiving string objects with edited output,
215
               -- using the two different methods (Put and Move).
216
               -- Use default parameters in the various calls where possible.
217
 
218
               Pack_2DP.Put(To         => TC_Put_String_17,
219
                            Item       => FXF3A00.Data_With_2DP(i),
220
                            Pic        => TC_Picture);
221
 
222
 
223
               Ada.Strings.Fixed.Move
224
                 (Source  => Pack_2DP.Image(Item => FXF3A00.Data_With_2DP(i),
225
                                            Pic  => TC_Picture),
226
                  Target  => TC_Move_String_17);
227
 
228
               -- Each receiving string object is now filled with the edited
229
               -- output result. Compare these two string objects with the
230
               -- expected edited output value.
231
 
232
               if FXF3A00.Edited_Output(i).all  /= TC_Put_String_17  or
233
                  FXF3A00.Edited_Output(i).all  /= TC_Move_String_17
234
               then
235
                  Report.Failed("Failed case where the output string is " &
236
                                "the exact length of the edited output "  &
237
                                "result, loop #" & Integer'Image(i));
238
               end if;
239
 
240
            when others => null;
241
         end case;
242
      end loop;
243
 
244
 
245
      -- Evaluate a mix of cases, where the expected edited output string
246
      -- length is either exactly as long or shorter than the receiving
247
      -- output string parameter.  This series of evaluations uses decimal
248
      -- data with no decimal places.
249
 
250
      TC_Start_Loop := TC_End_Loop + 1;                           -- 11
251
      TC_End_Loop   := TC_Start_Loop +                            -- 22
252
                       FXF3A00.Number_of_NDP_Items - 1;
253
      TC_Offset     := FXF3A00.Number_of_Foreign_Strings;         -- 10
254
      -- This offset is required due to the arrangement of data within the
255
      -- tables found in FXF3A00.
256
 
257
      for i in TC_Start_Loop..TC_End_Loop loop                    -- 11..22
258
 
259
         -- Create the picture object from the picture string.
260
 
261
         TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
262
 
263
         -- Determine the actual length of the edited output string
264
         -- that is expected from Put and Image.
265
 
266
         TC_Length := Pack_NDP.Length(TC_Picture);
267
 
268
         -- Fill the two receiving string objects with edited output,
269
         -- using the two different methods (Put and Move).
270
 
271
         Pack_NDP.Put(TC_Put_String_8,
272
                      FXF3A00.Data_With_NDP(i-TC_Offset),
273
                      TC_Picture);
274
 
275
         Ada.Strings.Fixed.Move
276
           (Pack_NDP.Image(FXF3A00.Data_With_NDP(i-TC_Offset), TC_Picture),
277
            TC_Move_String_8,
278
            Ada.Strings.Error,
279
            Ada.Strings.Right,
280
            Ada.Strings.Space);
281
 
282
         -- Determine if there is a difference in length between the
283
         -- receiving string object and the expected length of the edited
284
         -- output string.  If so, then define a blank filled string constant
285
         -- with length equal to this length difference.
286
 
287
         if TC_Length < TC_Put_String_8'Length then
288
            declare
289
               TC_Length_Diff   : Integer := TC_Put_String_8'Length -
290
                                             TC_Length;
291
               TC_Buffer_String : constant String(1..TC_Length_Diff) :=
292
                                          (others => ' ');
293
            begin
294
 
295
               -- Each receiving string object is now filled with the edited
296
               -- output result, right justified.
297
               -- Compare these two string objects with the expected edited
298
               -- output value, which is appended to the blank filled string
299
               -- whose length is the difference between the expected edited
300
               -- output length and the length of the receiving strings.
301
 
302
               if TC_Buffer_String & FXF3A00.Edited_Output(i+TC_Offset).all /=
303
                  TC_Put_String_8                                           or
304
                  TC_Buffer_String & FXF3A00.Edited_Output(i+TC_Offset).all /=
305
                  TC_Move_String_8
306
               then
307
                  Report.Failed("Failed case where the output string is "  &
308
                                "longer than the length of the edited "    &
309
                                "output result, loop #" & Integer'Image(i) &
310
                                ", using data with no decimal places");
311
               end if;
312
            end;
313
         else
314
 
315
            -- Compare these two string objects with the expected edited
316
            -- output value, which is appended to the blank filled string
317
            -- whose length is the difference between the expected edited
318
            -- output length and the length of the receiving strings.
319
 
320
            if FXF3A00.Edited_Output(i+TC_Offset).all /= TC_Put_String_8 or
321
               FXF3A00.Edited_Output(i+TC_Offset).all /= TC_Move_String_8
322
            then
323
               Report.Failed("Failed case where the output string is "  &
324
                             "the same length as the edited output "    &
325
                             "result, loop #" & Integer'Image(i)        &
326
                             ", using data with no decimal places");
327
            end if;
328
         end if;
329
      end loop;
330
 
331
   exception
332
      when others => Report.Failed("Exception raised in Test_Block");
333
   end Test_Block;
334
 
335
   Report.Result;
336
 
337
end CXF3A07;

powered by: WebSVN 2.1.0

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