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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXF3A02.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 function Ada.Text_IO.Editing.To_Picture raises
28
--      Picture_Error if the picture string provided as input parameter does
29
--      not conform to the composition constraints defined for picture
30
--      strings.
31
--      Check that when Pic_String is applied to To_Picture, the result
32
--      is equivalent to the actual string parameter of To_Picture;
33
--      Check that when Blank_When_Zero is applied to To_Picture, the result
34
--      is the same value as the Blank_When_Zero parameter of To_Picture.
35
--
36
-- TEST DESCRIPTION:
37
--      This test validates that function Editing.To_Picture returns a
38
--      Picture result when provided a valid picture string, and raises a
39
--      Picture_Error exception when provided an invalid picture string
40
--      input parameter.  In addition, the Picture result of To_Picture is
41
--      converted back to a picture string value using function Pic_String,
42
--      and the result of function Blank_When_Zero is validated based on the
43
--      value of parameter Blank_When_Zero used in the formation of the Picture
44
--      by function To_Picture.
45
--
46
-- TEST FILES:
47
--      The following files comprise this test:
48
--
49
--         FXF3A00.A   (foundation code)
50
--      => CXF3A02.A
51
--
52
--
53
-- CHANGE HISTORY:
54
--      06 Dec 94   SAIC    ACVC 2.0
55
--      11 Mar 97   PWB.CTA Corrected invalid picture string and uppercase
56
--                          problem.
57
--!
58
 
59
with FXF3A00;
60
with Ada.Text_IO.Editing;
61
with Ada.Strings.Maps;
62
with Ada.Strings.Fixed;
63
with Report;
64
 
65
procedure CXF3A02 is
66
 
67
   Lower_Alpha : constant String := "abcdefghijklmnopqrstuvwxyz";
68
   Upper_Alpha : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
69
   function UpperCase ( Source : String ) return String is
70
   begin
71
      return
72
         Ada.Strings.Fixed.Translate
73
            ( Source  => Source,
74
              Mapping => Ada.Strings.Maps.To_Mapping
75
                            ( From => Lower_Alpha,
76
                              To => Upper_Alpha ) );
77
   end UpperCase;
78
 
79
begin
80
 
81
   Report.Test ("CXF3A02", "Check that the function "                       &
82
                           "Ada.Text_IO.Editing.To_Picture raises "         &
83
                           "Picture_Error if the picture string provided "  &
84
                           "as input parameter does not conform to the "    &
85
                           "composition constraints defined for picture "   &
86
                           "strings");
87
 
88
   Test_Block:
89
   declare
90
 
91
      use Ada.Text_IO;
92
      use FXF3A00;
93
 
94
      TC_Picture         : Editing.Picture;
95
      TC_Blank_When_Zero : Boolean;
96
 
97
   begin
98
 
99
 
100
      -- Validate that function To_Picture does not raise Picture_Error when
101
      -- provided a valid picture string as an input parameter.
102
 
103
      for i in 1..FXF3A00.Number_Of_Valid_Strings loop
104
         begin
105
            TC_Picture :=
106
              Editing.To_Picture(Pic_String      => Valid_Strings(i).all,
107
                                 Blank_When_Zero => False );
108
         exception
109
            when Editing.Picture_Error =>
110
              Report.Failed
111
              ("Picture_Error raised by function To_Picture "     &
112
               "with a valid picture string as input parameter, " &
113
               "Valid_String = " & FXF3A00.Valid_Strings(i).all);
114
            when others =>
115
              Report.Failed("Unexpected exception raised - 1, " &
116
                            "Valid_String = " & FXF3A00.Valid_Strings(i).all);
117
         end;
118
      end loop;
119
 
120
 
121
 
122
      -- Validate that function To_Picture raises Picture_Error when an
123
      -- invalid picture string is provided as an input parameter.
124
      -- Default value used for parameter Blank_When_Zero.
125
 
126
      for i in 1..FXF3A00.Number_Of_Invalid_Strings loop
127
         begin
128
            TC_Picture :=
129
              Editing.To_Picture(Pic_String => FXF3A00.Invalid_Strings(i).all);
130
            Report.Failed
131
              ("Picture_Error not raised by function To_Picture "    &
132
               "with an invalid picture string as input parameter, " &
133
               "Invalid_String = " & FXF3A00.Invalid_Strings(i).all);
134
         exception
135
            when Editing.Picture_Error => null;  -- OK, expected exception.
136
            when others                =>
137
              Report.Failed("Unexpected exception raised, " &
138
                            "Invalid_String = "             &
139
                            FXF3A00.Invalid_Strings(i).all);
140
         end;
141
      end loop;
142
 
143
 
144
 
145
      -- Validate that To_Picture and Pic_String/Blank_When_Zero provide
146
      -- "inverse" results.
147
 
148
      -- Use the default value of the Blank_When_Zero parameter (False) for
