| 1 |
-- CXA3004.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 functions defined in package Ada.Characters.Handling |
| 28 |
-- for classification of and conversion between Wide_Character and |
| 29 |
-- Character values produce correct results when given the appropriate |
| 30 |
-- Character and String inputs. |
| 31 |
-- |
| 32 |
-- TEST DESCRIPTION: |
| 33 |
-- This test demonstrates the functions defined in package |
| 34 |
-- Ada.Characters.Handling which provide for the classification of and |
| 35 |
-- conversion between Wide_Characters and Characters, in character |
| 36 |
-- variables and strings. |
| 37 |
-- Each of the functions is provided with input values that are of the |
| 38 |
-- appropriate range. The results of the function processing are |
| 39 |
-- subsequently evaluated. |
| 40 |
-- |
| 41 |
-- APPLICABILITY CRITERIA: |
| 42 |
-- Applicable to all implementations using the Latin_1 set as the |
| 43 |
-- definition of Character. |
| 44 |
-- |
| 45 |
-- |
| 46 |
-- CHANGE HISTORY: |
| 47 |
-- 06 Dec 94 SAIC ACVC 2.0 |
| 48 |
-- 27 Dec 94 SAIC Corrected variable names. |
| 49 |
-- |
| 50 |
--! |
| 51 |
|
| 52 |
with Report; |
| 53 |
with Ada.Characters.Handling; |
| 54 |
|
| 55 |
procedure CXA3004 is |
| 56 |
begin |
| 57 |
|
| 58 |
Report.Test ("CXA3004", "Check that the functions defined in package " & |
| 59 |
"Ada.Characters.Handling for classification " & |
| 60 |
"of and conversion between Wide_Character and " & |
| 61 |
"Character values produce correct results " & |
| 62 |
"when given the appropriate Character " & |
| 63 |
"and String inputs"); |
| 64 |
|
| 65 |
Test_Block: |
| 66 |
declare |
| 67 |
|
| 68 |
package ACH renames Ada.Characters.Handling; |
| 69 |
|
| 70 |
Char_End : Integer := 255; |
| 71 |
WC_Start : Integer := 256; |
| 72 |
Sub_Char : Character := '*'; |
| 73 |
|
| 74 |
Blank : Character := ' '; |
| 75 |
First_Char : Character := Character'First; |
| 76 |
Last_Char : Character := Character'Last; |
| 77 |
F_Char : Character := 'F'; |
| 78 |
|
| 79 |
|
| 80 |
First_Wide_Char : Wide_Character := Wide_Character'First; |
| 81 |
Last_Non_Wide_Char : Wide_Character := Wide_Character'Val(Char_End); |
| 82 |
First_Unique_Wide_Char : Wide_Character := Wide_Character'Val(WC_Start); |
| 83 |
Last_Wide_Char : Wide_Character := Wide_Character'Last; |
| 84 |
|
| 85 |
A_String : String (1..3) := First_Char & 'X' & Last_Char; |
| 86 |
A_Wide_String : Wide_String (1..3) := First_Wide_Char & |
| 87 |
ACH.To_Wide_Character('X') & |
| 88 |
ACH.To_Wide_Character(Last_Char); |
| 89 |
|
| 90 |
Unique_Wide_String : Wide_String (1..2) := First_Unique_Wide_Char & |
| 91 |
Last_Wide_Char; |
| 92 |
|
| 93 |
Mixed_Wide_String : Wide_String (1..6) := ACH.To_Wide_Character('A') & |
| 94 |
First_Wide_Char & |
| 95 |
Last_Non_Wide_Char & |
| 96 |
First_Unique_Wide_Char & |
| 97 |
Last_Wide_Char & |
| 98 |
ACH.To_Wide_Character('Z'); |
| 99 |
|
| 100 |
|
| 101 |
Basic_Char : Character := 'A'; |
| 102 |
Basic_Wide_Char : Wide_Character := 'A'; |
| 103 |
Basic_String : String (1..6) := "ABCXYZ"; |
| 104 |
Basic_Wide_String : Wide_String (1..6) := "ABCXYZ"; |
| 105 |
|
| 106 |
begin |
| 107 |
|
| 108 |
|
| 109 |
-- Function Is_Character |
| 110 |
|
| 111 |
|
| 112 |
if not ACH.Is_Character(First_Wide_Char) then |
| 113 |
Report.Failed ("Incorrect result from Is_Character - 1"); |
| 114 |
end if; |
| 115 |
|
| 116 |
|
| 117 |
if ACH.Is_Character(First_Unique_Wide_Char) or |
| 118 |
ACH.Is_Character(Last_Wide_Char) |
| 119 |
then |
| 120 |
Report.Failed ("Incorrect result from Is_Character - 2"); |
| 121 |
end if; |
| 122 |
|
| 123 |
|
| 124 |
-- Function Is_String |
| 125 |
|
| 126 |
|
| 127 |
if not ACH.Is_String(A_Wide_String) then |
| 128 |
Report.Failed ("Incorrect result from Is_String - 1"); |
| 129 |
end if; |
| 130 |
|
| 131 |
|
| 132 |
if ACH.Is_String(Unique_Wide_String) or |
| 133 |
ACH.Is_String(Mixed_Wide_String) |
| 134 |
then |
| 135 |
Report.Failed ("Incorrect result from Is_String - 2"); |
| 136 |
end if; |
| 137 |
|
| 138 |
|
| 139 |
-- Function To_Character |
| 140 |
|
| 141 |
|
| 142 |
-- Use default substitution character in call of To_Character. |
| 143 |
|
| 144 |
if ACH.To_Character(First_Wide_Char) /= First_Char or |
| 145 |
ACH.To_Character(Last_Non_Wide_Char) /= Last_Char |
| 146 |
then |
| 147 |
Report.Failed ("Incorrect result from To_Character - 1"); |
| 148 |
end if; |
| 149 |
|
| 150 |
|
| 151 |
-- Provide a substitution character for use with To_Character. |
| 152 |
|
| 153 |
if ACH.To_Character(First_Unique_Wide_Char, Blank) /= Blank or |
| 154 |
ACH.To_Character(First_Unique_Wide_Char, Sub_Char) /= Sub_Char or |
| 155 |
ACH.To_Character(Last_Wide_Char) /= ' ' -- default |
| 156 |
then |
| 157 |
Report.Failed ("Incorrect result from To_Character - 2"); |
| 158 |
end if; |
| 159 |
|
| 160 |
|
| 161 |
-- Function To_String |
| 162 |
|
| 163 |
|
| 164 |
if ACH.To_String(A_Wide_String) /= A_String then |
| 165 |
Report.Failed ("Incorrect result from To_String - 1"); |
| 166 |
end if; |
| 167 |
|
| 168 |
|
| 169 |
if ACH.To_String(Unique_Wide_String, Sub_Char) /= "**" then |
| 170 |
Report.Failed ("Incorrect result from To_String - 2"); |
| 171 |
end if; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
if ACH.To_String(Mixed_Wide_String, Sub_Char) /= |
| 176 |
('A' & First_Char & Last_Char & "**" & 'Z') or |
| 177 |
ACH.To_String(Mixed_Wide_String, Sub_Char) /= |
| 178 |
(ACH.To_Character(Mixed_Wide_String(1), Sub_Char) & |
| 179 |
ACH.To_Character(Mixed_Wide_String(2), Sub_Char) & |
| 180 |
ACH.To_Character(Mixed_Wide_String(3), Sub_Char) & |
| 181 |
ACH.To_Character(Mixed_Wide_String(4), Sub_Char) & |
| 182 |
ACH.To_Character(Mixed_Wide_String(5), Sub_Char) & |
| 183 |
ACH.To_Character(Mixed_Wide_String(6), Sub_Char)) |
| 184 |
then |
| 185 |
Report.Failed ("Incorrect result from To_String - 3"); |
| 186 |
end if; |
| 187 |
|
| 188 |
|
| 189 |
-- Function To_Wide_Character |
| 190 |
|
| 191 |
|
| 192 |
if ACH.To_Wide_Character(Basic_Char) /= Basic_Wide_Char then |
| 193 |
Report.Failed ("Incorrect result from To_Wide_Character"); |
| 194 |
end if; |
| 195 |
|
| 196 |
|
| 197 |
-- Function To_Wide_String |
| 198 |
|
| 199 |
|
| 200 |
if not (ACH.To_Wide_String(Basic_String) = Basic_Wide_String) then |
| 201 |
Report.Failed ("Incorrect result from To_Wide_String"); |
| 202 |
end if; |
| 203 |
|
| 204 |
|
| 205 |
-- Functions Used In Combination |
| 206 |
|
| 207 |
if not ACH.Is_Character (ACH.To_Wide_Character ( |
| 208 |
ACH.To_Character(First_Wide_Char))) |
| 209 |
then |
| 210 |
Report.Failed ("Incorrect result from functions in combination - 1"); |
| 211 |
end if; |
| 212 |
|
| 213 |
|
| 214 |
if not ACH.Is_String(ACH.To_Wide_String(ACH.To_String(A_Wide_String))) |
| 215 |
then |
| 216 |
Report.Failed ("Incorrect result from functions in combination - 2"); |
| 217 |
end if; |
| 218 |
|
| 219 |
|
| 220 |
if ACH.To_String(ACH.To_Wide_Character('A') & |
| 221 |
ACH.To_Wide_Character(F_Char) & |
| 222 |
ACH.To_Wide_Character('Z')) /= "AFZ" |
| 223 |
then |
| 224 |
Report.Failed ("Incorrect result from functions in combination - 3"); |
| 225 |
end if; |
| 226 |
|
| 227 |
|
| 228 |
exception |
| 229 |
when others => Report.Failed ("Exception raised in Test_Block"); |
| 230 |
end Test_Block; |
| 231 |
|
| 232 |
|
| 233 |
Report.Result; |
| 234 |
|
| 235 |
end CXA3004; |