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 function "-", To_Ranges, To_Domain, and To_Range are
28 -- available in the package Ada.Strings.Maps, and that they produce
29 -- correct results based on the Character_Set/Character_Mapping input
33 -- This test examines the operation of four functions from within the
34 -- Ada.Strings.Maps package. A variety of Character_Sequence,
35 -- Character_Set, and Character_Mapping objects are created and
36 -- initialized for use with these functions. In each subtest of
37 -- function operation, specific inputs are provided to the functions as
38 -- input parameters, and the results are evaluated against expected
39 -- values. Wherever appropriate, additional characteristics of the
40 -- function results are verified against the prescribed result
45 -- 03 Feb 95 SAIC Initial prerelease version
46 -- 10 Mar 95 SAIC Incorporated reviewer comments.
47 -- 15 Apr 96 SAIC Incorporated reviewer comments for ACVC 2.1.
48 -- 05 Oct 96 SAIC Incorporated reviewer comments for ACVC 2.1.
52 with Ada
.Strings
.Maps
;
53 with Ada
.Strings
.Maps
.Constants
;
54 with Ada
.Characters
.Latin_1
;
61 Report
.Test
("CXA4024", "Check that the function ""-"", To_Ranges, " &
62 "To_Domain, and To_Range are available in " &
63 "the package Ada.Strings.Maps, and that " &
64 "they produce correct results");
69 use Ada
.Strings
, Ada
.Strings
.Maps
;
70 use type Maps
.Character_Set
; -- To allow logical set operator
72 package ACL1
renames Ada
.Characters
.Latin_1
;
74 MidPoint_Letter
: constant := 13;
75 Last_Letter
: constant := 26;
77 Vowels
: constant Maps
.Character_Sequence
:= "aeiou";
78 Quasi_Vowel
: constant Character := 'y';
80 Alphabet
: Maps
.Character_Sequence
(1..Last_Letter
);
81 Half_Alphabet
: Maps
.Character_Sequence
(1..MidPoint_Letter
);
87 Second_Half_Set
: Maps
.Character_Set
;
92 -- Load the alphabet strings for use in creating sets.
94 Half_Alphabet
(i
+1) := Character'Val(Character'Pos('a') + i
);
98 Alphabet
(i
+1) := Character'Val(Character'Pos('a') + i
);
101 -- Initialize a series of Character_Set objects.
103 Alphabet_Set
:= Maps
.To_Set
(Alphabet
);
104 Vowel_Set
:= Maps
.To_Set
(Vowels
);
105 Consonant_Set
:= Vowel_Set
XOR Alphabet_Set
;
106 First_Half_Set
:= Maps
.To_Set
(Half_Alphabet
);
107 Second_Half_Set
:= Alphabet_Set
XOR First_Half_Set
;
111 -- Evaluation of Set operator "-".
113 if Consonant_Set
/= "-"(Alphabet_Set
, Vowel_Set
) or
114 Vowel_Set
/= (Alphabet_Set
- Consonant_Set
) or
115 Alphabet_Set
/= Alphabet_Set
- Maps
.Null_Set
or
116 First_Half_Set
/= "-"(Alphabet_Set
, Second_Half_Set
) or
117 (Alphabet_Set
- Vowel_Set
) /= "AND"(Alphabet_Set
, "NOT"(Vowel_Set
))
119 Report
.Failed
("Incorrect result from ""-"" operator for sets");
124 -- Evaluation of Function "To_Ranges".
128 use type Maps
.Character_Range
;
129 use type Maps
.Character_Ranges
;
131 Set_A_to_C
: Maps
.Character_Set
:= Maps
.To_Set
("ABC");
132 Set_J
: Maps
.Character_Set
:= Maps
.To_Set
("J");
133 Set_M_to_P
: Maps
.Character_Set
:= Maps
.To_Set
("MNOP");
134 Set_X_to_Z
: Maps
.Character_Set
:= Maps
.To_Set
("XYZ");
135 Set_Of_Five
: Maps
.Character_Set
:= Set_A_to_C
OR -- Union of the
136 Set_M_to_P
OR -- five sets.
141 TC_Range_A_to_C
: Maps
.Character_Range
:= (Low
=> 'A', High
=> 'C');
142 TC_Range_J
: Maps
.Character_Range
:= ('J', 'J');
143 TC_Range_M_to_P
: Maps
.Character_Range
:= ('M', 'P');
144 TC_Range_X_to_Z
: Maps
.Character_Range
:= (Low
=> 'X', High
=> 'Z');
146 TC_Ranges
: Maps
.Character_Ranges
(1..4) :=
147 (1 => TC_Range_A_to_C
,
149 3 => TC_Range_M_to_P
,
150 4 => TC_Range_X_to_Z
);
154 -- Based on input of a set containing four separate "spans" of
155 -- character sequences, Function To_Ranges is required to produce
156 -- the shortest array of contiguous ranges of Character values in
157 -- the input set, in increasing order of Low.
161 -- This Character_Ranges constant should consist of array
162 -- components, each component being a Character_Range from Low
163 -- to High containing the appropriate characters.
165 Ranges_Result
: constant Maps
.Character_Ranges
:=
166 Maps
.To_Ranges
(Set
=> Set_Of_Five
);
169 -- Check the structure and components of the Character_Ranges
172 if Ranges_Result
(1) /= TC_Range_A_to_C
or
173 Ranges_Result
(1).Low
/= TC_Ranges
(1).Low
or
174 Ranges_Result
(2) /= TC_Range_J
or
175 Ranges_Result
(2).High
/= TC_Ranges
(2).High
or
176 Ranges_Result
(3) /= TC_Range_M_to_P
or
177 Ranges_Result
(3).Low
/= TC_Ranges
(3).Low
or
178 Ranges_Result
(3).High
/= TC_Ranges
(3).High
or
179 Ranges_Result
(4) /= TC_Range_X_To_Z
or
180 Ranges_Result
(4).Low
/= TC_Ranges
(4).Low
or
181 Ranges_Result
(4).High
/= TC_Ranges
(4).High
183 Report
.Failed
("Incorrect structure or components in " &
184 "Character_Ranges constant");
189 Report
.Failed
("Exception raised using the Function To_Ranges " &
190 "to initialize a Character_Ranges constant");
196 -- Evaluation of Functions To_Domain and To_Range.
200 Null_Sequence
: constant Maps
.Character_Sequence
:= "";
202 TC_Upper_Case_Sequence
: constant Maps
.Character_Sequence
:=
203 "ZYXWVUTSRQPONMABCDEFGHIJKL";
204 TC_Lower_Case_Sequence
: constant Maps
.Character_Sequence
:=
205 "zyxwvutsrqponmabcdefghijkl";
206 TC_Unordered_Sequence
: Maps
.Character_Sequence
(1..6) :=
209 TC_Upper_to_Lower_Map
: Maps
.Character_Mapping
:=
210 Maps
.To_Mapping
(TC_Upper_Case_Sequence
,
211 TC_Lower_Case_Sequence
);
213 TC_Lower_to_Upper_Map
: Maps
.Character_Mapping
:=
214 Maps
.To_Mapping
(TC_Lower_Case_Sequence
,
215 TC_Upper_Case_Sequence
);
217 TC_Unordered_Map
: Maps
.Character_Mapping
:=
218 Maps
.To_Mapping
(TC_Unordered_Sequence
,
224 TC_Domain_1
: constant Maps
.Character_Sequence
:=
225 Maps
.To_Domain
(TC_Upper_to_Lower_Map
);
227 TC_Domain_2
: constant Maps
.Character_Sequence
:=
228 Maps
.To_Domain
(TC_Lower_to_Upper_Map
);
230 TC_Domain_3
: Maps
.Character_Sequence
(1..6);
232 TC_Range_1
: constant Maps
.Character_Sequence
:=
233 Maps
.To_Range
(TC_Upper_to_Lower_Map
);
235 TC_Range_2
: constant Maps
.Character_Sequence
:=
236 Maps
.To_Range
(TC_Lower_to_Upper_Map
);
238 TC_Range_3
: Maps
.Character_Sequence
(1..6);
242 -- Function To_Domain returns the shortest Character_Sequence
243 -- value such that each character not in the result maps to
244 -- itself, and all characters in the result are in ascending
247 TC_Domain_3
:= Maps
.To_Domain
(TC_Unordered_Map
);
249 -- Check contents of result of To_Domain, must be in ascending
252 if TC_Domain_1
/= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" then
253 Report
.Failed
("Incorrect result from To_Domain with " &
254 "TC_Upper_to_Lower_Map as input");
257 if TC_Domain_2
/= "abcdefghijklmnopqrstuvwxyz" then
258 Report
.Failed
("Incorrect result from To_Domain with " &
259 "TC_Lower_to_Upper_Map as input");
262 if TC_Domain_3
/= "ABCxyz" then
263 Report
.Failed
("Incorrect result from To_Domain with " &
264 "an unordered mapping as input");
268 -- The lower bound on the returned Character_Sequence value
269 -- from To_Domain must be 1.
271 if TC_Domain_1
'First /= 1 or
272 TC_Domain_2
'First /= 1 or
273 TC_Domain_3
'First /= 1
275 Report
.Failed
("Incorrect lower bound returned from To_Domain");
279 -- Check contents of result of To_Range.
281 TC_Range_3
:= Maps
.To_Range
(TC_Unordered_Map
);
283 if TC_Range_1
/= "abcdefghijklmnopqrstuvwxyz" then
284 Report
.Failed
("Incorrect result from To_Range with " &
285 "TC_Upper_to_Lower_Map as input");
288 if TC_Range_2
/= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" then
289 Report
.Failed
("Incorrect result from To_Range with " &
290 "TC_Lower_to_Upper_Map as input");
293 if TC_Range_3
/= "gilkaj" then
294 Report
.Failed
("Incorrect result from To_Range with " &
295 "an unordered mapping as input");
299 -- The lower bound on the returned Character_Sequence value
302 if TC_Range_1
'First /= 1 or
303 TC_Range_2
'First /= 1 or
304 TC_Range_3
'First /= 1
306 Report
.Failed
("Incorrect lower bound returned from To_Range");
310 -- The upper bound on the returned Character_Sequence value
311 -- must be Map'Length.
313 if TC_Range_1
'Last /= TC_Lower_Case_Sequence
'Length or
314 TC_Range_2
'Last /= TC_Upper_Case_Sequence
'Length or
315 TC_Range_3
'Last /= TC_Unordered_Sequence
'Length
317 Report
.Failed
("Incorrect upper bound returned from To_Range");
322 -- Both function To_Domain and To_Range return the null string
323 -- when provided the Identity character map as an input parameter.
325 if Maps
.To_Domain
(Maps
.Identity
) /= Null_Sequence
then
326 Report
.Failed
("Function To_Domain did not return the null " &
327 "string when provided the Identity map as " &
331 if Maps
.To_Range
(Maps
.Identity
) /= Null_Sequence
then
332 Report
.Failed
("Function To_Range did not return the null " &
333 "string when provided the Identity map as " &
339 Report
.Failed
("Exception raised during the evaluation of " &
340 "Function To_Domain and To_Range");
344 when others => Report
.Failed
("Exception raised in Test_Block");