annotate gcc/testsuite/ada/acats/tests/cxf/cxf3a02.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CXF3A02.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that the function Ada.Text_IO.Editing.To_Picture raises
kono
parents:
diff changeset
28 -- Picture_Error if the picture string provided as input parameter does
kono
parents:
diff changeset
29 -- not conform to the composition constraints defined for picture
kono
parents:
diff changeset
30 -- strings.
kono
parents:
diff changeset
31 -- Check that when Pic_String is applied to To_Picture, the result
kono
parents:
diff changeset
32 -- is equivalent to the actual string parameter of To_Picture;
kono
parents:
diff changeset
33 -- Check that when Blank_When_Zero is applied to To_Picture, the result
kono
parents:
diff changeset
34 -- is the same value as the Blank_When_Zero parameter of To_Picture.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- TEST DESCRIPTION:
kono
parents:
diff changeset
37 -- This test validates that function Editing.To_Picture returns a
kono
parents:
diff changeset
38 -- Picture result when provided a valid picture string, and raises a
kono
parents:
diff changeset
39 -- Picture_Error exception when provided an invalid picture string
kono
parents:
diff changeset
40 -- input parameter. In addition, the Picture result of To_Picture is
kono
parents:
diff changeset
41 -- converted back to a picture string value using function Pic_String,
kono
parents:
diff changeset
42 -- and the result of function Blank_When_Zero is validated based on the
kono
parents:
diff changeset
43 -- value of parameter Blank_When_Zero used in the formation of the Picture
kono
parents:
diff changeset
44 -- by function To_Picture.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- TEST FILES:
kono
parents:
diff changeset
47 -- The following files comprise this test:
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- FXF3A00.A (foundation code)
kono
parents:
diff changeset
50 -- => CXF3A02.A
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- CHANGE HISTORY:
kono
parents:
diff changeset
54 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
55 -- 11 Mar 97 PWB.CTA Corrected invalid picture string and uppercase
kono
parents:
diff changeset
56 -- problem.
kono
parents:
diff changeset
57 --!
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 with FXF3A00;
kono
parents:
diff changeset
60 with Ada.Text_IO.Editing;
kono
parents:
diff changeset
61 with Ada.Strings.Maps;
kono
parents:
diff changeset
62 with Ada.Strings.Fixed;
kono
parents:
diff changeset
63 with Report;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure CXF3A02 is
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 Lower_Alpha : constant String := "abcdefghijklmnopqrstuvwxyz";
kono
parents:
diff changeset
68 Upper_Alpha : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
kono
parents:
diff changeset
69 function UpperCase ( Source : String ) return String is
kono
parents:
diff changeset
70 begin
kono
parents:
diff changeset
71 return
kono
parents:
diff changeset
72 Ada.Strings.Fixed.Translate
kono
parents:
diff changeset
73 ( Source => Source,
kono
parents:
diff changeset
74 Mapping => Ada.Strings.Maps.To_Mapping
kono
parents:
diff changeset
75 ( From => Lower_Alpha,
kono
parents:
diff changeset
76 To => Upper_Alpha ) );
kono
parents:
diff changeset
77 end UpperCase;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 begin
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 Report.Test ("CXF3A02", "Check that the function " &
kono
parents:
diff changeset
82 "Ada.Text_IO.Editing.To_Picture raises " &
kono
parents:
diff changeset
83 "Picture_Error if the picture string provided " &
kono
parents:
diff changeset
84 "as input parameter does not conform to the " &
kono
parents:
diff changeset
85 "composition constraints defined for picture " &
kono
parents:
diff changeset
86 "strings");
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Test_Block:
kono
parents:
diff changeset
89 declare
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 use Ada.Text_IO;
kono
parents:
diff changeset
92 use FXF3A00;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 TC_Picture : Editing.Picture;
kono
parents:
diff changeset
95 TC_Blank_When_Zero : Boolean;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 begin
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- Validate that function To_Picture does not raise Picture_Error when
kono
parents:
diff changeset
101 -- provided a valid picture string as an input parameter.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 for i in 1..FXF3A00.Number_Of_Valid_Strings loop
kono
parents:
diff changeset
104 begin
kono
parents:
diff changeset
105 TC_Picture :=
kono
parents:
diff changeset
106 Editing.To_Picture(Pic_String => Valid_Strings(i).all,
kono
parents:
diff changeset
107 Blank_When_Zero => False );
kono
parents:
diff changeset
108 exception
kono
parents:
diff changeset
109 when Editing.Picture_Error =>
kono
parents:
diff changeset
110 Report.Failed
kono
parents:
diff changeset
111 ("Picture_Error raised by function To_Picture " &
kono
parents:
diff changeset
112 "with a valid picture string as input parameter, " &
kono
parents:
diff changeset
113 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
114 when others =>
kono
parents:
diff changeset
115 Report.Failed("Unexpected exception raised - 1, " &
kono
parents:
diff changeset
116 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
117 end;
kono
parents:
diff changeset
118 end loop;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- Validate that function To_Picture raises Picture_Error when an
kono
parents:
diff changeset
123 -- invalid picture string is provided as an input parameter.
kono
parents:
diff changeset
124 -- Default value used for parameter Blank_When_Zero.
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 for i in 1..FXF3A00.Number_Of_Invalid_Strings loop
kono
parents:
diff changeset
127 begin
kono
parents:
diff changeset
128 TC_Picture :=
kono
parents:
diff changeset
129 Editing.To_Picture(Pic_String => FXF3A00.Invalid_Strings(i).all);
kono
parents:
diff changeset
130 Report.Failed
kono
parents:
diff changeset
131 ("Picture_Error not raised by function To_Picture " &
kono
parents:
diff changeset
132 "with an invalid picture string as input parameter, " &
kono
parents:
diff changeset
133 "Invalid_String = " & FXF3A00.Invalid_Strings(i).all);
kono
parents:
diff changeset
134 exception
kono
parents:
diff changeset
135 when Editing.Picture_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
136 when others =>
kono
parents:
diff changeset
137 Report.Failed("Unexpected exception raised, " &
kono
parents:
diff changeset
138 "Invalid_String = " &
kono
parents:
diff changeset
139 FXF3A00.Invalid_Strings(i).all);
kono
parents:
diff changeset
140 end;
kono
parents:
diff changeset
141 end loop;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Validate that To_Picture and Pic_String/Blank_When_Zero provide
kono
parents:
diff changeset
146 -- "inverse" results.
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 -- Use the default value of the Blank_When_Zero parameter (False) for
kono
parents:
diff changeset
149 -- these evaluations (some valid strings have the '*' zero suppression
kono
parents:
diff changeset
150 -- character, which would result in an invalid string if used with a
kono
parents:
diff changeset
151 -- True value for the Blank_When_Zero parameter).
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 for i in 1..FXF3A00.Number_Of_Valid_Strings loop
kono
parents:
diff changeset
154 begin
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -- Format a picture string using function To_Picture.
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 -- Reconvert the Picture result from To_Picture to a string value
kono
parents:
diff changeset
161 -- using function Pic_String, and compare to the original string.
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 if Editing.Pic_String(Pic => TC_Picture) /=
kono
parents:
diff changeset
164 Uppercase (FXF3A00.Valid_Strings(i).all)
kono
parents:
diff changeset
165 then
kono
parents:
diff changeset
166 Report.Failed
kono
parents:
diff changeset
167 ("Inverse result incorrect from Editing.Pic_String, " &
kono
parents:
diff changeset
168 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
169 end if;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 -- Ensure that function Blank_When_Zero returns the correct value
kono
parents:
diff changeset
172 -- of the Blank_When_Zero parameter used in forming the Picture
kono
parents:
diff changeset
173 -- (default parameter value False used in call to To_Picture
kono
parents:
diff changeset
174 -- above).
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 if Editing.Blank_When_Zero(Pic => TC_Picture) then
kono
parents:
diff changeset
177 Report.Failed
kono
parents:
diff changeset
178 ("Inverse result incorrect from Editing.Blank_When_Zero, " &
kono
parents:
diff changeset
179 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
180 end if;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 exception
kono
parents:
diff changeset
183 when others =>
kono
parents:
diff changeset
184 Report.Failed("Unexpected exception raised - 2, " &
kono
parents:
diff changeset
185 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
186 end;
kono
parents:
diff changeset
187 end loop;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 -- Specifically check that any lower case letters in the original
kono
parents:
diff changeset
191 -- picture string have been converted to upper case form following
kono
parents:
diff changeset
192 -- the To_Picture/Pic_String conversion (as shown in previous loop).
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 declare
kono
parents:
diff changeset
195 The_Picture : Editing.Picture;
kono
parents:
diff changeset
196 The_Picture_String : constant String := "+bBbZz_zZz_Zz9.99";
kono
parents:
diff changeset
197 The_Expected_Result : constant String := "+BBBZZ_ZZZ_ZZ9.99";
kono
parents:
diff changeset
198 begin
kono
parents:
diff changeset
199 -- Convert Picture String to Picture.
kono
parents:
diff changeset
200 The_Picture := Editing.To_Picture(Pic_String => The_Picture_String);
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 declare
kono
parents:
diff changeset
203 -- Reconvert the Picture to a Picture String.
kono
parents:
diff changeset
204 The_Result : constant String := Editing.Pic_String(The_Picture);
kono
parents:
diff changeset
205 begin
kono
parents:
diff changeset
206 if The_Result /= The_Expected_Result then
kono
parents:
diff changeset
207 Report.Failed("Conversion to Picture/Reconversion to String " &
kono
parents:
diff changeset
208 "did not produce expected result when Picture " &
kono
parents:
diff changeset
209 "String had lower case letters");
kono
parents:
diff changeset
210 end if;
kono
parents:
diff changeset
211 end;
kono
parents:
diff changeset
212 end;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 -- Use a value of True for the Blank_When_Zero parameter for the
kono
parents:
diff changeset
216 -- following evaluations (picture strings that do not have the '*' zero
kono
parents:
diff changeset
217 -- suppression character, which would result in an invalid string when
kono
parents:
diff changeset
218 -- used here with a True value for the Blank_When_Zero parameter).
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 for i in 3..24 loop
kono
parents:
diff changeset
221 begin
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 -- Format a picture string using function To_Picture.
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 TC_Picture :=
kono
parents:
diff changeset
226 Editing.To_Picture(Pic_String => Valid_Strings(i).all,
kono
parents:
diff changeset
227 Blank_When_Zero => True);
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 -- Reconvert the Picture result from To_Picture to a string value
kono
parents:
diff changeset
230 -- using function Pic_String, and compare to the original string.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 if Editing.Pic_String(Pic => TC_Picture) /=
kono
parents:
diff changeset
233 UpperCase (FXF3A00.Valid_Strings(i).all)
kono
parents:
diff changeset
234 then
kono
parents:
diff changeset
235 Report.Failed
kono
parents:
diff changeset
236 ("Inverse result incorrect from Editing.Pic_String, used " &
kono
parents:
diff changeset
237 "on Picture formed with parameter Blank_When_Zero = True, " &
kono
parents:
diff changeset
238 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
239 end if;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 -- Ensure that function Blank_When_Zero returns the correct value
kono
parents:
diff changeset
242 -- of the Blank_When_Zero parameter used in forming the Picture
kono
parents:
diff changeset
243 -- (default parameter value False overridden in call to
kono
parents:
diff changeset
244 -- To_Picture above).
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 if not Editing.Blank_When_Zero(Pic => TC_Picture) then
kono
parents:
diff changeset
247 Report.Failed
kono
parents:
diff changeset
248 ("Inverse result incorrect from Editing.Blank_When_Zero, " &
kono
parents:
diff changeset
249 "used on a Picture formed with parameter Blank_When_Zero " &
kono
parents:
diff changeset
250 "= True, Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
251 end if;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 exception
kono
parents:
diff changeset
254 when others =>
kono
parents:
diff changeset
255 Report.Failed("Unexpected exception raised - 3, " &
kono
parents:
diff changeset
256 "Valid_String = " & FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
257 end;
kono
parents:
diff changeset
258 end loop;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 exception
kono
parents:
diff changeset
262 when others => Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
263 end Test_Block;
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 Report.Result;
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 end CXF3A02;