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 conversion functions for Characters and Strings
28 -- defined in package Ada.Characters.Handling provide correct results
29 -- when given character/string input parameters.
32 -- This test checks the output of the To_Lower, To_Upper, and
33 -- To_Basic functions for both Characters and Strings. Each function
34 -- is called with input parameters that are within the appropriate
35 -- range of values, and also with values outside the specified
36 -- range (i.e., lower case 'a' to To_Lower). The functions are also
37 -- used in combination with one another, with the result of one function
38 -- providing the actual input parameter value to another.
42 -- 06 Dec 94 SAIC ACVC 2.0
43 -- 22 Dec 94 SAIC Corrected evaluations of Functions In Combination.
47 with Ada
.Characters
.Latin_1
;
48 with Ada
.Characters
.Handling
;
53 package AC
renames Ada
.Characters
;
54 package ACH
renames Ada
.Characters
.Handling
;
58 Report
.Test
("CXA3002", "Check that the conversion functions for " &
59 "Characters and Strings defined in package " &
60 "Ada.Characters.Handling provide correct " &
61 "results when given character/string input " &
67 Offset
: constant Integer := Character'Pos('a') - Character'Pos('A');
70 -- Function To_Lower for Characters
72 if ACH
.To_Lower
('A') /= 'a' or ACH
.To_Lower
('Z') /= 'z' then
73 Report
.Failed
("Incorrect operation of function To_Lower - 1");
77 for i
in Character'Pos('A') .. Character'Pos('Z') loop
78 if ACH
.To_Lower
(Character'Val(i
)) /= Character'Val(i
+ Offset
) then
79 Report
.Failed
("Incorrect operation of function To_Lower - 2");
84 if (ACH
.To_Lower
(AC
.Latin_1
.UC_A_Grave
) /=
85 AC
.Latin_1
.LC_A_Grave
) or
86 (ACH
.To_Lower
(AC
.Latin_1
.UC_Icelandic_Thorn
) /=
87 AC
.Latin_1
.LC_Icelandic_Thorn
)
89 Report
.Failed
("Incorrect operation of function To_Lower - 3");
93 if ACH
.To_Lower
('c') /= 'c' or
94 ACH
.To_Lower
('w') /= 'w' or
95 ACH
.To_Lower
(AC
.Latin_1
.CR
) /= AC
.Latin_1
.CR
or
96 ACH
.To_Lower
(AC
.Latin_1
.LF
) /= AC
.Latin_1
.LF
or
97 ACH
.To_Lower
(AC
.Latin_1
.Comma
) /= AC
.Latin_1
.Comma
or
98 ACH
.To_Lower
(AC
.Latin_1
.Question
) /= AC
.Latin_1
.Question
or
99 ACH
.To_Lower
('0') /= '0' or
100 ACH
.To_Lower
('9') /= '9'
102 Report
.Failed
("Incorrect operation of function To_Lower - 4");
106 --- Function To_Upper for Characters
109 if not (ACH
.To_Upper
('b') = 'B') and (ACH
.To_Upper
('y') = 'Y') then
110 Report
.Failed
("Incorrect operation of function To_Upper - 1");
114 for i
in Character'Pos(AC
.Latin_1
.LC_A
) ..
115 Character'Pos(AC
.Latin_1
.LC_Z
) loop
116 if ACH
.To_Upper
(Character'Val(i
)) /= Character'Val(i
- Offset
) then
117 Report
.Failed
("Incorrect operation of function To_Upper - 2");
122 if (ACH
.To_Upper
(AC
.Latin_1
.LC_U_Diaeresis
) /=
123 AC
.Latin_1
.UC_U_Diaeresis
) or
124 (ACH
.To_Upper
(AC
.Latin_1
.LC_A_Ring
) /=
125 AC
.Latin_1
.UC_A_Ring
)
127 Report
.Failed
("Incorrect operation of function To_Upper - 3");
131 if not (ACH
.To_Upper
('F') = 'F' and
132 ACH
.To_Upper
('U') = 'U' and
133 ACH
.To_Upper
(AC
.Latin_1
.LC_German_Sharp_S
) =
134 AC
.Latin_1
.LC_German_Sharp_S
and
135 ACH
.To_Upper
(AC
.Latin_1
.LC_Y_Diaeresis
) =
136 AC
.Latin_1
.LC_Y_Diaeresis
)
138 Report
.Failed
("Incorrect operation of function To_Upper - 4");
142 --- Function To_Basic for Characters
145 if ACH
.To_Basic
(AC
.Latin_1
.LC_A_Circumflex
) /=
146 ACH
.To_Basic
(AC
.Latin_1
.LC_A_Tilde
) or
147 ACH
.To_Basic
(AC
.Latin_1
.LC_E_Grave
) /=
148 ACH
.To_Basic
(AC
.Latin_1
.LC_E_Acute
) or
149 ACH
.To_Basic
(AC
.Latin_1
.LC_I_Circumflex
) /=
150 ACH
.To_Basic
(AC
.Latin_1
.LC_I_Diaeresis
) or
151 ACH
.To_Basic
(AC
.Latin_1
.UC_O_Tilde
) /=
152 ACH
.To_Basic
(AC
.Latin_1
.UC_O_Acute
) or
153 ACH
.To_Basic
(AC
.Latin_1
.UC_U_Grave
) /=
154 ACH
.To_Basic
(AC
.Latin_1
.UC_U_Acute
) or
155 ACH
.To_Basic
(AC
.Latin_1
.LC_Y_Acute
) /=
156 ACH
.To_Basic
(AC
.Latin_1
.LC_Y_Diaeresis
)
158 Report
.Failed
("Incorrect operation of function To_Basic - 1");
162 if ACH
.To_Basic
('Y') /= 'Y' or
163 ACH
.To_Basic
(AC
.Latin_1
.LC_E_Acute
) /= 'e' or
164 ACH
.To_Basic
('6') /= '6' or
165 ACH
.To_Basic
(AC
.Latin_1
.LC_R
) /= 'r'
167 Report
.Failed
("Incorrect operation of function To_Basic - 2");
171 -- Using Functions (for Characters) in Combination
174 if (ACH
.To_Upper
(ACH
.To_Lower
('A')) /= 'A' ) or
175 (ACH
.To_Upper
(ACH
.To_Lower
(AC
.Latin_1
.UC_A_Acute
)) /=
176 AC
.Latin_1
.UC_A_Acute
)
178 Report
.Failed
("Incorrect operation of functions in combination - 1");
182 if ACH
.To_Basic
(ACH
.To_Lower
(ACH
.To_Upper
(AC
.Latin_1
.LC_U_Grave
))) /=
185 Report
.Failed
("Incorrect operation of functions in combination - 2");
189 if ACH
.To_Lower
(ACH
.To_Basic
190 (ACH
.To_Upper
(AC
.Latin_1
.LC_O_Diaeresis
))) /= 'o'
192 Report
.Failed
("Incorrect operation of functions in combination - 3");
197 when others => Report
.Failed
("Exception raised in Character_Block");
204 LC_String
: constant String := "az" &
205 AC
.Latin_1
.LC_A_Grave
&
206 AC
.Latin_1
.LC_C_Cedilla
;
208 UC_String
: constant String := "AZ" &
209 AC
.Latin_1
.UC_A_Grave
&
210 AC
.Latin_1
.UC_C_Cedilla
;
212 LC_Basic_String
: constant String := "aei" & 'o' & 'u';
214 LC_NonBasic_String
: constant String := AC
.Latin_1
.LC_A_Diaeresis
&
215 AC
.Latin_1
.LC_E_Circumflex
&
216 AC
.Latin_1
.LC_I_Acute
&
217 AC
.Latin_1
.LC_O_Tilde
&
218 AC
.Latin_1
.LC_U_Grave
;
220 UC_Basic_String
: constant String := "AEIOU";
222 UC_NonBasic_String
: constant String := AC
.Latin_1
.UC_A_Tilde
&
223 AC
.Latin_1
.UC_E_Acute
&
224 AC
.Latin_1
.UC_I_Grave
&
225 AC
.Latin_1
.UC_O_Diaeresis
&
226 AC
.Latin_1
.UC_U_Circumflex
;
228 LC_Special_String
: constant String := "ab" &
229 AC
.Latin_1
.LC_German_Sharp_S
&
230 AC
.Latin_1
.LC_Y_Diaeresis
;
232 UC_Special_String
: constant String := "AB" &
233 AC
.Latin_1
.LC_German_Sharp_S
&
234 AC
.Latin_1
.LC_Y_Diaeresis
;
238 -- Function To_Lower for Strings
241 if ACH
.To_Lower
(UC_String
) /= LC_String
or
242 ACH
.To_Lower
(LC_String
) /= LC_String
244 Report
.Failed
("Incorrect result from To_Lower for strings - 1");
248 if ACH
.To_Lower
(UC_Basic_String
) /= LC_Basic_String
then
249 Report
.Failed
("Incorrect result from To_Lower for strings - 2");
253 -- Function To_Upper for Strings
256 if not (ACH
.To_Upper
(LC_String
) = UC_String
) then
257 Report
.Failed
("Incorrect result from To_Upper for strings - 1");
261 if ACH
.To_Upper
(LC_Basic_String
) /= UC_Basic_String
or
262 ACH
.To_Upper
(UC_String
) /= UC_String
264 Report
.Failed
("Incorrect result from To_Upper for strings - 2");
268 if ACH
.To_Upper
(LC_Special_String
) /= UC_Special_String
then
269 Report
.Failed
("Incorrect result from To_Upper for strings - 3");
274 -- Function To_Basic for Strings
277 if (ACH
.To_Basic
(LC_String
) /= "azac") or
278 (ACH
.To_Basic
(UC_String
) /= "AZAC")
280 Report
.Failed
("Incorrect result from To_Basic for Strings - 1");
284 if ACH
.To_Basic
(LC_NonBasic_String
) /= LC_Basic_String
then
285 Report
.Failed
("Incorrect result from To_Basic for Strings - 2");
289 if ACH
.To_Basic
(UC_NonBasic_String
) /= UC_Basic_String
then
290 Report
.Failed
("Incorrect result from To_Basic for Strings - 3");
294 -- Using Functions (for Strings) in Combination
297 if ACH
.To_Upper
(ACH
.To_Lower
(UC_Basic_String
)) /= UC_Basic_String
or
298 ACH
.To_Lower
(ACH
.To_Upper
(LC_Basic_String
)) /= LC_Basic_String
300 Report
.Failed
("Incorrect operation of functions in combination - 4");
304 if (ACH
.To_Basic
(ACH
.To_Lower
(UC_NonBasic_String
)) /= LC_Basic_String
) or
305 (ACH
.To_Basic
(ACH
.To_Upper
(LC_NonBasic_String
)) /= UC_Basic_String
)
307 Report
.Failed
("Incorrect operation of functions in combination - 5");
312 when others => Report
.Failed
("Exception raised in String_Block");