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 statically identifiable picture strings can be used
28 -- in conjunction with function Image to produce output strings
29 -- appropriate to foreign currency representations.
31 -- Check that statically identifiable picture strings will cause
32 -- function Image to raise Layout_Error under the appropriate
36 -- This test defines several picture strings that are statically
37 -- identifiable, (i.e., Pic : Picture := To_Picture("..."); ).
38 -- These picture strings are used in conjunction with decimal data
39 -- as parameters in calls to function Image.
43 -- 11 Apr 96 SAIC Initial release for 2.1.
48 with Ada
.Text_IO
.Editing
;
54 Report
.Test
("CXF3004", "Check that statically identifiable " &
55 "picture strings will cause function Image " &
56 "to raise Layout_Error under appropriate " &
63 use Ada
.Text_IO
.Editing
;
65 FF_Currency
: constant String := "FF";
66 DM_Currency
: constant String := "DM";
67 FF_Separator
: constant Character := '.';
68 DM_Separator
: constant Character := ',';
69 FF_Radix
: constant Character := ',';
70 DM_Radix
: constant Character := '.';
71 Blank_Fill
: constant Character := ' ';
72 Star_Fill
: constant Character := '*';
75 -- Define a decimal data type, and instantiate the Decimal_Output
76 -- generic package for the data type.
78 type Decimal_Data_Type
is delta 0.01 digits 16;
81 new Decimal_Output
(Num
=> Decimal_Data_Type
,
82 Default_Currency
=> "$",
83 Default_Fill
=> Star_Fill
,
84 Default_Separator
=> Default_Separator
,
85 Default_Radix_Mark
=> DM_Radix
);
89 -- The following decimal data items are used with picture strings
90 -- in evaluating use of foreign currency symbols.
92 Dec_Data_1
: Decimal_Data_Type
:= 123456.78;
93 Dec_Data_2
: Decimal_Data_Type
:= 32.10;
94 Dec_Data_3
: Decimal_Data_Type
:= -1234.57;
95 Dec_Data_4
: Decimal_Data_Type
:= 123456.78;
96 Dec_Data_5
: Decimal_Data_Type
:= 12.34;
97 Dec_Data_6
: Decimal_Data_Type
:= 12.34;
98 Dec_Data_7
: Decimal_Data_Type
:= 12345.67;
101 -- Statically identifiable picture strings.
102 -- These strings are used in conjunction with non-default values
103 -- for Currency string, Radix mark, and Separator in calls to
106 Picture_1
: Picture
:= To_Picture
("-###**_***_**9.99"); -- FF
107 Picture_2
: Picture
:= To_Picture
("###z_ZZ9.99"); -- FF
108 Picture_3
: Picture
:= To_Picture
("<<<<_<<<.<<###>"); -- DM
109 Picture_4
: Picture
:= To_Picture
("-$_$$$_$$$_$$9.99"); -- DM
110 Picture_5
: Picture
:= To_Picture
("$Zz9.99"); -- DM
111 Picture_6
: Picture
:= To_Picture
("$$$9.99"); -- DM
112 Picture_7
: Picture
:= To_Picture
("###_###_##9.99"); -- CHF
115 -- The following ten edited output strings correspond to the ten
116 -- foreign currency picture strings.
118 Output_1
: constant String := " FF***123.456,78";
119 Output_2
: constant String := " FF 32,10";
120 Output_3
: constant String := " (1,234.57DM )";
121 Output_4
: constant String := " DM123,456.78";
122 Output_5
: constant String := "DM 12.34";
123 Output_6
: constant String := " DM12.34";
124 Output_7
: constant String := " CHF12,345.67";
129 -- Check the results of function Image, using the picture strings
130 -- constructed above, in creating foreign currency edited output
133 if Image_IO
.Image
(Item
=> Dec_Data_1
,
135 Currency
=> FF_Currency
,
137 Separator
=> FF_Separator
,
138 Radix_Mark
=> FF_Radix
) /= Output_1
140 Report
.Failed
("Incorrect result from Fn. Image using Picture_1");
143 if Image_IO
.Image
(Item
=> Dec_Data_2
,
145 Currency
=> FF_Currency
,
147 Separator
=> FF_Separator
,
148 Radix_Mark
=> FF_Radix
) /= Output_2
150 Report
.Failed
("Incorrect result from Fn. Image using Picture_2");
153 if Image_IO
.Image
(Item
=> Dec_Data_3
,
155 Currency
=> DM_Currency
,
157 Separator
=> DM_Separator
,
158 Radix_Mark
=> DM_Radix
) /= Output_3
160 Report
.Failed
("Incorrect result from Fn. Image using Picture_3");
163 if Image_IO
.Image
(Item
=> Dec_Data_4
,
165 Currency
=> DM_Currency
,
167 Separator
=> DM_Separator
,
168 Radix_Mark
=> DM_Radix
) /= Output_4
170 Report
.Failed
("Incorrect result from Fn. Image using Picture_4");
173 if Image_IO
.Image
(Item
=> Dec_Data_5
,
175 Currency
=> DM_Currency
,
177 Separator
=> DM_Separator
,
178 Radix_Mark
=> DM_Radix
) /= Output_5
180 Report
.Failed
("Incorrect result from Fn. Image using Picture_5");
183 if Image_IO
.Image
(Item
=> Dec_Data_6
,
185 Currency
=> DM_Currency
,
187 Separator
=> DM_Separator
,
188 Radix_Mark
=> DM_Radix
) /= Output_6
190 Report
.Failed
("Incorrect result from Fn. Image using Picture_6");
193 if Image_IO
.Image
(Item
=> Dec_Data_7
,
198 Radix_Mark
=> '.') /= Output_7
200 Report
.Failed
("Incorrect result from Fn. Image using Picture_7");
204 -- The following calls of Function Image, using the specific
205 -- decimal values and picture strings provided, will cause
206 -- a Layout_Error to be raised.
207 -- Note: The data and the picture strings used in the following
208 -- evaluations are not themselves erroneous, but when used in
209 -- combination will cause Layout_Error to be raised.
213 Erroneous_Data_1
: Decimal_Data_Type
:= 12.34;
214 Erroneous_Picture_1
: Picture
:= To_Picture
("9.99");
215 N
: constant Natural := Image_IO
.Length
(Erroneous_Picture_1
);
216 TC_String
: String(1..N
);
218 TC_String
:= Image_IO
.Image
(Erroneous_Data_1
, Erroneous_Picture_1
);
219 Report
.Failed
("Layout_Error not raised by combination of " &
220 "Erroneous_Picture_1 and Erroneous_Data_1");
221 Report
.Comment
("Should never be printed: " & TC_String
);
223 when Ada
.Text_IO
.Layout_Error
=> null; -- OK, expected exception.
224 when The_Error
: others =>
226 ("The following exception was incorrectly raised in " &
227 "Exception_Block_1: " & Exception_Name
(The_Error
));
228 end Exception_Block_1
;
232 Erroneous_Data_2
: Decimal_Data_Type
:= -12.34;
233 Erroneous_Picture_2
: Picture
:= To_Picture
("99.99");
234 N
: constant Natural := Image_IO
.Length
(Erroneous_Picture_2
);
235 TC_String
: String(1..N
);
237 TC_String
:= Image_IO
.Image
(Erroneous_Data_2
, Erroneous_Picture_2
);
238 Report
.Failed
("Layout_Error not raised by combination of " &
239 "Erroneous_Picture_2 and Erroneous_Data_2");
240 Report
.Comment
("Should never be printed: " & TC_String
);
242 when Ada
.Text_IO
.Layout_Error
=> null; -- OK, expected exception.
243 when The_Error
: others =>
245 ("The following exception was incorrectly raised in " &
246 "Exception_Block_2: " & Exception_Name
(The_Error
));
247 end Exception_Block_2
;
250 when The_Error
: others =>
251 Report
.Failed
("The following exception was raised in the " &
252 "Test_Block: " & Exception_Name
(The_Error
));