annotate gcc/testsuite/ada/acats/tests/cxb/cxb4002.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 -- CXB4002.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 procedure To_COBOL converts the character elements
kono
parents:
diff changeset
28 -- of the String parameter Item into COBOL_Character elements of the
kono
parents:
diff changeset
29 -- Alphanumeric type parameter Target, using the Ada_to_COBOL mapping
kono
parents:
diff changeset
30 -- as the basis of conversion.
kono
parents:
diff changeset
31 -- Check that the parameter Last contains the index of the last element
kono
parents:
diff changeset
32 -- of parameter Target that was assigned by To_COBOL.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- Check that Constraint_Error is propagated by procedure To_COBOL
kono
parents:
diff changeset
35 -- when the length of String parameter Item exceeds the length of
kono
parents:
diff changeset
36 -- Alphanumeric parameter Target.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- Check that the procedure To_Ada converts the COBOL_Character
kono
parents:
diff changeset
39 -- elements of the Alphanumeric parameter Item into Character elements
kono
parents:
diff changeset
40 -- of the String parameter Target, using the COBOL_to_Ada mapping array
kono
parents:
diff changeset
41 -- as the basis of conversion.
kono
parents:
diff changeset
42 -- Check that the parameter Last contains the index of the last element
kono
parents:
diff changeset
43 -- of parameter Target that was assigned by To_Ada.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- Check that Constraint_Error is propagated by procedure To_Ada when
kono
parents:
diff changeset
46 -- the length of Alphanumeric parameter Item exceeds the length of
kono
parents:
diff changeset
47 -- String parameter Target.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- TEST DESCRIPTION:
kono
parents:
diff changeset
50 -- This test checks that the procedures To_COBOL and To_Ada produce
kono
parents:
diff changeset
51 -- the correct results, based on a variety of parameter input values.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- In the first series of subtests, the Out parameter results of
kono
parents:
diff changeset
54 -- procedure To_COBOL are compared against expected results,
kono
parents:
diff changeset
55 -- which includes (in the parameter Last) the index in Target of the
kono
parents:
diff changeset
56 -- last element assigned. The situation where procedure To_COBOL raises
kono
parents:
diff changeset
57 -- Constraint_Error (when Item'Length exceeds Target'Length) is also
kono
parents:
diff changeset
58 -- verified.
kono
parents:
diff changeset
59 --
kono
parents:
diff changeset
60 -- In the second series of subtests, the Out parameter results of
kono
parents:
diff changeset
61 -- procedure To_Ada are verified, in a similar manner as is done for
kono
parents:
diff changeset
62 -- procedure To_COBOL. The case of procedure To_Ada raising
kono
parents:
diff changeset
63 -- Constraint_Error is also verified.
kono
parents:
diff changeset
64 --
kono
parents:
diff changeset
65 -- This test assumes that the following characters are all included
kono
parents:
diff changeset
66 -- in the implementation defined type Interfaces.COBOL.COBOL_Character:
kono
parents:
diff changeset
67 -- ' ', 'a'..'z', 'A'..'Z', '0'..'9', '*', '$', '-', '_', and '#'.
kono
parents:
diff changeset
68 --
kono
parents:
diff changeset
69 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
70 -- This test is applicable to all implementations that provide
kono
parents:
diff changeset
71 -- package Interfaces.COBOL. If an implementation provides
kono
parents:
diff changeset
72 -- package Interfaces.COBOL, this test must compile, execute, and
kono
parents:
diff changeset
73 -- report "PASSED".
kono
parents:
diff changeset
74 --
kono
parents:
diff changeset
75 --
kono
parents:
diff changeset
76 -- CHANGE HISTORY:
kono
parents:
diff changeset
77 -- 12 Jan 96 SAIC Initial prerelease version.
kono
parents:
diff changeset
78 -- 30 May 96 SAIC Added applicability criteria for ACVC 2.1.
kono
parents:
diff changeset
79 -- 27 Oct 96 SAIC Incorporated reviewer comments.
kono
parents:
diff changeset
80 --
kono
parents:
diff changeset
81 --!
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 with Report;
kono
parents:
diff changeset
84 with Ada.Strings.Bounded;
kono
parents:
diff changeset
85 with Ada.Strings.Unbounded;
kono
parents:
diff changeset
86 with Interfaces.COBOL; -- N/A => ERROR
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 procedure CXB4002 is
kono
parents:
diff changeset
89 begin
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Report.Test ("CXB4002", "Check that the procedures To_COBOL and " &
kono
parents:
diff changeset
92 "To_Ada produce correct results");
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Test_Block:
kono
parents:
diff changeset
95 declare
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 package Bnd is new Ada.Strings.Bounded.Generic_Bounded_Length(10);
kono
parents:
diff changeset
98 package Unb renames Ada.Strings.Unbounded;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 use Interfaces;
kono
parents:
diff changeset
101 use Bnd, Unb;
kono
parents:
diff changeset
102 use type Interfaces.COBOL.Alphanumeric;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 Alphanumeric_1 : COBOL.Alphanumeric(1..1) := " ";
kono
parents:
diff changeset
106 Alphanumeric_5 : COBOL.Alphanumeric(1..5) := " ";
kono
parents:
diff changeset
107 Alphanumeric_10 : COBOL.Alphanumeric(1..10) := " ";
kono
parents:
diff changeset
108 Alphanumeric_20 : COBOL.Alphanumeric(1..20) := " ";
kono
parents:
diff changeset
109 TC_Alphanumeric_1 : COBOL.Alphanumeric(1..1) := "A";
kono
parents:
diff changeset
110 TC_Alphanumeric_5 : COBOL.Alphanumeric(1..5) := "ab*de";
kono
parents:
diff changeset
111 TC_Alphanumeric_10 : COBOL.Alphanumeric(1..10) := "$1a2b3C4D5";
kono
parents:
diff changeset
112 TC_Alphanumeric_20 : COBOL.Alphanumeric(1..20) := "1234-ABCD_6789#fghij";
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 Bnd_String : Bnd.Bounded_String :=
kono
parents:
diff changeset
115 Bnd.To_Bounded_String(" ");
kono
parents:
diff changeset
116 TC_Bnd_String : Bounded_String :=
kono
parents:
diff changeset
117 To_Bounded_String("$1a2b3C4D5");
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 Unb_String : Unb.Unbounded_String :=
kono
parents:
diff changeset
120 Unb.To_Unbounded_String(" ");
kono
parents:
diff changeset
121 TC_Unb_String : Unbounded_String :=
kono
parents:
diff changeset
122 To_Unbounded_String("ab*de");
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 String_1 : String(1..1) := " ";
kono
parents:
diff changeset
125 String_5 : String(1..5) := " ";
kono
parents:
diff changeset
126 String_10 : String(1..10) := " ";
kono
parents:
diff changeset
127 String_20 : String(1..20) := " ";
kono
parents:
diff changeset
128 TC_String_1 : String(1..1) := "A";
kono
parents:
diff changeset
129 TC_String_20 : String(1..20) := "1234-ABCD_6789#fghij";
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 TC_Alphanumeric : constant COBOL.Alphanumeric := ""; -- null array.
kono
parents:
diff changeset
132 TC_String : constant String := ""; -- null string.
kono
parents:
diff changeset
133 TC_Natural : Natural := 0;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 begin
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 -- Check that the procedure To_COBOL converts the character elements
kono
parents:
diff changeset
139 -- of the String parameter Item into COBOL_Character elements of the
kono
parents:
diff changeset
140 -- Alphanumeric type parameter Target, using the Ada_to_COBOL mapping
kono
parents:
diff changeset
141 -- as the basis of conversion.
kono
parents:
diff changeset
142 -- Check that the parameter Last contains the index of the last element
kono
parents:
diff changeset
143 -- of parameter Target that was assigned by To_COBOL.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 COBOL.To_COBOL(Item => TC_String_1,
kono
parents:
diff changeset
146 Target => Alphanumeric_1,
kono
parents:
diff changeset
147 Last => TC_Natural);
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 if Alphanumeric_1 /= TC_Alphanumeric_1 or
kono
parents:
diff changeset
150 TC_Natural /= TC_Alphanumeric_1'Length or
kono
parents:
diff changeset
151 TC_Natural /= 1
kono
parents:
diff changeset
152 then
kono
parents:
diff changeset
153 Report.Failed("Incorrect result from procedure To_COBOL - 1");
kono
parents:
diff changeset
154 end if;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 COBOL.To_COBOL(To_String(TC_Unb_String),
kono
parents:
diff changeset
157 Target => Alphanumeric_5,
kono
parents:
diff changeset
158 Last => TC_Natural);
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 if Alphanumeric_5 /= TC_Alphanumeric_5 or
kono
parents:
diff changeset
161 TC_Natural /= TC_Alphanumeric_5'Length or
kono
parents:
diff changeset
162 TC_Natural /= 5
kono
parents:
diff changeset
163 then
kono
parents:
diff changeset
164 Report.Failed("Incorrect result from procedure To_COBOL - 2");
kono
parents:
diff changeset
165 end if;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 COBOL.To_COBOL(To_String(TC_Bnd_String),
kono
parents:
diff changeset
168 Alphanumeric_10,
kono
parents:
diff changeset
169 Last => TC_Natural);
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 if Alphanumeric_10 /= TC_Alphanumeric_10 or
kono
parents:
diff changeset
172 TC_Natural /= TC_Alphanumeric_10'Length or
kono
parents:
diff changeset
173 TC_Natural /= 10
kono
parents:
diff changeset
174 then
kono
parents:
diff changeset
175 Report.Failed("Incorrect result from procedure To_COBOL - 3");
kono
parents:
diff changeset
176 end if;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 COBOL.To_COBOL(TC_String_20,
kono
parents:
diff changeset
179 Alphanumeric_20,
kono
parents:
diff changeset
180 TC_Natural);
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 if Alphanumeric_20 /= TC_Alphanumeric_20 or
kono
parents:
diff changeset
183 TC_Natural /= TC_Alphanumeric_20'Length or
kono
parents:
diff changeset
184 TC_Natural /= 20
kono
parents:
diff changeset
185 then
kono
parents:
diff changeset
186 Report.Failed("Incorrect result from procedure To_COBOL - 4");
kono
parents:
diff changeset
187 end if;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 COBOL.To_COBOL(Item => TC_String, -- null string
kono
parents:
diff changeset
190 Target => Alphanumeric_1,
kono
parents:
diff changeset
191 Last => TC_Natural);
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 if TC_Natural /= 0 then
kono
parents:
diff changeset
194 Report.Failed("Incorrect result from procedure To_COBOL, value " &
kono
parents:
diff changeset
195 "returned in parameter Last should be zero, since " &
kono
parents:
diff changeset
196 "parameter Item is null array");
kono
parents:
diff changeset
197 end if;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 -- Check that Constraint_Error is propagated by procedure To_COBOL
kono
parents:
diff changeset
202 -- when the length of String parameter Item exceeds the length of
kono
parents:
diff changeset
203 -- Alphanumeric parameter Target.
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 begin
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 COBOL.To_COBOL(Item => TC_String_20,
kono
parents:
diff changeset
208 Target => Alphanumeric_10,
kono
parents:
diff changeset
209 Last => TC_Natural);
kono
parents:
diff changeset
210 Report.Failed("Constraint_Error not raised by procedure To_COBOL " &
kono
parents:
diff changeset
211 "when Item'Length exceeds Target'Length");
kono
parents:
diff changeset
212 exception
kono
parents:
diff changeset
213 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
214 when others =>
kono
parents:
diff changeset
215 Report.Failed("Incorrect exception raised by procedure To_COBOL " &
kono
parents:
diff changeset
216 "when Item'Length exceeds Target'Length");
kono
parents:
diff changeset
217 end;
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 -- Check that the procedure To_Ada converts the COBOL_Character
kono
parents:
diff changeset
221 -- elements of the Alphanumeric parameter Item into Character elements
kono
parents:
diff changeset
222 -- of the String parameter Target, using the COBOL_to_Ada mapping array
kono
parents:
diff changeset
223 -- as the basis of conversion.
kono
parents:
diff changeset
224 -- Check that the parameter Last contains the index of the last element
kono
parents:
diff changeset
225 -- of parameter Target that was assigned by To_Ada.
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 COBOL.To_Ada(Item => TC_Alphanumeric_1,
kono
parents:
diff changeset
228 Target => String_1,
kono
parents:
diff changeset
229 Last => TC_Natural);
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 if String_1 /= TC_String_1 or
kono
parents:
diff changeset
232 TC_Natural /= TC_String_1'Length or
kono
parents:
diff changeset
233 TC_Natural /= 1
kono
parents:
diff changeset
234 then
kono
parents:
diff changeset
235 Report.Failed("Incorrect result from procedure To_Ada - 1");
kono
parents:
diff changeset
236 end if;
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 COBOL.To_Ada(TC_Alphanumeric_5,
kono
parents:
diff changeset
239 Target => String_5,
kono
parents:
diff changeset
240 Last => TC_Natural);
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 if String_5 /= To_String(TC_Unb_String) or
kono
parents:
diff changeset
243 TC_Natural /= Length(TC_Unb_String) or
kono
parents:
diff changeset
244 TC_Natural /= 5
kono
parents:
diff changeset
245 then
kono
parents:
diff changeset
246 Report.Failed("Incorrect result from procedure To_Ada - 2");
kono
parents:
diff changeset
247 end if;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 COBOL.To_Ada(TC_Alphanumeric_10,
kono
parents:
diff changeset
250 String_10,
kono
parents:
diff changeset
251 Last => TC_Natural);
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 if String_10 /= To_String(TC_Bnd_String) or
kono
parents:
diff changeset
254 TC_Natural /= Length(TC_Bnd_String) or
kono
parents:
diff changeset
255 TC_Natural /= 10
kono
parents:
diff changeset
256 then
kono
parents:
diff changeset
257 Report.Failed("Incorrect result from procedure To_Ada - 3");
kono
parents:
diff changeset
258 end if;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 COBOL.To_Ada(TC_Alphanumeric_20,
kono
parents:
diff changeset
261 String_20,
kono
parents:
diff changeset
262 TC_Natural);
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 if String_20 /= TC_String_20 or
kono
parents:
diff changeset
265 TC_Natural /= TC_String_20'Length or
kono
parents:
diff changeset
266 TC_Natural /= 20
kono
parents:
diff changeset
267 then
kono
parents:
diff changeset
268 Report.Failed("Incorrect result from procedure To_Ada - 4");
kono
parents:
diff changeset
269 end if;
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 COBOL.To_Ada(Item => TC_Alphanumeric, -- null array.
kono
parents:
diff changeset
272 Target => String_20,
kono
parents:
diff changeset
273 Last => TC_Natural);
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 if TC_Natural /= 0 then
kono
parents:
diff changeset
276 Report.Failed("Incorrect result from procedure To_Ada, value " &
kono
parents:
diff changeset
277 "returned in parameter Last should be zero, since " &
kono
parents:
diff changeset
278 "parameter Item is null array");
kono
parents:
diff changeset
279 end if;
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 -- Check that Constraint_Error is propagated by procedure To_Ada when
kono
parents:
diff changeset
284 -- the length of Alphanumeric parameter Item exceeds the length of
kono
parents:
diff changeset
285 -- String parameter Target.
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 begin
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 COBOL.To_Ada(Item => TC_Alphanumeric_10,
kono
parents:
diff changeset
290 Target => String_5,
kono
parents:
diff changeset
291 Last => TC_Natural);
kono
parents:
diff changeset
292 Report.Failed("Constraint_Error not raised by procedure To_Ada " &
kono
parents:
diff changeset
293 "when Item'Length exceeds Target'Length");
kono
parents:
diff changeset
294 exception
kono
parents:
diff changeset
295 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
296 when others =>
kono
parents:
diff changeset
297 Report.Failed("Incorrect exception raised by procedure To_Ada " &
kono
parents:
diff changeset
298 "when Item'Length exceeds Target'Length");
kono
parents:
diff changeset
299 end;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 exception
kono
parents:
diff changeset
303 when others => Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
304 end Test_Block;
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 Report.Result;
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 end CXB4002;