annotate gcc/testsuite/ada/acats/tests/cxf/cxf3002.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 -- CXF3002.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 functionality contained in package
kono
parents:
diff changeset
28 -- Ada.Wide_Text_IO.Editing is available and produces correct results.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION:
kono
parents:
diff changeset
31 -- This test is designed to validate the procedures and functions that
kono
parents:
diff changeset
32 -- are found in package Ada.Wide_Text_IO.Editing, the "wide"
kono
parents:
diff changeset
33 -- complementary package to Ada.Text_IO.Editing. The test is similar
kono
parents:
diff changeset
34 -- to CXF3301, which tested a large portion of the Ada.Text_IO.Editing
kono
parents:
diff changeset
35 -- package. Additional testing has been added here to cover the balance
kono
parents:
diff changeset
36 -- of the Wide_Text_IO.Editing child package.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- This test is structured using tables of data, consisting of
kono
parents:
diff changeset
39 -- numerical values, picture strings, and expected image
kono
parents:
diff changeset
40 -- result strings.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- Each picture string is checked for validity, and an invalid picture
kono
parents:
diff changeset
43 -- string will cause immediate test failure on its first pass through
kono
parents:
diff changeset
44 -- the evaluation loop. Inside the evaluation loop, each decimal data
kono
parents:
diff changeset
45 -- item is combined with each of the picture strings as parameters to a
kono
parents:
diff changeset
46 -- call to Image, and the result of each call is compared to an
kono
parents:
diff changeset
47 -- expected edited output result string.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- Note: Each of the functions Valid, To_Picture, and Pic_String has
kono
parents:
diff changeset
50 -- String (rather than Wide_String) as its parameter or result
kono
parents:
diff changeset
51 -- subtype, since a picture String is not localizable.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 -- CHANGE HISTORY:
kono
parents:
diff changeset
55 -- 22 Jun 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
56 -- 22 Aug 95 SAIC Test name changed to CXF3002 (from CXF3401) to
kono
parents:
diff changeset
57 -- conform with naming conventions.
kono
parents:
diff changeset
58 -- 24 Feb 97 PWB.CTA Corrected picture strings and expected values.
kono
parents:
diff changeset
59 --!
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 with Ada.Wide_Text_IO.Editing;
kono
parents:
diff changeset
62 with Report;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 procedure CXF3002 is
kono
parents:
diff changeset
65 begin
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 Report.Test ("CXF3002", "Check that the functionality contained " &
kono
parents:
diff changeset
68 "in package Ada.Wide_Text_IO.Editing is " &
kono
parents:
diff changeset
69 "available and produces correct results");
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 Test_Block:
kono
parents:
diff changeset
72 declare
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 use Ada.Wide_Text_IO;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 Number_Of_Decimal_Items : constant := 5;
kono
parents:
diff changeset
77 Number_Of_Picture_Strings : constant := 4;
kono
parents:
diff changeset
78 Number_Of_Expected_Results : constant := Number_Of_Decimal_Items *
kono
parents:
diff changeset
79 Number_Of_Picture_Strings;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 Def_Cur : constant Wide_String := "$";
kono
parents:
diff changeset
82 Def_Fill : constant Wide_Character := '*';
kono
parents:
diff changeset
83 Def_Sep : constant Wide_Character := Editing.Default_Separator;
kono
parents:
diff changeset
84 Def_Radix : constant Wide_Character := Editing.Default_Radix_Mark;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type String_Pointer_Type is access String;
kono
parents:
diff changeset
87 type Wide_String_Pointer_Type is access Wide_String;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 -- Define a decimal data type, and instantiate the Decimal_Output
kono
parents:
diff changeset
90 -- generic package for the data type.
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 type Decimal_Data_Type is delta 0.01 digits 16;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 package Wide_Ed_Out is
kono
parents:
diff changeset
95 new Editing.Decimal_Output(Num => Decimal_Data_Type,
kono
parents:
diff changeset
96 Default_Currency => Def_Cur,
kono
parents:
diff changeset
97 Default_Fill => Def_Fill,
kono
parents:
diff changeset
98 Default_Separator => Def_Sep,
kono
parents:
diff changeset
99 Default_Radix_Mark => Def_Radix);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 -- Define types for the arrays of data that will hold the decimal data
kono
parents:
diff changeset
102 -- values, picture strings, and expected edited output results.
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 type Decimal_Data_Array_Type is
kono
parents:
diff changeset
105 array (Integer range <>) of Decimal_Data_Type;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 type Picture_String_Array_Type is
kono
parents:
diff changeset
108 array (Integer range <>) of String_Pointer_Type;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 type Edited_Output_Results_Array_Type is
kono
parents:
diff changeset
111 array (Integer range <>) of Wide_String_Pointer_Type;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- Define the data arrays for this test.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 Decimal_Data :
kono
parents:
diff changeset
116 Decimal_Data_Array_Type(1..Number_Of_Decimal_Items) :=
kono
parents:
diff changeset
117 ( 1 => 5678.90,
kono
parents:
diff changeset
118 2 => -6789.01,
kono
parents:
diff changeset
119 3 => 0.00,
kono
parents:
diff changeset
120 4 => 0.20,
kono
parents:
diff changeset
121 5 => 3.45
kono
parents:
diff changeset
122 );
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 Picture_Strings :
kono
parents:
diff changeset
125 Picture_String_Array_Type(1..Number_Of_Picture_Strings) :=
kono
parents:
diff changeset
126 ( 1 => new String'("-$$_$$9.99"),
kono
parents:
diff changeset
127 2 => new String'("-$$_$$$.$$"),
kono
parents:
diff changeset
128 3 => new String'("-ZZZZ.ZZ"),
kono
parents:
diff changeset
129 4 => new String'("-$$$_999.99")
kono
parents:
diff changeset
130 );
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 Edited_Output :
kono
parents:
diff changeset
134 Edited_Output_Results_Array_Type(1..Number_Of_Expected_Results) :=
kono
parents:
diff changeset
135 ( 1 => new Wide_String'(" $5,678.90"),
kono
parents:
diff changeset
136 2 => new Wide_String'(" $5,678.90"),
kono
parents:
diff changeset
137 3 => new Wide_String'(" 5678.90"),
kono
parents:
diff changeset
138 4 => new Wide_String'(" $5,678.90"),
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 5 => new Wide_String'("-$6,789.01"),
kono
parents:
diff changeset
141 6 => new Wide_String'("-$6,789.01"),
kono
parents:
diff changeset
142 7 => new Wide_String'("-6789.01"),
kono
parents:
diff changeset
143 8 => new Wide_String'("- $6,789.01"),
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 9 => new Wide_String'(" $0.00"),
kono
parents:
diff changeset
146 10 => new Wide_String'(" "),
kono
parents:
diff changeset
147 11 => new Wide_String'(" "),
kono
parents:
diff changeset
148 12 => new Wide_String'(" $ 000.00"),
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 13 => new Wide_String'(" $0.20"),
kono
parents:
diff changeset
151 14 => new Wide_String'(" $.20"),
kono
parents:
diff changeset
152 15 => new Wide_String'(" .20"),
kono
parents:
diff changeset
153 16 => new Wide_String'(" $ 000.20"),
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 17 => new Wide_String'(" $3.45"),
kono
parents:
diff changeset
156 18 => new Wide_String'(" $3.45"),
kono
parents:
diff changeset
157 19 => new Wide_String'(" 3.45"),
kono
parents:
diff changeset
158 20 => new Wide_String'(" $ 003.45")
kono
parents:
diff changeset
159 );
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 TC_Picture : Editing.Picture;
kono
parents:
diff changeset
162 TC_Loop_Count : Natural := 0;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 begin
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Compare string result of Image with expected edited output wide
kono
parents:
diff changeset
167 -- string.
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 Evaluate_Edited_Output:
kono
parents:
diff changeset
170 for i in 1..Number_Of_Decimal_Items loop
kono
parents:
diff changeset
171 for j in 1..Number_Of_Picture_Strings loop
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 TC_Loop_Count := TC_Loop_Count + 1;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 -- Check on the validity of the picture strings prior to
kono
parents:
diff changeset
176 -- processing.
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 if Editing.Valid(Picture_Strings(j).all) then
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 -- Create the picture object from the picture string.
kono
parents:
diff changeset
181 TC_Picture := Editing.To_Picture(Picture_Strings(j).all);
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 -- Check results of function Decimal_Output.Valid.
kono
parents:
diff changeset
184 if not Wide_Ed_Out.Valid(Decimal_Data(i), TC_Picture) then
kono
parents:
diff changeset
185 Report.Failed("Incorrect result from function Valid " &
kono
parents:
diff changeset
186 "when examining the picture string that " &
kono
parents:
diff changeset
187 "was produced from string " &
kono
parents:
diff changeset
188 Integer'Image(j) & " in conjunction with " &
kono
parents:
diff changeset
189 "decimal data item # " & Integer'Image(i));
kono
parents:
diff changeset
190 end if;
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 -- Check results of function Editing.Pic_String.
kono
parents:
diff changeset
193 if Editing.Pic_String(TC_Picture) /= Picture_Strings(j).all then
kono
parents:
diff changeset
194 Report.Failed("Incorrect result from To_Picture/" &
kono
parents:
diff changeset
195 "Pic_String conversion for picture " &
kono
parents:
diff changeset
196 "string # " & Integer'Image(j));
kono
parents:
diff changeset
197 end if;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- Compare actual edited output result of Function Image with
kono
parents:
diff changeset
200 -- the expected result.
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 if Wide_Ed_Out.Image(Decimal_Data(i), TC_Picture) /=
kono
parents:
diff changeset
203 Edited_Output(TC_Loop_Count).all
kono
parents:
diff changeset
204 then
kono
parents:
diff changeset
205 Report.Failed("Incorrect result from Function Image, " &
kono
parents:
diff changeset
206 "when used with decimal data item # " &
kono
parents:
diff changeset
207 Integer'Image(i) &
kono
parents:
diff changeset
208 " and picture string # " &
kono
parents:
diff changeset
209 Integer'Image(j));
kono
parents:
diff changeset
210 end if;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 else
kono
parents:
diff changeset
213 Report.Failed("Picture String # " & Integer'Image(j) &
kono
parents:
diff changeset
214 "reported as being invalid");
kono
parents:
diff changeset
215 end if;
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 end loop;
kono
parents:
diff changeset
218 end loop Evaluate_Edited_Output;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 exception
kono
parents:
diff changeset
221 when Editing.Picture_Error =>
kono
parents:
diff changeset
222 Report.Failed ("Picture_Error raised in Test_Block");
kono
parents:
diff changeset
223 when Layout_Error =>
kono
parents:
diff changeset
224 Report.Failed ("Layout_Error raised in Test_Block");
kono
parents:
diff changeset
225 when others =>
kono
parents:
diff changeset
226 Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
227 end Test_Block;
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 Report.Result;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 end CXF3002;