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 the character classification functions defined in
28 -- package Ada.Characters.Handling produce correct results when provided
29 -- constant arguments from package Ada.Characters.Latin_1.
32 -- This test checks the character classification functions of package
33 -- Ada.Characters.Handling. In the evaluation of each function, loops
34 -- are constructed to examine the function with as many values of type
35 -- Character (Ada.Characters.Latin_1 constants) as possible in an
36 -- amount of code that is about equal to the amount of code required
37 -- to examine the function with a few representative input values and
39 -- The usage paradigm being demonstrated by this test is that of the
40 -- functions being used to assign to boolean variables, as well as
41 -- serving as boolean conditions.
45 -- 06 Dec 94 SAIC ACVC 2.0
46 -- 29 Apr 95 SAIC Fixed subtest checking Is_Graphic function.
50 with Ada
.Characters
.Latin_1
;
51 with Ada
.Characters
.Handling
;
58 Report
.Test
("CXA3001", "Check that the character classification " &
59 "functions defined in package " &
60 "Ada.Characters.Handling produce " &
61 "correct results when provided constant " &
62 "arguments from package Ada.Characters.Latin_1");
67 package AC
renames Ada
.Characters
;
68 package ACH
renames Ada
.Characters
.Handling
;
70 TC_Boolean
: Boolean := False;
74 -- Over the next six statements/blocks of code, evaluate functions
75 -- Is_Control and Is_Graphic with control character and non-control
78 for i
in Character'Pos(AC
.Latin_1
.NUL
) ..
79 Character'Pos(AC
.Latin_1
.US
) loop
80 if not ACH
.Is_Control
(Character'Val(i
)) then
81 Report
.Failed
("Incorrect result from function Is_Control - 1");
83 if ACH
.Is_Graphic
(Character'Val(i
)) then
84 Report
.Failed
("Incorrect result from function Is_Graphic - 1");
89 for i
in Character'Pos(AC
.Latin_1
.Space
) ..
90 Character'Pos(AC
.Latin_1
.Tilde
) loop
91 if not ACH
.Is_Graphic
(Character'Val(i
)) then
92 Report
.Failed
("Incorrect result from function Is_Graphic - 2");
94 if ACH
.Is_Control
(Character'Val(i
)) then
95 Report
.Failed
("Incorrect result from function Is_Control - 2");
100 for i
in Character'Pos(AC
.Latin_1
.Reserved_128
) ..
101 Character'Pos(AC
.Latin_1
.APC
) loop
102 if not ACH
.Is_Control
(Character'Val(i
)) then
103 Report
.Failed
("Incorrect result from function Is_Control - 3");
105 TC_Boolean
:= ACH
.Is_Graphic
(Character'Val(i
));
107 Report
.Failed
("Incorrect result from function Is_Graphic - 3");
112 for i
in Character'Pos(AC
.Latin_1
.No_Break_Space
) ..
113 Character'Pos(AC
.Latin_1
.LC_Y_Diaeresis
) loop
114 TC_Boolean
:= ACH
.Is_Control
(Character'Val(i
));
116 Report
.Failed
("Incorrect result from function Is_Control - 4");
119 if not ACH
.Is_Graphic
(Character'Val(i
)) then
120 Report
.Failed
("Incorrect result from function Is_Graphic - 4");
124 -- Check renamed constants.
126 if not (ACH
.Is_Control
(AC
.Latin_1
.IS4
) and
127 ACH
.Is_Control
(AC
.Latin_1
.IS3
) and
128 ACH
.Is_Control
(AC
.Latin_1
.IS2
) and
129 ACH
.Is_Control
(AC
.Latin_1
.IS1
)) or
130 (ACH
.Is_Control
(AC
.Latin_1
.NBSP
) or
131 ACH
.Is_Control
(AC
.Latin_1
.Paragraph_Sign
) or
132 ACH
.Is_Control
(AC
.Latin_1
.Minus_Sign
) or
133 ACH
.Is_Control
(AC
.Latin_1
.Ring_Above
))
135 Report
.Failed
("Incorrect result from function Is_Control - 5");
138 if (ACH
.Is_Graphic
(AC
.Latin_1
.IS4
) or
139 ACH
.Is_Graphic
(AC
.Latin_1
.IS3
) or
140 ACH
.Is_Graphic
(AC
.Latin_1
.IS2
) or
141 ACH
.Is_Graphic
(AC
.Latin_1
.IS1
)) or
142 not (ACH
.Is_Graphic
(AC
.Latin_1
.NBSP
) and
143 ACH
.Is_Graphic
(AC
.Latin_1
.Paragraph_Sign
) and
144 ACH
.Is_Graphic
(AC
.Latin_1
.Minus_Sign
) and
145 ACH
.Is_Graphic
(AC
.Latin_1
.Ring_Above
))
147 Report
.Failed
("Incorrect result from function Is_Graphic - 5");
151 -- Evaluate function Is_Letter with letter/non-letter inputs.
153 for i
in Character'Pos('A') .. Character'Pos('Z') loop
154 if not ACH
.Is_Letter
(Character'Val(i
)) then
155 Report
.Failed
("Incorrect Is_Letter result - 1");
159 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
160 Character'Pos(AC
.Latin_1
.LC_Z
) loop
161 if not ACH
.Is_Letter
(Character'Val(i
)) then
162 Report
.Failed
("Incorrect Is_Letter result - 2");
166 for i
in Character'Pos(AC
.Latin_1
.UC_A_Grave
) ..
167 Character'Pos(AC
.Latin_1
.UC_O_Diaeresis
) loop
168 if not ACH
.Is_Letter
(Character'Val(i
)) then
169 Report
.Failed
("Incorrect Is_Letter result - 3");
173 for i
in Character'Pos(AC
.Latin_1
.UC_O_Oblique_Stroke
) ..
174 Character'Pos(AC
.Latin_1
.LC_O_Diaeresis
) loop
175 if not ACH
.Is_Letter
(Character'Val(i
)) then
176 Report
.Failed
("Incorrect Is_Letter result - 4");
180 for i
in Character'Pos(AC
.Latin_1
.LC_O_Oblique_Stroke
) ..
181 Character'Pos(AC
.Latin_1
.LC_Y_Diaeresis
) loop
182 if not ACH
.Is_Letter
(Character'Val(i
)) then
183 Report
.Failed
("Incorrect Is_Letter result - 5");
187 -- Check for rejection of non-letters.
188 for i
in Character'Pos(AC
.Latin_1
.NUL
) ..
189 Character'Pos(AC
.Latin_1
.Commercial_At
) loop
190 if ACH
.Is_Letter
(Character'Val(i
)) then
191 Report
.Failed
("Incorrect Is_Letter result - 6");
196 -- Evaluate function Is_Lower with lower case/non-lower case inputs.
198 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
199 Character'Pos(AC
.Latin_1
.LC_Z
) loop
200 if not ACH
.Is_Lower
(Character'Val(i
)) then
201 Report
.Failed
("Incorrect Is_Lower result - 1");
205 for i
in Character'Pos(AC
.Latin_1
.LC_A_Grave
) ..
206 Character'Pos(AC
.Latin_1
.LC_O_Diaeresis
) loop
207 if not ACH
.Is_Lower
(Character'Val(i
)) then
208 Report
.Failed
("Incorrect Is_Lower result - 2");
212 for i
in Character'Pos(AC
.Latin_1
.LC_O_Oblique_Stroke
) ..
213 Character'Pos(AC
.Latin_1
.LC_Y_Diaeresis
) loop
214 if not ACH
.Is_Lower
(Character'Val(i
)) then
215 Report
.Failed
("Incorrect Is_Lower result - 3");
219 if ACH
.Is_Lower
('A') or
220 ACH
.Is_Lower
(AC
.Latin_1
.UC_Icelandic_Eth
) or
221 ACH
.Is_Lower
(AC
.Latin_1
.Number_Sign
) or
222 ACH
.Is_Lower
(AC
.Latin_1
.Cedilla
) or
223 ACH
.Is_Lower
(AC
.Latin_1
.SYN
) or
224 ACH
.Is_Lower
(AC
.Latin_1
.ESA
)
226 Report
.Failed
("Incorrect Is_Lower result - 4");
230 -- Evaluate function Is_Upper with upper case/non-upper case inputs.
232 for i
in Character'Pos('A') .. Character'Pos('Z') loop
233 if not ACH
.Is_Upper
(Character'Val(i
)) then
234 Report
.Failed
("Incorrect Is_Upper result - 1");
238 for i
in Character'Pos(AC
.Latin_1
.UC_A_Grave
) ..
239 Character'Pos(AC
.Latin_1
.UC_O_Diaeresis
) loop
240 if not ACH
.Is_Upper
(Character'Val(i
)) then
241 Report
.Failed
("Incorrect Is_Upper result - 2");
245 for i
in Character'Pos(AC
.Latin_1
.UC_O_Oblique_Stroke
) ..
246 Character'Pos(AC
.Latin_1
.UC_Icelandic_Thorn
) loop
247 if not ACH
.Is_Upper
(Character'Val(i
)) then
248 Report
.Failed
("Incorrect Is_Upper result - 3");
252 if ACH
.Is_Upper
('8') or
253 ACH
.Is_Upper
(AC
.Latin_1
.LC_A_Ring
) or
254 ACH
.Is_Upper
(AC
.Latin_1
.Dollar_Sign
) or
255 ACH
.Is_Upper
(AC
.Latin_1
.Broken_Bar
) or
256 ACH
.Is_Upper
(AC
.Latin_1
.ETB
) or
257 ACH
.Is_Upper
(AC
.Latin_1
.VTS
)
259 Report
.Failed
("Incorrect Is_Upper result - 4");
263 for i
in Character'Pos('a') .. Character'Pos('z') loop
264 if ACH
.Is_Upper
(Character'Val(i
)) then
265 Report
.Failed
("Incorrect Is_Upper result - 5");
270 -- Evaluate function Is_Basic with basic/non-basic inputs.
271 -- (Note: Basic letters are those without diacritical marks.)
273 for i
in Character'Pos('A') .. Character'Pos('Z') loop
274 if not ACH
.Is_Basic
(Character'Val(i
)) then
275 Report
.Failed
("Incorrect Is_Basic result - 1");
279 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
280 Character'Pos(AC
.Latin_1
.LC_Z
) loop
281 if not ACH
.Is_Basic
(Character'Val(i
)) then
282 Report
.Failed
("Incorrect Is_Basic result - 2");
287 if not (ACH
.Is_Basic
(AC
.Latin_1
.UC_AE_Diphthong
) and
288 ACH
.Is_Basic
(AC
.Latin_1
.LC_AE_Diphthong
) and
289 ACH
.Is_Basic
(AC
.Latin_1
.LC_German_Sharp_S
) and
290 ACH
.Is_Basic
(AC
.Latin_1
.LC_Icelandic_Eth
) and
291 ACH
.Is_Basic
(AC
.Latin_1
.LC_Icelandic_Thorn
) and
292 ACH
.Is_Basic
(AC
.Latin_1
.UC_Icelandic_Eth
) and
293 ACH
.Is_Basic
(AC
.Latin_1
.UC_Icelandic_Thorn
))
295 Report
.Failed
("Incorrect Is_Basic result - 3");
298 -- Check for rejection of non-basics.
299 if ACH
.Is_Basic
(AC
.Latin_1
.UC_A_Tilde
) or
300 ACH
.Is_Basic
(AC
.Latin_1
.LC_A_Grave
) or
301 ACH
.Is_Basic
(AC
.Latin_1
.Ampersand
) or
302 ACH
.Is_Basic
(AC
.Latin_1
.Yen_Sign
) or
303 ACH
.Is_Basic
(AC
.Latin_1
.NAK
) or
304 ACH
.Is_Basic
(AC
.Latin_1
.SS2
)
306 Report
.Failed
("Incorrect Is_Basic result - 4");
311 for i
in Character'Pos(AC
.Latin_1
.NUL
) ..
312 Character'Pos(AC
.Latin_1
.Commercial_At
) loop
313 if ACH
.Is_Basic
(Character'Val(i
)) then
314 Report
.Failed
("Incorrect Is_Basic result - 5");
319 -- Evaluate functions Is_Digit and Is_Decimal_Digit (a rename of
320 -- Is_Digit) with decimal digit/non-digit inputs.
323 if not (ACH
.Is_Digit
('0') and
324 ACH
.Is_Decimal_Digit
('9')) or
325 ACH
.Is_Digit
('a') or -- Hex digits.
326 ACH
.Is_Decimal_Digit
('f') or
327 ACH
.Is_Decimal_Digit
('A') or
330 Report
.Failed
("Incorrect Is_Digit/Is_Decimal_Digit result - 1");
333 if ACH
.Is_Digit
(AC
.Latin_1
.Full_Stop
) or
334 ACH
.Is_Decimal_Digit
(AC
.Latin_1
.Dollar_Sign
) or
335 ACH
.Is_Digit
(AC
.Latin_1
.Number_Sign
) or
336 ACH
.Is_Decimal_Digit
(AC
.Latin_1
.Left_Parenthesis
) or
337 ACH
.Is_Digit
(AC
.Latin_1
.Right_Parenthesis
)
339 Report
.Failed
("Incorrect Is_Digit/Is_Decimal_Digit result - 2");
343 -- Evaluate functions Is_Hexadecimal_Digit with hexadecimal digit and
344 -- non-hexadecimal digit inputs.
346 for i
in Character'Pos('0') .. Character'Pos('9') loop
347 if not ACH
.Is_Hexadecimal_Digit
(Character'Val(i
)) then
348 Report
.Failed
("Incorrect Is_Hexadecimal_Digit result - 1");
352 for i
in Character'Pos('A') .. Character'Pos('F') loop
353 if not ACH
.Is_Hexadecimal_Digit
(Character'Val(i
)) then
354 Report
.Failed
("Incorrect Is_Hexadecimal_Digit result - 2");
358 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
359 Character'Pos(AC
.Latin_1
.LC_F
) loop
360 if not ACH
.Is_Hexadecimal_Digit
(Character'Val(i
)) then
361 Report
.Failed
("Incorrect Is_Hexadecimal_Digit result - 3");
366 if ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.Minus_Sign
) or
367 ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.Hyphen
) or
368 ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.LC_G
) or
369 ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.LC_Z
) or
370 ACH
.Is_Hexadecimal_Digit
('G') or
371 ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.Cent_Sign
) or
372 ACH
.Is_Hexadecimal_Digit
(AC
.Latin_1
.Pound_Sign
)
374 Report
.Failed
("Incorrect Is_HexaDecimal_Digit result - 4");
378 -- Evaluate functions Is_Alphanumeric and Is_Special with
379 -- letters, digits, and non-alphanumeric inputs.
381 for i
in Character'Pos(AC
.Latin_1
.NUL
) ..
382 Character'Pos(AC
.Latin_1
.US
) loop
383 if ACH
.Is_Alphanumeric
(Character'Val(i
)) then
384 Report
.Failed
("Incorrect Is_Alphanumeric result - 1");
386 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
388 Report
.Failed
("Incorrect Is_Special result - 1");
393 for i
in Character'Pos(AC
.Latin_1
.Reserved_128
) ..
394 Character'Pos(AC
.Latin_1
.APC
) loop
395 TC_Boolean
:= ACH
.Is_Alphanumeric
(Character'Val(i
));
397 Report
.Failed
("Incorrect Is_Alphanumeric result - 2");
400 if ACH
.Is_Special
(Character'Val(i
)) then
401 Report
.Failed
("Incorrect Is_Special result - 2");
405 for i
in Character'Pos(AC
.Latin_1
.Space
) ..
406 Character'Pos(AC
.Latin_1
.Solidus
) loop
407 TC_Boolean
:= ACH
.Is_Alphanumeric
(Character'Val(i
));
409 Report
.Failed
("Incorrect Is_Alphanumeric result - 3");
412 if not ACH
.Is_Special
(Character'Val(i
)) then
413 Report
.Failed
("Incorrect Is_Special result - 3");
417 for i
in Character'Pos('A') .. Character'Pos('Z') loop
418 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
419 Report
.Failed
("Incorrect Is_Alphanumeric result - 4");
421 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
423 Report
.Failed
("Incorrect Is_Special result - 4");
428 for i
in Character'Pos('0') .. Character'Pos('9') loop
429 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
430 Report
.Failed
("Incorrect Is_Alphanumeric result - 5");
432 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
434 Report
.Failed
("Incorrect Is_Special result - 5");
439 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
440 Character'Pos(AC
.Latin_1
.LC_Z
) loop
441 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
442 Report
.Failed
("Incorrect Is_Alphanumeric result - 6");
444 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
446 Report
.Failed
("Incorrect Is_Special result - 6");
451 for i
in Character'Pos(AC
.Latin_1
.No_Break_Space
) ..
452 Character'Pos(AC
.Latin_1
.Inverted_Question
) loop
453 TC_Boolean
:= ACH
.Is_Alphanumeric
(Character'Val(i
));
455 Report
.Failed
("Incorrect Is_Alphanumeric result - 7");
458 if not ACH
.Is_Special
(Character'Val(i
)) then
459 Report
.Failed
("Incorrect Is_Special result - 7");
463 for i
in Character'Pos(AC
.Latin_1
.UC_A_Grave
) ..
464 Character'Pos(AC
.Latin_1
.UC_O_Diaeresis
) loop
465 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
466 Report
.Failed
("Incorrect Is_Alphanumeric result - 8");
468 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
470 Report
.Failed
("Incorrect Is_Special result - 8");
475 for i
in Character'Pos(AC
.Latin_1
.UC_O_Oblique_Stroke
) ..
476 Character'Pos(AC
.Latin_1
.LC_O_Diaeresis
) loop
477 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
478 Report
.Failed
("Incorrect Is_Alphanumeric result - 9");
480 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
482 Report
.Failed
("Incorrect Is_Special result - 9");
487 for i
in Character'Pos(AC
.Latin_1
.LC_O_Oblique_Stroke
) ..
488 Character'Pos(AC
.Latin_1
.LC_Y_Diaeresis
) loop
489 if not ACH
.Is_Alphanumeric
(Character'Val(i
)) then
490 Report
.Failed
("Incorrect Is_Alphanumeric result - 10");
492 TC_Boolean
:= ACH
.Is_Special
(Character'Val(i
));
494 Report
.Failed
("Incorrect Is_Special result - 10");
501 when others => Report
.Failed
("Exception raised during processing");