| 1 |
720 |
jeremybenn |
-- CXA4024.A
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Grant of Unlimited Rights
|
| 4 |
|
|
--
|
| 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
|
| 14 |
|
|
-- to do so.
|
| 15 |
|
|
--
|
| 16 |
|
|
-- DISCLAIMER
|
| 17 |
|
|
--
|
| 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.
|
| 24 |
|
|
--*
|
| 25 |
|
|
--
|
| 26 |
|
|
-- OBJECTIVE:
|
| 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
|
| 30 |
|
|
-- provided.
|
| 31 |
|
|
--
|
| 32 |
|
|
-- TEST DESCRIPTION:
|
| 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
|
| 41 |
|
|
-- characteristics.
|
| 42 |
|
|
--
|
| 43 |
|
|
--
|
| 44 |
|
|
-- CHANGE HISTORY:
|
| 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.
|
| 49 |
|
|
--
|
| 50 |
|
|
--!
|
| 51 |
|
|
|
| 52 |
|
|
with Ada.Strings.Maps;
|
| 53 |
|
|
with Ada.Strings.Maps.Constants;
|
| 54 |
|
|
with Ada.Characters.Latin_1;
|
| 55 |
|
|
with Report;
|
| 56 |
|
|
|
| 57 |
|
|
procedure CXA4024 is
|
| 58 |
|
|
|
| 59 |
|
|
begin
|
| 60 |
|
|
|
| 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");
|
| 65 |
|
|
|
| 66 |
|
|
Test_Block:
|
| 67 |
|
|
declare
|
| 68 |
|
|
|
| 69 |
|
|
use Ada.Strings, Ada.Strings.Maps;
|
| 70 |
|
|
use type Maps.Character_Set; -- To allow logical set operator
|
| 71 |
|
|
-- infix notation.
|
| 72 |
|
|
package ACL1 renames Ada.Characters.Latin_1;
|
| 73 |
|
|
|
| 74 |
|
|
MidPoint_Letter : constant := 13;
|
| 75 |
|
|
Last_Letter : constant := 26;
|
| 76 |
|
|
|
| 77 |
|
|
Vowels : constant Maps.Character_Sequence := "aeiou";
|
| 78 |
|
|
Quasi_Vowel : constant Character := 'y';
|
| 79 |
|
|
|
| 80 |
|
|
Alphabet : Maps.Character_Sequence (1..Last_Letter);
|
| 81 |
|
|
Half_Alphabet : Maps.Character_Sequence (1..MidPoint_Letter);
|
| 82 |
|
|
|
| 83 |
|
|
Alphabet_Set,
|
| 84 |
|
|
Consonant_Set,
|
| 85 |
|
|
Vowel_Set,
|
| 86 |
|
|
First_Half_Set,
|
| 87 |
|
|
Second_Half_Set : Maps.Character_Set;
|
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
begin
|
| 91 |
|
|
|
| 92 |
|
|
-- Load the alphabet strings for use in creating sets.
|
| 93 |
|
|
for i in 0..12 loop
|
| 94 |
|
|
Half_Alphabet(i+1) := Character'Val(Character'Pos('a') + i);
|
| 95 |
|
|
end loop;
|
| 96 |
|
|
|
| 97 |
|
|
for i in 0..25 loop
|
| 98 |
|
|
Alphabet(i+1) := Character'Val(Character'Pos('a') + i);
|
| 99 |
|
|
end loop;
|
| 100 |
|
|
|
| 101 |
|
|
-- Initialize a series of Character_Set objects.
|
| 102 |
|
|
|
| 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;
|
| 108 |
|
|
|
| 109 |
|
|
|
| 110 |
|
|
|
| 111 |
|
|
-- Evaluation of Set operator "-".
|
| 112 |
|
|
|
| 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))
|
| 118 |
|
|
then
|
| 119 |
|
|
Report.Failed("Incorrect result from ""-"" operator for sets");
|
| 120 |
|
|
end if;
|
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
|
| 124 |
|
|
-- Evaluation of Function "To_Ranges".
|
| 125 |
|
|
|
| 126 |
|
|
declare
|
| 127 |
|
|
|
| 128 |
|
|
use type Maps.Character_Range;
|
| 129 |
|
|
use type Maps.Character_Ranges;
|
| 130 |
|
|
|
| 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.
|
| 137 |
|
|
Set_X_to_Z OR
|
| 138 |
|
|
Set_J OR
|
| 139 |
|
|
Maps.Null_Set;
|
| 140 |
|
|
|
| 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');
|
| 145 |
|
|
|
| 146 |
|
|
TC_Ranges : Maps.Character_Ranges (1..4) :=
|
| 147 |
|
|
(1 => TC_Range_A_to_C,
|
| 148 |
|
|
2 => TC_Range_J,
|
| 149 |
|
|
3 => TC_Range_M_to_P,
|
| 150 |
|
|
4 => TC_Range_X_to_Z);
|
| 151 |
|
|
|
| 152 |
|
|
begin
|
| 153 |
|
|
|
| 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.
|
| 158 |
|
|
|
| 159 |
|
|
declare
|
| 160 |
|
|
|
| 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.
|
| 164 |
|
|
|
| 165 |
|
|
Ranges_Result : constant Maps.Character_Ranges :=
|
| 166 |
|
|
Maps.To_Ranges(Set => Set_Of_Five);
|
| 167 |
|
|
begin
|
| 168 |
|
|
|
| 169 |
|
|
-- Check the structure and components of the Character_Ranges
|
| 170 |
|
|
-- constant.
|
| 171 |
|
|
|
| 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
|
| 182 |
|
|
then
|
| 183 |
|
|
Report.Failed ("Incorrect structure or components in " &
|
| 184 |
|
|
"Character_Ranges constant");
|
| 185 |
|
|
end if;
|
| 186 |
|
|
|
| 187 |
|
|
exception
|
| 188 |
|
|
when others =>
|
| 189 |
|
|
Report.Failed("Exception raised using the Function To_Ranges " &
|
| 190 |
|
|
"to initialize a Character_Ranges constant");
|
| 191 |
|
|
end;
|
| 192 |
|
|
end;
|
| 193 |
|
|
|
| 194 |
|
|
|
| 195 |
|
|
|
| 196 |
|
|
-- Evaluation of Functions To_Domain and To_Range.
|
| 197 |
|
|
|
| 198 |
|
|
declare
|
| 199 |
|
|
|
| 200 |
|
|
Null_Sequence : constant Maps.Character_Sequence := "";
|
| 201 |
|
|
|
| 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) :=
|
| 207 |
|
|
"BxACzy";
|
| 208 |
|
|
|
| 209 |
|
|
TC_Upper_to_Lower_Map : Maps.Character_Mapping :=
|
| 210 |
|
|
Maps.To_Mapping(TC_Upper_Case_Sequence,
|
| 211 |
|
|
TC_Lower_Case_Sequence);
|
| 212 |
|
|
|
| 213 |
|
|
TC_Lower_to_Upper_Map : Maps.Character_Mapping :=
|
| 214 |
|
|
Maps.To_Mapping(TC_Lower_Case_Sequence,
|
| 215 |
|
|
TC_Upper_Case_Sequence);
|
| 216 |
|
|
|
| 217 |
|
|
TC_Unordered_Map : Maps.Character_Mapping :=
|
| 218 |
|
|
Maps.To_Mapping(TC_Unordered_Sequence,
|
| 219 |
|
|
"ikglja");
|
| 220 |
|
|
begin
|
| 221 |
|
|
|
| 222 |
|
|
declare
|
| 223 |
|
|
|
| 224 |
|
|
TC_Domain_1 : constant Maps.Character_Sequence :=
|
| 225 |
|
|
Maps.To_Domain(TC_Upper_to_Lower_Map);
|
| 226 |
|
|
|
| 227 |
|
|
TC_Domain_2 : constant Maps.Character_Sequence :=
|
| 228 |
|
|
Maps.To_Domain(TC_Lower_to_Upper_Map);
|
| 229 |
|
|
|
| 230 |
|
|
TC_Domain_3 : Maps.Character_Sequence(1..6);
|
| 231 |
|
|
|
| 232 |
|
|
TC_Range_1 : constant Maps.Character_Sequence :=
|
| 233 |
|
|
Maps.To_Range(TC_Upper_to_Lower_Map);
|
| 234 |
|
|
|
| 235 |
|
|
TC_Range_2 : constant Maps.Character_Sequence :=
|
| 236 |
|
|
Maps.To_Range(TC_Lower_to_Upper_Map);
|
| 237 |
|
|
|
| 238 |
|
|
TC_Range_3 : Maps.Character_Sequence(1..6);
|
| 239 |
|
|
|
| 240 |
|
|
begin
|
| 241 |
|
|
|
| 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
|
| 245 |
|
|
-- order.
|
| 246 |
|
|
|
| 247 |
|
|
TC_Domain_3 := Maps.To_Domain(TC_Unordered_Map);
|
| 248 |
|
|
|
| 249 |
|
|
-- Check contents of result of To_Domain, must be in ascending
|
| 250 |
|
|
-- order.
|
| 251 |
|
|
|
| 252 |
|
|
if TC_Domain_1 /= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" then
|
| 253 |
|
|
Report.Failed("Incorrect result from To_Domain with " &
|
| 254 |
|
|
"TC_Upper_to_Lower_Map as input");
|
| 255 |
|
|
end if;
|
| 256 |
|
|
|
| 257 |
|
|
if TC_Domain_2 /= "abcdefghijklmnopqrstuvwxyz" then
|
| 258 |
|
|
Report.Failed("Incorrect result from To_Domain with " &
|
| 259 |
|
|
"TC_Lower_to_Upper_Map as input");
|
| 260 |
|
|
end if;
|
| 261 |
|
|
|
| 262 |
|
|
if TC_Domain_3 /= "ABCxyz" then
|
| 263 |
|
|
Report.Failed("Incorrect result from To_Domain with " &
|
| 264 |
|
|
"an unordered mapping as input");
|
| 265 |
|
|
end if;
|
| 266 |
|
|
|
| 267 |
|
|
|
| 268 |
|
|
-- The lower bound on the returned Character_Sequence value
|
| 269 |
|
|
-- from To_Domain must be 1.
|
| 270 |
|
|
|
| 271 |
|
|
if TC_Domain_1'First /= 1 or
|
| 272 |
|
|
TC_Domain_2'First /= 1 or
|
| 273 |
|
|
TC_Domain_3'First /= 1
|
| 274 |
|
|
then
|
| 275 |
|
|
Report.Failed("Incorrect lower bound returned from To_Domain");
|
| 276 |
|
|
end if;
|
| 277 |
|
|
|
| 278 |
|
|
|
| 279 |
|
|
-- Check contents of result of To_Range.
|
| 280 |
|
|
|
| 281 |
|
|
TC_Range_3 := Maps.To_Range(TC_Unordered_Map);
|
| 282 |
|
|
|
| 283 |
|
|
if TC_Range_1 /= "abcdefghijklmnopqrstuvwxyz" then
|
| 284 |
|
|
Report.Failed("Incorrect result from To_Range with " &
|
| 285 |
|
|
"TC_Upper_to_Lower_Map as input");
|
| 286 |
|
|
end if;
|
| 287 |
|
|
|
| 288 |
|
|
if TC_Range_2 /= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" then
|
| 289 |
|
|
Report.Failed("Incorrect result from To_Range with " &
|
| 290 |
|
|
"TC_Lower_to_Upper_Map as input");
|
| 291 |
|
|
end if;
|
| 292 |
|
|
|
| 293 |
|
|
if TC_Range_3 /= "gilkaj" then
|
| 294 |
|
|
Report.Failed("Incorrect result from To_Range with " &
|
| 295 |
|
|
"an unordered mapping as input");
|
| 296 |
|
|
end if;
|
| 297 |
|
|
|
| 298 |
|
|
|
| 299 |
|
|
-- The lower bound on the returned Character_Sequence value
|
| 300 |
|
|
-- must be 1.
|
| 301 |
|
|
|
| 302 |
|
|
if TC_Range_1'First /= 1 or
|
| 303 |
|
|
TC_Range_2'First /= 1 or
|
| 304 |
|
|
TC_Range_3'First /= 1
|
| 305 |
|
|
then
|
| 306 |
|
|
Report.Failed("Incorrect lower bound returned from To_Range");
|
| 307 |
|
|
end if;
|
| 308 |
|
|
|
| 309 |
|
|
|
| 310 |
|
|
-- The upper bound on the returned Character_Sequence value
|
| 311 |
|
|
-- must be Map'Length.
|
| 312 |
|
|
|
| 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
|
| 316 |
|
|
then
|
| 317 |
|
|
Report.Failed("Incorrect upper bound returned from To_Range");
|
| 318 |
|
|
end if;
|
| 319 |
|
|
|
| 320 |
|
|
end;
|
| 321 |
|
|
|
| 322 |
|
|
-- Both function To_Domain and To_Range return the null string
|
| 323 |
|
|
-- when provided the Identity character map as an input parameter.
|
| 324 |
|
|
|
| 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 " &
|
| 328 |
|
|
"input");
|
| 329 |
|
|
end if;
|
| 330 |
|
|
|
| 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 " &
|
| 334 |
|
|
"input");
|
| 335 |
|
|
end if;
|
| 336 |
|
|
|
| 337 |
|
|
exception
|
| 338 |
|
|
when others =>
|
| 339 |
|
|
Report.Failed("Exception raised during the evaluation of " &
|
| 340 |
|
|
"Function To_Domain and To_Range");
|
| 341 |
|
|
end;
|
| 342 |
|
|
|
| 343 |
|
|
exception
|
| 344 |
|
|
when others => Report.Failed ("Exception raised in Test_Block");
|
| 345 |
|
|
end Test_Block;
|
| 346 |
|
|
|
| 347 |
|
|
|
| 348 |
|
|
Report.Result;
|
| 349 |
|
|
|
| 350 |
|
|
end CXA4024;
|