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 types, operations, and other entities defined within
28 -- the package Ada.Strings.Maps are available and/or produce correct
32 -- This test demonstrates the availability and function of the types and
33 -- operations defined in package Ada.Strings.Maps. It demonstrates the
34 -- use of these types and functions as they would be used in common
35 -- programming practice.
36 -- Character set creation, assignment, and comparison are evaluated
37 -- in this test. Each of the functions provided in package
38 -- Ada.Strings.Maps is utilized in creating or manipulating set objects,
39 -- and the function results are evaluated for correctness.
40 -- Character sequences are examined using the functions provided for
41 -- manipulating objects of this type. Likewise, character maps are
42 -- created, and their contents evaluated. Exception raising conditions
43 -- from the function To_Mapping are also created.
44 -- Note: Throughout this test, the set logical operators are printed in
45 -- capital letters to enhance their visibility.
49 -- 06 Dec 94 SAIC ACVC 2.0
53 with Ada
.Strings
.Maps
;
59 use type Maps
.Character_Set
;
63 Report
.Test
("CXA4001", "Check that the types, operations, and other " &
64 "entities defined within the package " &
65 "Ada.Strings.Maps are available and/or produce " &
71 MidPoint_Letter
: constant := 13;
72 Last_Letter
: constant := 26;
74 Vowels
: constant Maps
.Character_Sequence
:= "aeiou";
75 Quasi_Vowel
: constant Character := 'y';
77 Alphabet
: Maps
.Character_Sequence
(1..Last_Letter
);
78 Half_Alphabet
: Maps
.Character_Sequence
(1..MidPoint_Letter
);
79 Inverse_Alphabet
: Maps
.Character_Sequence
(1..Last_Letter
);
86 Second_Half_Set
: Maps
.Character_Set
;
90 -- Load the alphabet string 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
);
102 -- Initialize a series of Character_Set objects.
104 Alphabet_Set
:= Maps
.To_Set
(Alphabet
);
105 Vowel_Set
:= Maps
.To_Set
(Vowels
);
106 Full_Vowel_Set
:= Vowel_Set
OR Maps
.To_Set
(Quasi_Vowel
);
107 Consonant_Set
:= Vowel_Set
XOR Alphabet_Set
;
109 First_Half_Set
:= Maps
.To_Set
(Half_Alphabet
);
110 Second_Half_Set
:= Alphabet_Set
XOR First_Half_Set
;
113 -- Evaluation of Set objects, operators, and functions.
115 if Alphabet_Set
/= (Vowel_Set
OR Consonant_Set
) then
116 Report
.Failed
("Incorrect set combinations using OR operator");
121 if not Maps
.Is_In
(Vowels
(i
), Vowel_Set
) or
122 not Maps
.Is_In
(Vowels
(i
), Alphabet_Set
) or
123 Maps
.Is_In
(Vowels
(i
), Consonant_Set
)
125 Report
.Failed
("Incorrect function Is_In use with set " &
126 "combinations - " & Integer'Image(i
));
131 if Maps
.Is_Subset
(Vowel_Set
, First_Half_Set
) or
132 Maps
."<="(Vowel_Set
, Second_Half_Set
) or
133 not Maps
.Is_Subset
(Vowel_Set
, Alphabet_Set
)
135 Report
.Failed
("Incorrect set evaluation using Is_Subset function");
139 if not (Full_Vowel_Set
= Maps
.To_Set
("aeiouy")) then
140 Report
.Failed
("Incorrect result for ""="" set operator");
144 if not ((Vowel_Set
AND First_Half_Set
) OR
145 (Full_Vowel_Set
AND Second_Half_Set
)) = Full_Vowel_Set
then
147 ("Incorrect result for AND, OR, or ""="" set operators");
151 if (Alphabet_Set
AND Maps
.Null_Set
) /= Maps
.Null_Set
or
152 (Alphabet_Set
OR Maps
.Null_Set
) /= Alphabet_Set
154 Report
.Failed
("Incorrect result for AND or OR set operators");
158 Vowel_Set
:= Full_Vowel_Set
;
159 Vowel_Set
:= Vowel_Set
AND (NOT Maps
.To_Set
(Quasi_Vowel
));
161 if not (Vowels
= Maps
.To_Sequence
(Vowel_Set
)) then
162 Report
.Failed
("Incorrect Set to Sequence translation");
167 Inverse_Alphabet
(i
) := Alphabet
(27-i
);
171 Inverse_Map
: Maps
.Character_Mapping
:=
172 Maps
.To_Mapping
(Alphabet
, Inverse_Alphabet
);
174 if Maps
.Value
(Maps
.Identity
, 'b') /= Maps
.Value
(Inverse_Map
,'y')
176 Report
.Failed
("Incorrect Inverse mapping");
181 -- Check that Translation_Error is raised when a character is
182 -- repeated in the parameter "From" string.
184 Bad_Map
: Maps
.Character_Mapping
;
186 Bad_Map
:= Maps
.To_Mapping
(From
=> "aa", To
=> "yz");
187 Report
.Failed
("Exception not raised with repeated character");
189 when Translation_Error
=> null; -- OK
191 Report
.Failed
("Incorrect exception raised in To_Mapping with " &
192 "a repeated character");
196 -- Check that Translation_Error is raised when the parameters of the
197 -- function To_Mapping are of unequal lengths.
199 Bad_Map
: Maps
.Character_Mapping
;
201 Bad_Map
:= Maps
.To_Mapping
("abc", "yz");
202 Report
.Failed
("Exception not raised with unequal parameter lengths");
204 when Translation_Error
=> null; -- OK
206 Report
.Failed
("Incorrect exception raised in To_Mapping with " &
207 "unequal parameter lengths");
212 when others => Report
.Failed
("Exception raised in Test_Block");