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 Ada.Text_IO.Editing.Put and Ada.Strings.Fixed.Move
28 -- have the same effect in putting edited output results into string
32 -- This test is structured using tables of data, consisting of
33 -- numerical values, picture strings, and expected image
34 -- result strings. These data tables are found in package FXF3A00.
36 -- The operation of the two above subprograms are examined twice, first
37 -- with the output of an edited output string to a receiving string
38 -- object of equal size, the other to a receiving string object of
39 -- larger size, where justification and padding are considered.
40 -- The procedure Editing.Put will place an edited output string into
41 -- a larger receiving string with right justification and blank fill.
42 -- Procedure Move has parameter control of justification and fill, and
43 -- in this test will mirror Put by specifying right justification and
46 -- In the cases where the edited output string is of shorter length
47 -- than the receiving string object, a blank-filled constant string
48 -- will be catenated to the front of the expected edited output string
49 -- for comparison with the receiving string object, enabling direct
50 -- string comparison for result verification.
53 -- The following files comprise this test:
55 -- FXF3A00.A (foundation code)
60 -- 30 JAN 95 SAIC Initial prerelease version.
61 -- 11 MAR 97 PWB.CTA Fixed string lengths
65 with Ada
.Text_IO
.Editing
;
66 with Ada
.Strings
.Fixed
;
72 Report
.Test
("CXF3A07", "Check that Ada.Text_IO.Editing.Put and " &
73 "Ada.Strings.Fixed.Move have the same " &
74 "effect in putting edited output results " &
75 "into string variables");
81 -- Instantiate the Decimal_Output generic package for two
82 -- different decimal data types.
84 package Pack_2DP
is -- Uses decimal type with delta 0.01.
85 new Editing
.Decimal_Output
(FXF3A00
.Decimal_Type_2DP
);
87 package Pack_NDP
is -- Uses decimal type with delta 1.0.
88 new Editing
.Decimal_Output
(Num
=> FXF3A00
.Decimal_Type_NDP
,
89 Default_Currency
=> "$",
91 Default_Separator
=> ',',
92 Default_Radix_Mark
=> '.');
94 TC_Picture
: Editing
.Picture
;
95 TC_Start_Loop
: Integer := 0;
96 TC_End_Loop
: Integer := 0;
97 TC_Offset
: Integer := 0;
98 TC_Length
: Natural := 0;
100 TC_Put_String_20
, -- Longer than the longest edited
101 TC_Move_String_20
: String(1..20); -- output string.
103 TC_Put_String_17
, -- Exact length of longest edited
104 TC_Move_String_17
: String(1..17); -- output string in 2DP-US data set.
106 TC_Put_String_8
, -- Exact length of longest edited
107 TC_Move_String_8
: String(1..8); -- output string in NDP-US data set.
112 -- Examine cases where the output string is longer than the length
113 -- of the edited output result. Use the instantiation of
114 -- Decimal_Output specific to data with two decimal places.
117 TC_End_Loop
:= FXF3A00
.Number_of_2DP_Items
- -- 10
118 FXF3A00
.Number_Of_Foreign_Strings
;
120 for i
in TC_Start_Loop
..TC_End_Loop
loop -- 1..10
122 -- Create the picture object from the picture string.
124 TC_Picture
:= Editing
.To_Picture
(FXF3A00
.Valid_Strings
(i
).all,
125 Blank_When_Zero
=> False);
127 -- Determine the actual length of the edited output string
128 -- that is expected from Put and Image.
130 TC_Length
:= Pack_2DP
.Length
(Pic
=> TC_Picture
,
133 -- Determine the difference in length between the receiving string
134 -- object and the expected length of the edited output string.
135 -- Define a blank filled string constant with length equal to this
136 -- length difference.
139 TC_Length_Diff
: Integer := TC_Put_String_20
'Length -
141 TC_Buffer_String
: constant String(1..TC_Length_Diff
) :=
145 -- Fill the two receiving string objects with edited output,
146 -- using the two different methods (Put and Move).
148 Pack_2DP
.Put
(To
=> TC_Put_String_20
,
149 Item
=> FXF3A00
.Data_With_2DP
(i
),
157 Ada
.Strings
.Fixed
.Move
158 (Source
=> Pack_2DP
.Image
(Item
=> FXF3A00
.Data_With_2DP
(i
),
164 Target
=> TC_Move_String_20
,
165 Drop
=> Ada
.Strings
.Error
,
166 Justify
=> Ada
.Strings
.Right
,
167 Pad
=> Ada
.Strings
.Space
);
169 -- Each receiving string object is now filled with the edited
170 -- output result, right justified.
171 -- Compare these two string objects with the expected edited
172 -- output value, which is appended to the blank filled string
173 -- whose length is the difference between the expected edited
174 -- output length and the length of the receiving strings.
176 if TC_Buffer_String
& FXF3A00
.Edited_Output
(i
).all /=
178 TC_Buffer_String
& FXF3A00
.Edited_Output
(i
).all /=
181 Report
.Failed
("Failed case where the output string is " &
182 "longer than the length of the edited " &
183 "output result, loop #" & Integer'Image(i
));
188 Report
.Failed
("Layout_Error raised when the output string " &
189 "is longer than the length of the edited " &
190 "output result, loop #" & Integer'Image(i
));
192 Report
.Failed
("Exception raised when the output string is " &
193 "longer than the length of the edited " &
194 "output result, loop #" & Integer'Image(i
));
199 -- Repeat the above loop, but only evaluate three cases - those where
200 -- the length of the expected edited output string is the exact length
201 -- of the receiving strings (no justification will be required within
202 -- the string. This series of evaluations again uses decimal data
203 -- with two decimal places.
205 for i
in TC_Start_Loop
..TC_End_Loop
loop -- 1..10
210 -- Create the picture object from the picture string.
212 Editing
.To_Picture
(FXF3A00
.Valid_Strings
(i
).all);
214 -- Fill the two receiving string objects with edited output,
215 -- using the two different methods (Put and Move).
216 -- Use default parameters in the various calls where possible.
218 Pack_2DP
.Put
(To
=> TC_Put_String_17
,
219 Item
=> FXF3A00
.Data_With_2DP
(i
),
223 Ada
.Strings
.Fixed
.Move
224 (Source
=> Pack_2DP
.Image
(Item
=> FXF3A00
.Data_With_2DP
(i
),
226 Target
=> TC_Move_String_17
);
228 -- Each receiving string object is now filled with the edited
229 -- output result. Compare these two string objects with the
230 -- expected edited output value.
232 if FXF3A00
.Edited_Output
(i
).all /= TC_Put_String_17
or
233 FXF3A00
.Edited_Output
(i
).all /= TC_Move_String_17
235 Report
.Failed
("Failed case where the output string is " &
236 "the exact length of the edited output " &
237 "result, loop #" & Integer'Image(i
));
245 -- Evaluate a mix of cases, where the expected edited output string
246 -- length is either exactly as long or shorter than the receiving
247 -- output string parameter. This series of evaluations uses decimal
248 -- data with no decimal places.
250 TC_Start_Loop
:= TC_End_Loop
+ 1; -- 11
251 TC_End_Loop
:= TC_Start_Loop
+ -- 22
252 FXF3A00
.Number_of_NDP_Items
- 1;
253 TC_Offset
:= FXF3A00
.Number_of_Foreign_Strings
; -- 10
254 -- This offset is required due to the arrangement of data within the
255 -- tables found in FXF3A00.
257 for i
in TC_Start_Loop
..TC_End_Loop
loop -- 11..22
259 -- Create the picture object from the picture string.
261 TC_Picture
:= Editing
.To_Picture
(FXF3A00
.Valid_Strings
(i
).all);
263 -- Determine the actual length of the edited output string
264 -- that is expected from Put and Image.
266 TC_Length
:= Pack_NDP
.Length
(TC_Picture
);
268 -- Fill the two receiving string objects with edited output,
269 -- using the two different methods (Put and Move).
271 Pack_NDP
.Put
(TC_Put_String_8
,
272 FXF3A00
.Data_With_NDP
(i
-TC_Offset
),
275 Ada
.Strings
.Fixed
.Move
276 (Pack_NDP
.Image
(FXF3A00
.Data_With_NDP
(i
-TC_Offset
), TC_Picture
),
282 -- Determine if there is a difference in length between the
283 -- receiving string object and the expected length of the edited
284 -- output string. If so, then define a blank filled string constant
285 -- with length equal to this length difference.
287 if TC_Length
< TC_Put_String_8
'Length then
289 TC_Length_Diff
: Integer := TC_Put_String_8
'Length -
291 TC_Buffer_String
: constant String(1..TC_Length_Diff
) :=
295 -- Each receiving string object is now filled with the edited
296 -- output result, right justified.
297 -- Compare these two string objects with the expected edited
298 -- output value, which is appended to the blank filled string
299 -- whose length is the difference between the expected edited
300 -- output length and the length of the receiving strings.
302 if TC_Buffer_String
& FXF3A00
.Edited_Output
(i
+TC_Offset
).all /=
304 TC_Buffer_String
& FXF3A00
.Edited_Output
(i
+TC_Offset
).all /=
307 Report
.Failed
("Failed case where the output string is " &
308 "longer than the length of the edited " &
309 "output result, loop #" & Integer'Image(i
) &
310 ", using data with no decimal places");
315 -- Compare these two string objects with the expected edited
316 -- output value, which is appended to the blank filled string
317 -- whose length is the difference between the expected edited
318 -- output length and the length of the receiving strings.
320 if FXF3A00
.Edited_Output
(i
+TC_Offset
).all /= TC_Put_String_8
or
321 FXF3A00
.Edited_Output
(i
+TC_Offset
).all /= TC_Move_String_8
323 Report
.Failed
("Failed case where the output string is " &
324 "the same length as the edited output " &
325 "result, loop #" & Integer'Image(i
) &
326 ", using data with no decimal places");
332 when others => Report
.Failed
("Exception raised in Test_Block");