annotate gcc/testsuite/ada/acats/tests/cxf/cxf3a07.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 -- CXF3A07.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 Ada.Text_IO.Editing.Put and Ada.Strings.Fixed.Move
kono
parents:
diff changeset
28 -- have the same effect in putting edited output results into string
kono
parents:
diff changeset
29 -- variables.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- This test is structured using tables of data, consisting of
kono
parents:
diff changeset
33 -- numerical values, picture strings, and expected image
kono
parents:
diff changeset
34 -- result strings. These data tables are found in package FXF3A00.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- The operation of the two above subprograms are examined twice, first
kono
parents:
diff changeset
37 -- with the output of an edited output string to a receiving string
kono
parents:
diff changeset
38 -- object of equal size, the other to a receiving string object of
kono
parents:
diff changeset
39 -- larger size, where justification and padding are considered.
kono
parents:
diff changeset
40 -- The procedure Editing.Put will place an edited output string into
kono
parents:
diff changeset
41 -- a larger receiving string with right justification and blank fill.
kono
parents:
diff changeset
42 -- Procedure Move has parameter control of justification and fill, and
kono
parents:
diff changeset
43 -- in this test will mirror Put by specifying right justification and
kono
parents:
diff changeset
44 -- blank fill.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- In the cases where the edited output string is of shorter length
kono
parents:
diff changeset
47 -- than the receiving string object, a blank-filled constant string
kono
parents:
diff changeset
48 -- will be catenated to the front of the expected edited output string
kono
parents:
diff changeset
49 -- for comparison with the receiving string object, enabling direct
kono
parents:
diff changeset
50 -- string comparison for result verification.
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 -- TEST FILES:
kono
parents:
diff changeset
53 -- The following files comprise this test:
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- FXF3A00.A (foundation code)
kono
parents:
diff changeset
56 -- => CXF3A07.A
kono
parents:
diff changeset
57 --
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 -- CHANGE HISTORY:
kono
parents:
diff changeset
60 -- 30 JAN 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
61 -- 11 MAR 97 PWB.CTA Fixed string lengths
kono
parents:
diff changeset
62 --!
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 with FXF3A00;
kono
parents:
diff changeset
65 with Ada.Text_IO.Editing;
kono
parents:
diff changeset
66 with Ada.Strings.Fixed;
kono
parents:
diff changeset
67 with Report;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 procedure CXF3A07 is
kono
parents:
diff changeset
70 begin
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 Report.Test ("CXF3A07", "Check that Ada.Text_IO.Editing.Put and " &
kono
parents:
diff changeset
73 "Ada.Strings.Fixed.Move have the same " &
kono
parents:
diff changeset
74 "effect in putting edited output results " &
kono
parents:
diff changeset
75 "into string variables");
kono
parents:
diff changeset
76 Test_Block:
kono
parents:
diff changeset
77 declare
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 use Ada.Text_IO;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- Instantiate the Decimal_Output generic package for two
kono
parents:
diff changeset
82 -- different decimal data types.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 package Pack_2DP is -- Uses decimal type with delta 0.01.
kono
parents:
diff changeset
85 new Editing.Decimal_Output(FXF3A00.Decimal_Type_2DP);
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 package Pack_NDP is -- Uses decimal type with delta 1.0.
kono
parents:
diff changeset
88 new Editing.Decimal_Output(Num => FXF3A00.Decimal_Type_NDP,
kono
parents:
diff changeset
89 Default_Currency => "$",
kono
parents:
diff changeset
90 Default_Fill => '*',
kono
parents:
diff changeset
91 Default_Separator => ',',
kono
parents:
diff changeset
92 Default_Radix_Mark => '.');
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 TC_Picture : Editing.Picture;
kono
parents:
diff changeset
95 TC_Start_Loop : Integer := 0;
kono
parents:
diff changeset
96 TC_End_Loop : Integer := 0;
kono
parents:
diff changeset
97 TC_Offset : Integer := 0;
kono
parents:
diff changeset
98 TC_Length : Natural := 0;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 TC_Put_String_20, -- Longer than the longest edited
kono
parents:
diff changeset
101 TC_Move_String_20 : String(1..20); -- output string.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 TC_Put_String_17, -- Exact length of longest edited
kono
parents:
diff changeset
104 TC_Move_String_17 : String(1..17); -- output string in 2DP-US data set.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 TC_Put_String_8, -- Exact length of longest edited
kono
parents:
diff changeset
107 TC_Move_String_8 : String(1..8); -- output string in NDP-US data set.
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 begin
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- Examine cases where the output string is longer than the length
kono
parents:
diff changeset
113 -- of the edited output result. Use the instantiation of
kono
parents:
diff changeset
114 -- Decimal_Output specific to data with two decimal places.
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 TC_Start_Loop := 1;
kono
parents:
diff changeset
117 TC_End_Loop := FXF3A00.Number_of_2DP_Items - -- 10
kono
parents:
diff changeset
118 FXF3A00.Number_Of_Foreign_Strings;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 for i in TC_Start_Loop..TC_End_Loop loop -- 1..10
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- Create the picture object from the picture string.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all,
kono
parents:
diff changeset
125 Blank_When_Zero => False);
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 -- Determine the actual length of the edited output string
kono
parents:
diff changeset
128 -- that is expected from Put and Image.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 TC_Length := Pack_2DP.Length(Pic => TC_Picture,
kono
parents:
diff changeset
131 Currency => "$");
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- Determine the difference in length between the receiving string
kono
parents:
diff changeset
134 -- object and the expected length of the edited output string.
kono
parents:
diff changeset
135 -- Define a blank filled string constant with length equal to this
kono
parents:
diff changeset
136 -- length difference.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 declare
kono
parents:
diff changeset
139 TC_Length_Diff : Integer := TC_Put_String_20'Length -
kono
parents:
diff changeset
140 TC_Length;
kono
parents:
diff changeset
141 TC_Buffer_String : constant String(1..TC_Length_Diff) :=
kono
parents:
diff changeset
142 (others => ' ');
kono
parents:
diff changeset
143 begin
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Fill the two receiving string objects with edited output,
kono
parents:
diff changeset
146 -- using the two different methods (Put and Move).
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 Pack_2DP.Put(To => TC_Put_String_20,
kono
parents:
diff changeset
149 Item => FXF3A00.Data_With_2DP(i),
kono
parents:
diff changeset
150 Pic => TC_Picture,
kono
parents:
diff changeset
151 Currency => "$",
kono
parents:
diff changeset
152 Fill => '*',
kono
parents:
diff changeset
153 Separator => ',',
kono
parents:
diff changeset
154 Radix_Mark => '.');
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 Ada.Strings.Fixed.Move
kono
parents:
diff changeset
158 (Source => Pack_2DP.Image(Item => FXF3A00.Data_With_2DP(i),
kono
parents:
diff changeset
159 Pic => TC_Picture,
kono
parents:
diff changeset
160 Currency => "$",
kono
parents:
diff changeset
161 Fill => '*',
kono
parents:
diff changeset
162 Separator => ',',
kono
parents:
diff changeset
163 Radix_Mark => '.'),
kono
parents:
diff changeset
164 Target => TC_Move_String_20,
kono
parents:
diff changeset
165 Drop => Ada.Strings.Error,
kono
parents:
diff changeset
166 Justify => Ada.Strings.Right,
kono
parents:
diff changeset
167 Pad => Ada.Strings.Space);
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 -- Each receiving string object is now filled with the edited
kono
parents:
diff changeset
170 -- output result, right justified.
kono
parents:
diff changeset
171 -- Compare these two string objects with the expected edited
kono
parents:
diff changeset
172 -- output value, which is appended to the blank filled string
kono
parents:
diff changeset
173 -- whose length is the difference between the expected edited
kono
parents:
diff changeset
174 -- output length and the length of the receiving strings.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 if TC_Buffer_String & FXF3A00.Edited_Output(i).all /=
kono
parents:
diff changeset
177 TC_Put_String_20 or
kono
parents:
diff changeset
178 TC_Buffer_String & FXF3A00.Edited_Output(i).all /=
kono
parents:
diff changeset
179 TC_Move_String_20
kono
parents:
diff changeset
180 then
kono
parents:
diff changeset
181 Report.Failed("Failed case where the output string is " &
kono
parents:
diff changeset
182 "longer than the length of the edited " &
kono
parents:
diff changeset
183 "output result, loop #" & Integer'Image(i));
kono
parents:
diff changeset
184 end if;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 exception
kono
parents:
diff changeset
187 when Layout_Error =>
kono
parents:
diff changeset
188 Report.Failed("Layout_Error raised when the output string " &
kono
parents:
diff changeset
189 "is longer than the length of the edited " &
kono
parents:
diff changeset
190 "output result, loop #" & Integer'Image(i));
kono
parents:
diff changeset
191 when others =>
kono
parents:
diff changeset
192 Report.Failed("Exception raised when the output string is " &
kono
parents:
diff changeset
193 "longer than the length of the edited " &
kono
parents:
diff changeset
194 "output result, loop #" & Integer'Image(i));
kono
parents:
diff changeset
195 end;
kono
parents:
diff changeset
196 end loop;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- Repeat the above loop, but only evaluate three cases - those where
kono
parents:
diff changeset
200 -- the length of the expected edited output string is the exact length
kono
parents:
diff changeset
201 -- of the receiving strings (no justification will be required within
kono
parents:
diff changeset
202 -- the string. This series of evaluations again uses decimal data
kono
parents:
diff changeset
203 -- with two decimal places.
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 for i in TC_Start_Loop..TC_End_Loop loop -- 1..10
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 case i is
kono
parents:
diff changeset
208 when 1 | 5 | 7 =>
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 -- Create the picture object from the picture string.
kono
parents:
diff changeset
211 TC_Picture :=
kono
parents:
diff changeset
212 Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 -- Fill the two receiving string objects with edited output,
kono
parents:
diff changeset
215 -- using the two different methods (Put and Move).
kono
parents:
diff changeset
216 -- Use default parameters in the various calls where possible.
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 Pack_2DP.Put(To => TC_Put_String_17,
kono
parents:
diff changeset
219 Item => FXF3A00.Data_With_2DP(i),
kono
parents:
diff changeset
220 Pic => TC_Picture);
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Ada.Strings.Fixed.Move
kono
parents:
diff changeset
224 (Source => Pack_2DP.Image(Item => FXF3A00.Data_With_2DP(i),
kono
parents:
diff changeset
225 Pic => TC_Picture),
kono
parents:
diff changeset
226 Target => TC_Move_String_17);
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 -- Each receiving string object is now filled with the edited
kono
parents:
diff changeset
229 -- output result. Compare these two string objects with the
kono
parents:
diff changeset
230 -- expected edited output value.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 if FXF3A00.Edited_Output(i).all /= TC_Put_String_17 or
kono
parents:
diff changeset
233 FXF3A00.Edited_Output(i).all /= TC_Move_String_17
kono
parents:
diff changeset
234 then
kono
parents:
diff changeset
235 Report.Failed("Failed case where the output string is " &
kono
parents:
diff changeset
236 "the exact length of the edited output " &
kono
parents:
diff changeset
237 "result, loop #" & Integer'Image(i));
kono
parents:
diff changeset
238 end if;
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 when others => null;
kono
parents:
diff changeset
241 end case;
kono
parents:
diff changeset
242 end loop;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 -- Evaluate a mix of cases, where the expected edited output string
kono
parents:
diff changeset
246 -- length is either exactly as long or shorter than the receiving
kono
parents:
diff changeset
247 -- output string parameter. This series of evaluations uses decimal
kono
parents:
diff changeset
248 -- data with no decimal places.
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 TC_Start_Loop := TC_End_Loop + 1; -- 11
kono
parents:
diff changeset
251 TC_End_Loop := TC_Start_Loop + -- 22
kono
parents:
diff changeset
252 FXF3A00.Number_of_NDP_Items - 1;
kono
parents:
diff changeset
253 TC_Offset := FXF3A00.Number_of_Foreign_Strings; -- 10
kono
parents:
diff changeset
254 -- This offset is required due to the arrangement of data within the
kono
parents:
diff changeset
255 -- tables found in FXF3A00.
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 for i in TC_Start_Loop..TC_End_Loop loop -- 11..22
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 -- Create the picture object from the picture string.
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 TC_Picture := Editing.To_Picture(FXF3A00.Valid_Strings(i).all);
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 -- Determine the actual length of the edited output string
kono
parents:
diff changeset
264 -- that is expected from Put and Image.
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 TC_Length := Pack_NDP.Length(TC_Picture);
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 -- Fill the two receiving string objects with edited output,
kono
parents:
diff changeset
269 -- using the two different methods (Put and Move).
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 Pack_NDP.Put(TC_Put_String_8,
kono
parents:
diff changeset
272 FXF3A00.Data_With_NDP(i-TC_Offset),
kono
parents:
diff changeset
273 TC_Picture);
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 Ada.Strings.Fixed.Move
kono
parents:
diff changeset
276 (Pack_NDP.Image(FXF3A00.Data_With_NDP(i-TC_Offset), TC_Picture),
kono
parents:
diff changeset
277 TC_Move_String_8,
kono
parents:
diff changeset
278 Ada.Strings.Error,
kono
parents:
diff changeset
279 Ada.Strings.Right,
kono
parents:
diff changeset
280 Ada.Strings.Space);
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 -- Determine if there is a difference in length between the
kono
parents:
diff changeset
283 -- receiving string object and the expected length of the edited
kono
parents:
diff changeset
284 -- output string. If so, then define a blank filled string constant
kono
parents:
diff changeset
285 -- with length equal to this length difference.
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 if TC_Length < TC_Put_String_8'Length then
kono
parents:
diff changeset
288 declare
kono
parents:
diff changeset
289 TC_Length_Diff : Integer := TC_Put_String_8'Length -
kono
parents:
diff changeset
290 TC_Length;
kono
parents:
diff changeset
291 TC_Buffer_String : constant String(1..TC_Length_Diff) :=
kono
parents:
diff changeset
292 (others => ' ');
kono
parents:
diff changeset
293 begin
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 -- Each receiving string object is now filled with the edited
kono
parents:
diff changeset
296 -- output result, right justified.
kono
parents:
diff changeset
297 -- Compare these two string objects with the expected edited
kono
parents:
diff changeset
298 -- output value, which is appended to the blank filled string
kono
parents:
diff changeset
299 -- whose length is the difference between the expected edited
kono
parents:
diff changeset
300 -- output length and the length of the receiving strings.
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 if TC_Buffer_String & FXF3A00.Edited_Output(i+TC_Offset).all /=
kono
parents:
diff changeset
303 TC_Put_String_8 or
kono
parents:
diff changeset
304 TC_Buffer_String & FXF3A00.Edited_Output(i+TC_Offset).all /=
kono
parents:
diff changeset
305 TC_Move_String_8
kono
parents:
diff changeset
306 then
kono
parents:
diff changeset
307 Report.Failed("Failed case where the output string is " &
kono
parents:
diff changeset
308 "longer than the length of the edited " &
kono
parents:
diff changeset
309 "output result, loop #" & Integer'Image(i) &
kono
parents:
diff changeset
310 ", using data with no decimal places");
kono
parents:
diff changeset
311 end if;
kono
parents:
diff changeset
312 end;
kono
parents:
diff changeset
313 else
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 -- Compare these two string objects with the expected edited
kono
parents:
diff changeset
316 -- output value, which is appended to the blank filled string
kono
parents:
diff changeset
317 -- whose length is the difference between the expected edited
kono
parents:
diff changeset
318 -- output length and the length of the receiving strings.
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 if FXF3A00.Edited_Output(i+TC_Offset).all /= TC_Put_String_8 or
kono
parents:
diff changeset
321 FXF3A00.Edited_Output(i+TC_Offset).all /= TC_Move_String_8
kono
parents:
diff changeset
322 then
kono
parents:
diff changeset
323 Report.Failed("Failed case where the output string is " &
kono
parents:
diff changeset
324 "the same length as the edited output " &
kono
parents:
diff changeset
325 "result, loop #" & Integer'Image(i) &
kono
parents:
diff changeset
326 ", using data with no decimal places");
kono
parents:
diff changeset
327 end if;
kono
parents:
diff changeset
328 end if;
kono
parents:
diff changeset
329 end loop;
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 exception
kono
parents:
diff changeset
332 when others => Report.Failed("Exception raised in Test_Block");
kono
parents:
diff changeset
333 end Test_Block;
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 Report.Result;
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 end CXF3A07;