2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / ada / acats / tests / cxf / cxf3001.a
blob1b9abca153f820fac0831253c69bff71a8807c89
1 -- CXF3001.A
2 --
3 -- Grant of Unlimited Rights
4 --
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
14 -- to do so.
16 -- DISCLAIMER
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.
24 --*
26 -- OBJECTIVE:
27 -- Check that the edited output string value returned by Function Image
28 -- is correct.
30 -- TEST DESCRIPTION:
31 -- This test is structured using tables of data, consisting of
32 -- numerical values, picture strings, and expected image
33 -- result strings.
35 -- Each picture string is checked for validity, and an invalid picture
36 -- string will cause immediate test failure on its first pass through
37 -- the evaluation loop. Inside the evaluation loop, each decimal data
38 -- item is combined with each of the picture strings as parameters to a
39 -- call to Image, and the result of each call is compared to an
40 -- expected edited output result string.
41 --
42 --
43 -- CHANGE HISTORY:
44 -- 24 Feb 95 SAIC Initial prerelease version.
45 -- 23 Jun 95 SAIC Corrected call to functions Valid and To_Picture.
46 -- 22 Aug 95 SAIC Test name changed to CXF3001 (from CXF3301) to
47 -- conform to naming conventions.
48 -- 24 Feb 97 CTA.PWB Corrected picture strings and expected results.
49 --!
51 with Ada.Text_IO.Editing;
52 with Report;
54 procedure CXF3001 is
55 begin
57 Report.Test ("CXF3001", "Check that the string value returned by " &
58 "Function Image is correct");
60 Test_Block:
61 declare
63 use Ada.Text_IO;
65 Number_Of_Decimal_Items : constant := 5;
66 Number_Of_Picture_Strings : constant := 4;
67 Number_Of_Expected_Results : constant := Number_Of_Decimal_Items *
68 Number_Of_Picture_Strings;
70 type String_Pointer_Type is access String;
72 -- Define a decimal data type, and instantiate the Decimal_Output
73 -- generic package for the data type.
75 type Decimal_Data_Type is delta 0.01 digits 16;
76 package Ed_Out is new Editing.Decimal_Output (Decimal_Data_Type);
78 -- Define types for the arrays of data that will hold the decimal data
79 -- values, picture strings, and expected edited output results.
81 type Decimal_Data_Array_Type is
82 array (Integer range <>) of Decimal_Data_Type;
84 type Picture_String_Array_Type is
85 array (Integer range <>) of String_Pointer_Type;
87 type Edited_Output_Results_Array_Type is
88 array (Integer range <>) of String_Pointer_Type;
90 -- Define the data arrays for this test.
92 Decimal_Data :
93 Decimal_Data_Array_Type(1..Number_Of_Decimal_Items) :=
94 ( 1 => 5678.90,
95 2 => -6789.01,
96 3 => 0.00,
97 4 => 0.20,
98 5 => 3.45
101 Picture_Strings :
102 Picture_String_Array_Type(1..Number_Of_Picture_Strings) :=
103 ( 1 => new String'("-$$_$$9.99"),
104 2 => new String'("-$$_$$$.$$"),
105 3 => new String'("-ZZZZ.ZZ"),
106 4 => new String'("-$$$_999.99")
109 Edited_Output :
110 Edited_Output_Results_Array_Type(1..Number_Of_Expected_Results) :=
111 ( 1 => new String'(" $5,678.90"),
112 2 => new String'(" $5,678.90"),
113 3 => new String'(" 5678.90"),
114 4 => new String'(" $5,678.90"),
116 5 => new String'("-$6,789.01"),
117 6 => new String'("-$6,789.01"),
118 7 => new String'("-6789.01"),
119 8 => new String'("- $6,789.01"),
121 9 => new String'(" $0.00"),
122 10 => new String'(" "),
123 11 => new String'(" "),
124 12 => new String'(" $ 000.00"),
126 13 => new String'(" $0.20"),
127 14 => new String'(" $.20"),
128 15 => new String'(" .20"),
129 16 => new String'(" $ 000.20"),
131 17 => new String'(" $3.45"),
132 18 => new String'(" $3.45"),
133 19 => new String'(" 3.45"),
134 20 => new String'(" $ 003.45")
137 TC_Picture : Editing.Picture;
138 TC_Loop_Count : Natural := 0;
140 begin
142 -- Compare string result of Image with expected edited output string.
144 Evaluate_Edited_Output:
145 for i in 1..Number_Of_Decimal_Items loop
146 for j in 1..Number_Of_Picture_Strings loop
148 TC_Loop_Count := TC_Loop_Count + 1;
150 -- Check on the validity of the picture strings prior to
151 -- processing.
153 if Editing.Valid(Picture_Strings(j).all) then
155 -- Create the picture object from the picture string.
156 TC_Picture := Editing.To_Picture(Picture_Strings(j).all);
158 -- Compare actual edited output result of Function Image with
159 -- the expected result.
161 if Ed_Out.Image(Decimal_Data(i), TC_Picture) /=
162 Edited_Output(TC_Loop_Count).all
163 then
164 Report.Failed("Incorrect result from Function Image, " &
165 "when used with decimal data item # " &
166 Integer'Image(i) &
167 " and picture string # " &
168 Integer'Image(j));
169 end if;
171 else
172 Report.Failed("Picture String # " & Integer'Image(j) &
173 "reported as being invalid");
174 -- Immediate test failure if a string is invalid.
175 exit Evaluate_Edited_Output;
176 end if;
178 end loop;
179 end loop Evaluate_Edited_Output;
181 exception
182 when Editing.Picture_Error =>
183 Report.Failed ("Picture_Error raised in Test_Block");
184 when Layout_Error =>
185 Report.Failed ("Layout_Error raised in Test_Block");
186 when others =>
187 Report.Failed ("Exception raised in Test_Block");
188 end Test_Block;
190 Report.Result;
192 end CXF3001;