149
      -- these evaluations (some valid strings have the '*' zero suppression
150
      -- character, which would result in an invalid string if used with a
151
      -- True value for the Blank_When_Zero parameter).
152
 
153
      for i in 1..FXF3A00.Number_Of_Valid_Strings loop
154
         begin
155
 
156
            -- Format a picture string using function To_Picture.
157
 
158
            TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
159
 
160
            -- Reconvert the Picture result from To_Picture to a string value
161
            -- using function Pic_String, and compare to the original string.
162
 
163
            if Editing.Pic_String(Pic => TC_Picture) /=
164
               Uppercase (FXF3A00.Valid_Strings(i).all)
165
            then
166
               Report.Failed
167
                 ("Inverse result incorrect from Editing.Pic_String, " &
168
                  "Valid_String = " & FXF3A00.Valid_Strings(i).all);
169
            end if;
170
 
171
            -- Ensure that function Blank_When_Zero returns the correct value
172
            -- of the Blank_When_Zero parameter used in forming the Picture
173
            -- (default parameter value False used in call to To_Picture
174
            -- above).
175
 
176
            if Editing.Blank_When_Zero(Pic => TC_Picture) then
177
               Report.Failed
178
                 ("Inverse result incorrect from Editing.Blank_When_Zero, " &
179
                  "Valid_String = " & FXF3A00.Valid_Strings(i).all);
180
            end if;
181
 
182
         exception
183
            when others =>
184
              Report.Failed("Unexpected exception raised - 2, " &
185
                            "Valid_String = " & FXF3A00.Valid_Strings(i).all);
186
         end;
187
      end loop;
188
 
189
 
190
      -- Specifically check that any lower case letters in the original
191
      -- picture string have been converted to upper case form following
192
      -- the To_Picture/Pic_String conversion (as shown in previous loop).
193
 
194
      declare
195
         The_Picture         : Editing.Picture;
196
         The_Picture_String  : constant String := "+bBbZz_zZz_Zz9.99";
197
         The_Expected_Result : constant String := "+BBBZZ_ZZZ_ZZ9.99";
198
      begin
199
         -- Convert Picture String to Picture.
200
         The_Picture := Editing.To_Picture(Pic_String => The_Picture_String);
201
 
202
         declare
203
            -- Reconvert the Picture to a Picture String.
204
            The_Result : constant String := Editing.Pic_String(The_Picture);
205
         begin
206
            if The_Result /= The_Expected_Result then
207
               Report.Failed("Conversion to Picture/Reconversion to String " &
208
                             "did not produce expected result when Picture " &
209
                             "String had lower case letters");
210
            end if;
211
         end;
212
      end;
213
 
214
 
215
      -- Use a value of True for the Blank_When_Zero parameter for the
216
      -- following evaluations (picture strings that do not have the '*' zero
217
      -- suppression character, which would result in an invalid string when
218
      -- used here with a True value for the Blank_When_Zero parameter).
219
 
220
      for i in 3..24 loop
221
         begin
222
 
223
            -- Format a picture string using function To_Picture.
224
 
225
            TC_Picture :=
226
              Editing.To_Picture(Pic_String      => Valid_Strings(i).all,
227
                                 Blank_When_Zero => True);
228
 
229
            -- Reconvert the Picture result from To_Picture to a string value
230
            -- using function Pic_String, and compare to the original string.
231
 
232
            if Editing.Pic_String(Pic => TC_Picture) /=
233
               UpperCase (FXF3A00.Valid_Strings(i).all)
234
            then
235
               Report.Failed
236
                 ("Inverse result incorrect from Editing.Pic_String, used "   &
237
                  "on Picture formed with parameter Blank_When_Zero = True, " &
238
                  "Valid_String = " & FXF3A00.Valid_Strings(i).all);
239
            end if;
240
 
241
            -- Ensure that function Blank_When_Zero returns the correct value
242
            -- of the Blank_When_Zero parameter used in forming the Picture
243
            -- (default parameter value False overridden in call to
244
            -- To_Picture above).
245
 
246
            if not Editing.Blank_When_Zero(Pic => TC_Picture) then
247
               Report.Failed
248
                 ("Inverse result incorrect from Editing.Blank_When_Zero, "  &
249
                  "used on a Picture formed with parameter Blank_When_Zero " &
250
                  "= True, Valid_String = " & FXF3A00.Valid_Strings(i).all);
251
            end if;
252
 
253
         exception
254
            when others =>
255
              Report.Failed("Unexpected exception raised - 3, " &
256
                            "Valid_String = " & FXF3A00.Valid_Strings(i).all);
257
         end;
258
      end loop;
259
 
260
 
261
   exception
262
      when others => Report.Failed ("Exception raised in Test_Block");
263
   end Test_Block;
264
 
265
   Report.Result;
266
 
267
end CXF3A02;

powered by: WebSVN 2.1.0

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