annotate gcc/testsuite/ada/acats/tests/cxb/cxb3007.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 -- CXB3007.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_C converts the Wide_Character elements
kono
parents:
diff changeset
28 -- of a Wide_String parameter into wchar_t elements of the wchar_array
kono
parents:
diff changeset
29 -- parameter Target, with wide_nul termination if parameter Append_Nul
kono
parents:
diff changeset
30 -- is true.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- Check that the out parameter Count of procedure To_C is set to the
kono
parents:
diff changeset
33 -- appropriate value for both the wide_nul/no wide_nul terminated cases.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Check that Constraint_Error is propagated by procedure To_C if the
kono
parents:
diff changeset
36 -- length of the wchar_array parameter Target is not sufficient to
kono
parents:
diff changeset
37 -- hold the converted Wide_String value.
kono
parents:
diff changeset
38 --
kono
parents:
diff changeset
39 -- Check that the Procedure To_Ada converts wchar_t elements of the
kono
parents:
diff changeset
40 -- wchar_array parameter Item to the corresponding Wide_Character
kono
parents:
diff changeset
41 -- elements of Wide_String out parameter Target.
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- Check that Constraint_Error is propagated by Procedure To_Ada if the
kono
parents:
diff changeset
44 -- length of Wide_String parameter Target is not long enough to hold the
kono
parents:
diff changeset
45 -- converted wchar_array value.
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 -- Check that Terminator_Error is propagated by Procedure To_Ada if the
kono
parents:
diff changeset
48 -- parameter Trim_Nul is set to True, but the actual Item parameter
kono
parents:
diff changeset
49 -- contains no wide_nul wchar_t.
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 -- TEST DESCRIPTION:
kono
parents:
diff changeset
52 -- This test uses a variety of Wide_String, and wchar_array objects to
kono
parents:
diff changeset
53 -- test versions of the To_C and To_Ada procedures.
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- This test assumes that the following characters are all included
kono
parents:
diff changeset
56 -- in the implementation defined type Interfaces.C.wchar_t:
kono
parents:
diff changeset
57 -- ' ', 'a'..'z', 'A'..'Z', and '-'.
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
60 -- This test is applicable to all implementations that provide
kono
parents:
diff changeset
61 -- package Interfaces.C. If an implementation provides
kono
parents:
diff changeset
62 -- package Interfaces.C, this test must compile, execute, and
kono
parents:
diff changeset
63 -- report "PASSED".
kono
parents:
diff changeset
64 --
kono
parents:
diff changeset
65 -- CHANGE HISTORY:
kono
parents:
diff changeset
66 -- 01 Sep 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
67 -- 09 May 96 SAIC Incorporated reviewer comments for ACVC 2.1.
kono
parents:
diff changeset
68 -- 26 Oct 96 SAIC Incorporated reviewer comments.
kono
parents:
diff changeset
69 -- 14 Sep 99 RLB Removed incorrect and unnecessary
kono
parents:
diff changeset
70 -- Unchecked_Conversion.
kono
parents:
diff changeset
71 --
kono
parents:
diff changeset
72 --!
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 with Report;
kono
parents:
diff changeset
75 with Interfaces.C; -- N/A => ERROR
kono
parents:
diff changeset
76 with Ada.Characters.Latin_1;
kono
parents:
diff changeset
77 with Ada.Characters.Handling;
kono
parents:
diff changeset
78 with Ada.Exceptions;
kono
parents:
diff changeset
79 with Ada.Strings.Wide_Fixed;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure CXB3007 is
kono
parents:
diff changeset
82 begin
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 Report.Test ("CXB3007", "Check that the procedures To_C and To_Ada " &
kono
parents:
diff changeset
85 "for wide strings produce correct results");
kono
parents:
diff changeset
86 Test_Block:
kono
parents:
diff changeset
87 declare
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 use Interfaces, Interfaces.C;
kono
parents:
diff changeset
90 use Ada.Characters, Ada.Characters.Handling;
kono
parents:
diff changeset
91 use Ada.Exceptions;
kono
parents:
diff changeset
92 use Ada.Strings.Wide_Fixed;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 TC_Short_Wide_String : Wide_String(1..4) :=
kono
parents:
diff changeset
95 (others => Wide_Character'First);
kono
parents:
diff changeset
96 TC_Wide_String : Wide_String(1..8) :=
kono
parents:
diff changeset
97 (others => Wide_Character'First);
kono
parents:
diff changeset
98 TC_wchar_array : wchar_array(0..7) := (others => wchar_t'First);
kono
parents:
diff changeset
99 TC_size_t_Count : size_t := size_t'First;
kono
parents:
diff changeset
100 TC_Natural_Count : Natural := Natural'First;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 -- We can use the wide character forms of To_Ada and To_C here to check
kono
parents:
diff changeset
104 -- the results; they were tested in CXB3006. We give them different
kono
parents:
diff changeset
105 -- names to avoid confusion below.
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 function Wide_Character_to_wchar_t (Source : in Wide_Character)
kono
parents:
diff changeset
108 return wchar_t renames To_C;
kono
parents:
diff changeset
109 function wchar_t_to_Wide_Character (Source : in wchar_t)
kono
parents:
diff changeset
110 return Wide_Character renames To_Ada;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 begin
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 -- Check that the procedure To_C converts the Wide_Character elements
kono
parents:
diff changeset
115 -- of a Wide_String parameter into wchar_t elements of wchar_array out
kono
parents:
diff changeset
116 -- parameter Target.
kono
parents:
diff changeset
117 --
kono
parents:
diff changeset
118 -- Case of wide_nul termination.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 TC_Wide_String(1..6) := "abcdef";
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 To_C (Item => TC_Wide_String(1..6), -- Source slice of length 6.
kono
parents:
diff changeset
123 Target => TC_wchar_array,
kono
parents:
diff changeset
124 Count => TC_size_t_Count,
kono
parents:
diff changeset
125 Append_Nul => True);
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 -- Check that the out parameter Count is set to the appropriate value
kono
parents:
diff changeset
128 -- for the wide_nul terminated case.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 if TC_size_t_Count /= 7 then
kono
parents:
diff changeset
131 Report.Failed("Incorrect setting of out parameter Count by " &
kono
parents:
diff changeset
132 "Procedure To_C when Append_Nul => True");
kono
parents:
diff changeset
133 end if;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 for i in 1..TC_size_t_Count-1 loop
kono
parents:
diff changeset
136 if wchar_t_to_Wide_Character(TC_wchar_array(i-1)) /=
kono
parents:
diff changeset
137 TC_Wide_String(Integer(i))
kono
parents:
diff changeset
138 then
kono
parents:
diff changeset
139 Report.Failed("Incorrect result from Procedure To_C when " &
kono
parents:
diff changeset
140 "checking individual wchar_t values, case of " &
kono
parents:
diff changeset
141 "Append_Nul => True; " &
kono
parents:
diff changeset
142 "wchar_t position = " & Integer'Image(Integer(i)));
kono
parents:
diff changeset
143 end if;
kono
parents:
diff changeset
144 end loop;
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 if not Is_Nul_Terminated(TC_wchar_array) then
kono
parents:
diff changeset
147 Report.Failed("No wide_nul wchar_t appended to the wchar_array " &
kono
parents:
diff changeset
148 "result from Procedure To_C when Append_Nul => True");
kono
parents:
diff changeset
149 end if;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 if TC_wchar_array(0..6) /= To_C("abcdef", True) then
kono
parents:
diff changeset
152 Report.Failed("Incorrect result from Procedure To_C when " &
kono
parents:
diff changeset
153 "directly comparing wchar_array results, case " &
kono
parents:
diff changeset
154 "of Append_Nul => True");
kono
parents:
diff changeset
155 end if;
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- Check Procedure To_C with no wide_nul termination.
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 TC_wchar_array := (others => Wide_Character_to_wchar_t('M'));
kono
parents:
diff changeset
161 TC_Wide_String(1..4) := "WXYZ";
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 To_C (Item => TC_Wide_String(1..4), -- Source slice of length 4.
kono
parents:
diff changeset
164 Target => TC_wchar_array,
kono
parents:
diff changeset
165 Count => TC_size_t_Count,
kono
parents:
diff changeset
166 Append_Nul => False);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 -- Check that the out parameter Count is set to the appropriate value
kono
parents:
diff changeset
169 -- for the non-wide_nul terminated case.
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 if TC_size_t_Count /= 4 then
kono
parents:
diff changeset
172 Report.Failed("Incorrect setting of out parameter Count by " &
kono
parents:
diff changeset
173 "Procedure To_C when Append_Nul => False");
kono
parents:
diff changeset
174 end if;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 for i in 1..TC_size_t_Count loop
kono
parents:
diff changeset
177 if wchar_t_to_Wide_Character(TC_wchar_array(i-1)) /=
kono
parents:
diff changeset
178 TC_Wide_String(Integer(i))
kono
parents:
diff changeset
179 then
kono
parents:
diff changeset
180 Report.Failed("Incorrect result from Procedure To_C when " &
kono
parents:
diff changeset
181 "checking individual wchar_t values, case of " &
kono
parents:
diff changeset
182 "Append_Nul => False; " &
kono
parents:
diff changeset
183 "wchar_t position = " & Integer'Image(Integer(i)));
kono
parents:
diff changeset
184 end if;
kono
parents:
diff changeset
185 end loop;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 if Is_Nul_Terminated(TC_wchar_array) then
kono
parents:
diff changeset
188 Report.Failed
kono
parents:
diff changeset
189 ("The wide_nul wchar_t was appended to the wchar_array " &
kono
parents:
diff changeset
190 "result of Procedure To_C when Append_Nul => False");
kono
parents:
diff changeset
191 end if;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 if TC_wchar_array(0..3) /= To_C("WXYZ", False) then
kono
parents:
diff changeset
194 Report.Failed("Incorrect result from Procedure To_C when " &
kono
parents:
diff changeset
195 "directly comparing wchar_array results, case " &
kono
parents:
diff changeset
196 "of Append_Nul => False");
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 raised by procedure To_C if the
kono
parents:
diff changeset
202 -- length of the target wchar_array parameter is not sufficient to
kono
parents:
diff changeset
203 -- hold the converted Wide_String value (plus wide_nul if Append_Nul
kono
parents:
diff changeset
204 -- is True).
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 TC_wchar_array := (others => wchar_t'First);
kono
parents:
diff changeset
207 begin
kono
parents:
diff changeset
208 To_C("A string too long",
kono
parents:
diff changeset
209 TC_wchar_array,
kono
parents:
diff changeset
210 TC_size_t_Count,
kono
parents:
diff changeset
211 Append_Nul => True);
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Report.Failed("Constraint_Error not raised when the Target " &
kono
parents:
diff changeset
214 "parameter of Procedure To_C is not long enough " &
kono
parents:
diff changeset
215 "to hold the converted Wide_String");
kono
parents:
diff changeset
216 Report.Comment
kono
parents:
diff changeset
217 (To_Character(wchar_t_to_Wide_Character(TC_wchar_array(0))) &
kono
parents:
diff changeset
218 " printed to defeat optimization");
kono
parents:
diff changeset
219 exception
kono
parents:
diff changeset
220 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
221 when others =>
kono
parents:
diff changeset
222 Report.Failed("Incorrect exception raised by Procedure " &
kono
parents:
diff changeset
223 "To_C when the Target parameter is not long " &
kono
parents:
diff changeset
224 "enough to contain the wchar_array result");
kono
parents:
diff changeset
225 end;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 -- Check that the procedure To_Ada converts wchar_t elements of the
kono
parents:
diff changeset
230 -- wchar_array parameter Item to the corresponding Wide_Character
kono
parents:
diff changeset
231 -- elements of Wide_String out parameter Target, with result wide
kono
parents:
diff changeset
232 -- string length based on the Trim_Nul parameter.
kono
parents:
diff changeset
233 --
kono
parents:
diff changeset
234 -- Case of appended wide_nul wchar_t on the wchar_array In parameter.
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 TC_wchar_array :=
kono
parents:
diff changeset
237 To_C ("ACVC-95", Append_Nul => True); -- 8 total chars.
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 To_Ada (Item => TC_wchar_array,
kono
parents:
diff changeset
240 Target => TC_Wide_String,
kono
parents:
diff changeset
241 Count => TC_Natural_Count,
kono
parents:
diff changeset
242 Trim_Nul => False);
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 if TC_Natural_Count /= 8 then
kono
parents:
diff changeset
245 Report.Failed("Incorrect value returned in out parameter Count " &
kono
parents:
diff changeset
246 "by Procedure To_Ada, case of Trim_Nul => False");
kono
parents:
diff changeset
247 end if;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 for i in 1..TC_Natural_Count loop
kono
parents:
diff changeset
250 if Wide_Character_to_wchar_t(TC_Wide_String(i)) /=
kono
parents:
diff changeset
251 TC_wchar_array(size_t(i-1))
kono
parents:
diff changeset
252 then
kono
parents:
diff changeset
253 Report.Failed("Incorrect result from Procedure To_Ada when " &
kono
parents:
diff changeset
254 "checking individual wchar_t values, case of " &
kono
parents:
diff changeset
255 "Trim_Nul => False, when a wide_nul is present " &
kono
parents:
diff changeset
256 "in the wchar_array input parameter; " &
kono
parents:
diff changeset
257 "position = " & Integer'Image(Integer(i)));
kono
parents:
diff changeset
258 end if;
kono
parents:
diff changeset
259 end loop;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 if TC_Wide_String(TC_Natural_Count) /= To_Wide_Character(Latin_1.Nul)
kono
parents:
diff changeset
262 then
kono
parents:
diff changeset
263 Report.Failed("Last Wide_Character of Wide_String result of " &
kono
parents:
diff changeset
264 "Procedure To_Ada is not Nul, even though a " &
kono
parents:
diff changeset
265 "wide_nul was present in the wchar_array argument, " &
kono
parents:
diff changeset
266 "and the Trim_Nul parameter was set to False");
kono
parents:
diff changeset
267 end if;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 TC_Wide_String := (others => Wide_Character'First);
kono
parents:
diff changeset
271 TC_wchar_array(0..3) := To_C ("XYz", Append_Nul => True); -- 4 chars.
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 To_Ada (Item => TC_wchar_array,
kono
parents:
diff changeset
274 Target => TC_Wide_String,
kono
parents:
diff changeset
275 Count => TC_Natural_Count,
kono
parents:
diff changeset
276 Trim_Nul => True);
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 if TC_Natural_Count /= 3 then
kono
parents:
diff changeset
279 Report.Failed("Incorrect value returned in out parameter Count " &
kono
parents:
diff changeset
280 "by Procedure To_Ada, case of Trim_Nul => True");
kono
parents:
diff changeset
281 end if;
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 for i in 1..TC_Natural_Count loop
kono
parents:
diff changeset
284 if Wide_Character_to_wchar_t(TC_Wide_String(i)) /=
kono
parents:
diff changeset
285 TC_wchar_array(size_t(i-1))
kono
parents:
diff changeset
286 then
kono
parents:
diff changeset
287 Report.Failed("Incorrect result from Procedure To_Ada when " &
kono
parents:
diff changeset
288 "checking individual wchar_t values, case of " &
kono
parents:
diff changeset
289 "Trim_Nul => True, when a wide_nul is present " &
kono
parents:
diff changeset
290 "in the wchar_array input parameter; " &
kono
parents:
diff changeset
291 "position = " & Integer'Image(Integer(i)));
kono
parents:
diff changeset
292 end if;
kono
parents:
diff changeset
293 end loop;
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 if TC_Wide_String(TC_Natural_Count) = To_Wide_Character(Latin_1.Nul)
kono
parents:
diff changeset
296 then
kono
parents:
diff changeset
297 Report.Failed("Last Wide_Character of Wide_String result of " &
kono
parents:
diff changeset
298 "Procedure To_Ada is Nul, even though the " &
kono
parents:
diff changeset
299 "Trim_Nul parameter was set to True");
kono
parents:
diff changeset
300 end if;
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 if TC_Wide_String(TC_Natural_Count+1) /= Wide_Character'First then
kono
parents:
diff changeset
303 Report.Failed("Incorrect replacement from To_Ada");
kono
parents:
diff changeset
304 end if;
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 -- Case of no wide_nul wchar_t present in the wchar_array argument.
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 TC_Wide_String := (others => Wide_Character'First);
kono
parents:
diff changeset
310 TC_wchar_array := To_C ("ABCDWXYZ", Append_Nul => False);
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 To_Ada (Item => TC_wchar_array,
kono
parents:
diff changeset
313 Target => TC_Wide_String,
kono
parents:
diff changeset
314 Count => TC_Natural_Count,
kono
parents:
diff changeset
315 Trim_Nul => False);
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 if TC_Natural_Count /= 8 then
kono
parents:
diff changeset
318 Report.Failed("Incorrect value returned in out parameter Count " &
kono
parents:
diff changeset
319 "by Procedure To_Ada, case of Trim_Nul => False, " &
kono
parents:
diff changeset
320 "with no wide_nul wchar_t present in the parameter " &
kono
parents:
diff changeset
321 "Item");
kono
parents:
diff changeset
322 end if;
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 for i in 1..TC_Natural_Count loop
kono
parents:
diff changeset
325 if Wide_Character_to_wchar_t(TC_Wide_String(i)) /=
kono
parents:
diff changeset
326 TC_wchar_array(size_t(i-1))
kono
parents:
diff changeset
327 then
kono
parents:
diff changeset
328 Report.Failed("Incorrect result from Procedure To_Ada when " &
kono
parents:
diff changeset
329 "checking individual wchar_t values, case of " &
kono
parents:
diff changeset
330 "Trim_Nul => False, when a wide_nul is not " &
kono
parents:
diff changeset
331 "present in the wchar_array input parameter; " &
kono
parents:
diff changeset
332 "position = " & Integer'Image(Integer(i)));
kono
parents:
diff changeset
333 end if;
kono
parents:
diff changeset
334 end loop;
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 if TC_Wide_String(TC_Natural_Count) = To_Wide_Character(Latin_1.Nul)
kono
parents:
diff changeset
337 then
kono
parents:
diff changeset
338 Report.Failed("Last Wide_Character of Wide_String result of " &
kono
parents:
diff changeset
339 "Procedure To_Ada is Nul, even though the wide_nul " &
kono
parents:
diff changeset
340 "wchar_t was not present in the parameter Item, " &
kono
parents:
diff changeset
341 "with the parameter Trim_Nul => False");
kono
parents:
diff changeset
342 end if;
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 -- Check that the Procedure To_Ada raises Terminator_Error if the
kono
parents:
diff changeset
347 -- parameter Trim_Nul is set to True, but the actual Item parameter
kono
parents:
diff changeset
348 -- does not contain the wide_nul wchar_t.
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 begin
kono
parents:
diff changeset
351 TC_Wide_String := (others => Wide_Character'First);
kono
parents:
diff changeset
352 TC_wchar_array := To_C ("ABCDWXYZ", Append_Nul => False);
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 To_Ada(TC_wchar_array,
kono
parents:
diff changeset
355 TC_Wide_String,
kono
parents:
diff changeset
356 Count => TC_Natural_Count,
kono
parents:
diff changeset
357 Trim_Nul => True);
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 Report.Failed("Terminator_Error not raised when Item " &
kono
parents:
diff changeset
360 "parameter of To_Ada does not contain the " &
kono
parents:
diff changeset
361 "wide_nul wchar_t, but parameter Trim_Nul => True");
kono
parents:
diff changeset
362 Report.Comment(To_String(TC_Wide_String) &
kono
parents:
diff changeset
363 " printed to defeat optimization");
kono
parents:
diff changeset
364 exception
kono
parents:
diff changeset
365 when Terminator_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
366 when others =>
kono
parents:
diff changeset
367 Report.Failed("Incorrect exception raised by Procedure " &
kono
parents:
diff changeset
368 "To_Ada when the Item parameter does not " &
kono
parents:
diff changeset
369 "contain the wide_nul wchar_t, but parameter " &
kono
parents:
diff changeset
370 "Trim_Nul => True");
kono
parents:
diff changeset
371 end;
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 -- Check that Constraint_Error is propagated by procedure To_Ada if the
kono
parents:
diff changeset
376 -- length of Wide_String parameter Target is not long enough to hold the
kono
parents:
diff changeset
377 -- converted wchar_array value (plus wide_nul if Trim_Nul is False).
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 begin
kono
parents:
diff changeset
380 TC_wchar_array(0..4) := To_C ("ABCD", Append_Nul => True);
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 To_Ada(TC_wchar_array(0..4),
kono
parents:
diff changeset
383 TC_Short_Wide_String, -- Length of 4.
kono
parents:
diff changeset
384 Count => TC_Natural_Count,
kono
parents:
diff changeset
385 Trim_Nul => False);
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 Report.Failed("Constraint_Error not raised when Wide_String " &
kono
parents:
diff changeset
388 "parameter Target of Procedure To_Ada is not " &
kono
parents:
diff changeset
389 "long enough to hold the converted wchar_ts");
kono
parents:
diff changeset
390 Report.Comment(To_String(TC_Short_Wide_String) &
kono
parents:
diff changeset
391 " printed to defeat optimization");
kono
parents:
diff changeset
392 exception
kono
parents:
diff changeset
393 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
394 when others =>
kono
parents:
diff changeset
395 Report.Failed("Incorrect exception raised by Procedure " &
kono
parents:
diff changeset
396 "To_Ada when Wide_String parameter Target is " &
kono
parents:
diff changeset
397 "not long enough to hold the converted wchar_ts");
kono
parents:
diff changeset
398 end;
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 exception
kono
parents:
diff changeset
401 when The_Error : others =>
kono
parents:
diff changeset
402 Report.Failed ("The following exception was raised in the " &
kono
parents:
diff changeset
403 "Test_Block: " & Exception_Name(The_Error));
kono
parents:
diff changeset
404 end Test_Block;
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 Report.Result;
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 end CXB3007;