3 -- Grant of Unlimited Rights
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
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.
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
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.
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.
47 -- The following files comprise this test:
49 -- FXF3A00.A (foundation code)
54 -- 06 Dec 94 SAIC ACVC 2.0
55 -- 11 Mar 97 PWB.CTA Corrected invalid picture string and uppercase
60 with Ada
.Text_IO
.Editing
;
61 with Ada
.Strings
.Maps
;
62 with Ada
.Strings
.Fixed
;
67 Lower_Alpha
: constant String := "abcdefghijklmnopqrstuvwxyz";
68 Upper_Alpha
: constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
69 function UpperCase
( Source
: String ) return String is
72 Ada
.Strings
.Fixed
.Translate
74 Mapping
=> Ada
.Strings
.Maps
.To_Mapping
75 ( From
=> Lower_Alpha
,
76 To
=> Upper_Alpha
) );
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 " &
94 TC_Picture
: Editing
.Picture
;
95 TC_Blank_When_Zero
: Boolean;
100 -- Validate that function To_Picture does not raise Picture_Error when
101 -- provided a valid picture string as an input parameter.
103 for i
in 1..FXF3A00
.Number_Of_Valid_Strings
loop
106 Editing
.To_Picture
(Pic_String
=> Valid_Strings
(i
).all,
107 Blank_When_Zero
=> False );
109 when Editing
.Picture_Error
=>
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);
115 Report
.Failed
("Unexpected exception raised - 1, " &
116 "Valid_String = " & FXF3A00
.Valid_Strings
(i
).all);
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.
126 for i
in 1..FXF3A00
.Number_Of_Invalid_Strings
loop
129 Editing
.To_Picture
(Pic_String
=> FXF3A00
.Invalid_Strings
(i
).all);
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);
135 when Editing
.Picture_Error
=> null; -- OK, expected exception.
137 Report
.Failed
("Unexpected exception raised, " &
138 "Invalid_String = " &
139 FXF3A00
.Invalid_Strings
(i
).all);
145 -- Validate that To_Picture and Pic_String/Blank_When_Zero provide
146 -- "inverse" results.
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).
153 for i
in 1..FXF3A00
.Number_Of_Valid_Strings
loop
156 -- Format a picture string using function To_Picture.
158 TC_Picture
:= Editing
.To_Picture
(FXF3A00
.Valid_Strings
(i
).all);
160 -- Reconvert the Picture result from To_Picture to a string value
161 -- using function Pic_String, and compare to the original string.
163 if Editing
.Pic_String
(Pic
=> TC_Picture
) /=
164 Uppercase
(FXF3A00
.Valid_Strings
(i
).all)
167 ("Inverse result incorrect from Editing.Pic_String, " &
168 "Valid_String = " & FXF3A00
.Valid_Strings
(i
).all);
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
176 if Editing
.Blank_When_Zero
(Pic
=> TC_Picture
) then
178 ("Inverse result incorrect from Editing.Blank_When_Zero, " &
179 "Valid_String = " & FXF3A00
.Valid_Strings
(i
).all);
184 Report
.Failed
("Unexpected exception raised - 2, " &
185 "Valid_String = " & FXF3A00
.Valid_Strings
(i
).all);
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).
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";
199 -- Convert Picture String to Picture.
200 The_Picture
:= Editing
.To_Picture
(Pic_String
=> The_Picture_String
);
203 -- Reconvert the Picture to a Picture String.
204 The_Result
: constant String := Editing
.Pic_String
(The_Picture
);
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");
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).
223 -- Format a picture string using function To_Picture.
226 Editing
.To_Picture
(Pic_String
=> Valid_Strings
(i
).all,
227 Blank_When_Zero
=> True);
229 -- Reconvert the Picture result from To_Picture to a string value
230 -- using function Pic_String, and compare to the original string.
232 if Editing
.Pic_String
(Pic
=> TC_Picture
) /=
233 UpperCase
(FXF3A00
.Valid_Strings
(i
).all)
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);
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).
246 if not Editing
.Blank_When_Zero
(Pic
=> TC_Picture
) then
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);
255 Report
.Failed
("Unexpected exception raised - 3, " &
256 "Valid_String = " & FXF3A00
.Valid_Strings
(i
).all);
262 when others => Report
.Failed
("Exception raised in Test_Block");