| 1 |
-- CXAB001.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 operations defined in package Wide_Text_IO allow for |
| 28 |
-- the input/output of Wide_Character and Wide_String data. |
| 29 |
-- |
| 30 |
-- TEST DESCRIPTION: |
| 31 |
-- This test is designed to exercise the components of the Wide_Text_IO |
| 32 |
-- package, including the Put/Get utilities for Wide_Characters and |
| 33 |
-- Wide_String objects. |
| 34 |
-- The test utilizes the Put and Get procedures defined for |
| 35 |
-- Wide_Characters, as well as the Put, Get, Put_Line, and Get_Line |
| 36 |
-- procedures defined for Wide_Strings. In addition, many of the |
| 37 |
-- additional subprograms found in package Wide_Text_IO are used in this |
| 38 |
-- test. |
| 39 |
-- |
| 40 |
-- APPLICABILITY CRITERIA: |
| 41 |
-- This test is applicable to all implementations capable of supporting |
| 42 |
-- external Wide_Text_IO files. |
| 43 |
-- |
| 44 |
-- |
| 45 |
-- CHANGE HISTORY: |
| 46 |
-- 06 Dec 94 SAIC ACVC 2.0 |
| 47 |
-- 26 Feb 97 CTA.PWB Allowed for non-support of some IO operations. |
| 48 |
--! |
| 49 |
|
| 50 |
with Ada.Wide_Text_IO; |
| 51 |
with Report; |
| 52 |
|
| 53 |
procedure CXAB001 is |
| 54 |
|
| 55 |
Filter_File : Ada.Wide_Text_IO.File_Type; |
| 56 |
Filter_Filename : constant String := |
| 57 |
Report.Legal_File_Name ( Nam => "CXAB001" ); |
| 58 |
Incomplete : exception; |
| 59 |
|
| 60 |
|
| 61 |
begin |
| 62 |
|
| 63 |
Report.Test ("CXAB001", "Check that the operations defined in package " & |
| 64 |
"Wide_Text_IO allow for the input/output of " & |
| 65 |
"Wide_Character and Wide_String data"); |
| 66 |
|
| 67 |
|
| 68 |
Test_for_Wide_Text_IO_Support: |
| 69 |
begin |
| 70 |
|
| 71 |
-- An implementation that does not support Wide_Text_IO in a particular |
| 72 |
-- environment will raise Use_Error on calls to various |
| 73 |
-- Wide_Text_IO operations. This block statement encloses a call to |
| 74 |
-- Create, which should raise an exception in a non-supportive |
| 75 |
-- environment. This exception will be handled to produce a |
| 76 |
-- Not_Applicable result. |
| 77 |
|
| 78 |
Ada.Wide_Text_IO.Create (File => Filter_File, -- Create. |
| 79 |
Mode => Ada.Wide_Text_IO.Out_File, |
| 80 |
Name => Filter_Filename); |
| 81 |
|
| 82 |
exception |
| 83 |
|
| 84 |
when Ada.Wide_Text_IO.Use_Error | Ada.Wide_Text_IO.Name_Error => |
| 85 |
Report.Not_Applicable |
| 86 |
( "Files not supported - Create as Out_File for Wide_Text_IO" ); |
| 87 |
raise Incomplete; |
| 88 |
|
| 89 |
end Test_for_Wide_Text_IO_Support; |
| 90 |
|
| 91 |
Operational_Test_Block: |
| 92 |
declare |
| 93 |
|
| 94 |
First_String : constant Wide_String := "Somewhere "; |
| 95 |
Second_String : constant Wide_String := "Over The "; |
| 96 |
Third_String : constant Wide_String := "Rainbow"; |
| 97 |
Current_Char : Wide_Character := ' '; |
| 98 |
|
| 99 |
begin |
| 100 |
|
| 101 |
Enter_Data_In_File: |
| 102 |
declare |
| 103 |
Pos : Natural := 1; |
| 104 |
Bad_Character_Found : Boolean := False; |
| 105 |
begin |
| 106 |
-- Use the Put procedure defined for Wide_Character data to |
| 107 |
-- write all of the wide characters of the First_String into |
| 108 |
-- the file individually, followed by a call to New_Line. |
| 109 |
|
| 110 |
while Pos <= First_String'Length loop |
| 111 |
Ada.Wide_Text_IO.Put (Filter_File, First_String (Pos)); -- Put. |
| 112 |
Pos := Pos + 1; |
| 113 |
end loop; |
| 114 |
Ada.Wide_Text_IO.New_Line (Filter_File); -- New_Line. |
| 115 |
|
| 116 |
-- Reset to In_File mode and read file contents, using the Get |
| 117 |
-- procedure defined for Wide_Character data. |
| 118 |
Reset1: |
| 119 |
begin |
| 120 |
Ada.Wide_Text_IO.Reset (Filter_File, -- Reset. |
| 121 |
Ada.Wide_Text_IO.In_File); |
| 122 |
exception |
| 123 |
when Ada.Wide_Text_IO.Use_Error => |
| 124 |
Report.Not_Applicable |
| 125 |
( "Reset to In_File not supported for Wide_Text_IO" ); |
| 126 |
raise Incomplete; |
| 127 |
end Reset1; |
| 128 |
|
| 129 |
Pos := 1; |
| 130 |
while Pos <= First_String'Length loop |
| 131 |
Ada.Wide_Text_IO.Get (Filter_File, Current_Char); -- Get. |
| 132 |
-- Verify the wide character against the original string. |
| 133 |
if Current_Char /= First_String(Pos) then |
| 134 |
Bad_Character_Found := True; |
| 135 |
end if; |
| 136 |
Pos := Pos + 1; |
| 137 |
end loop; |
| 138 |
|
| 139 |
if Bad_Character_Found then |
| 140 |
Report.Failed ("Incorrect Wide_Character read from file - 1"); |
| 141 |
end if; |
| 142 |
|
| 143 |
-- Following user file/string processing, the Wide_String data |
| 144 |
-- of the Second_String and Third_String Wide_String objects are |
| 145 |
-- appended to the file. |
| 146 |
-- The Put procedure defined for Wide_String data is used to |
| 147 |
-- transfer the Second_String, followed by a call to New_Line. |
| 148 |
-- The Put_Line procedure defined for Wide_String data is used |
| 149 |
-- to transfer the Third_String. |
| 150 |
Reset2: |
| 151 |
begin |
| 152 |
Ada.Wide_Text_IO.Reset (Filter_File, -- Reset. |
| 153 |
Ada.Wide_Text_IO.Append_File); |
| 154 |
|
| 155 |
exception |
| 156 |
when Ada.Wide_Text_IO.Use_Error => |
| 157 |
Report.Not_Applicable |
| 158 |
( "Reset to Append_File not supported for Wide_Text_IO" ); |
| 159 |
raise Incomplete; |
| 160 |
end Reset2; |
| 161 |
|
| 162 |
Ada.Wide_Text_IO.Put (Filter_File, Second_String); -- Put. |
| 163 |
Ada.Wide_Text_IO.New_Line (Filter_File); -- New_Line. |
| 164 |
|
| 165 |
Ada.Wide_Text_IO.Put_Line (Filter_File, Third_String); -- Put_Line. |
| 166 |
Ada.Wide_Text_IO.Close (Filter_File); -- Close. |
| 167 |
|
| 168 |
exception |
| 169 |
|
| 170 |
when Incomplete => |
| 171 |
raise; |
| 172 |
|
| 173 |
when others => |
| 174 |
Report.Failed ("Exception in Enter_Data_In_File block"); |
| 175 |
raise; |
| 176 |
|
| 177 |
end Enter_Data_In_File; |
| 178 |
|
| 179 |
--- |
| 180 |
|
| 181 |
Filter_Block: |
| 182 |
declare |
| 183 |
|
| 184 |
Pos : Positive := 1; |
| 185 |
TC_String2 : Wide_String (1..Second_String'Length); |
| 186 |
TC_String3 : Wide_String (1..Third_String'Length); |
| 187 |
Last : Natural := Natural'First; |
| 188 |
|
| 189 |
begin |
| 190 |
|
| 191 |
Ada.Wide_Text_IO.Open (Filter_File, -- Open. |
| 192 |
Ada.Wide_Text_IO.In_File, |
| 193 |
Filter_Filename); |
| 194 |
|
| 195 |
|
| 196 |
-- Read the data of the First_String from the file, using the |
| 197 |
-- Get procedure defined for Wide_Character data. |
| 198 |
-- Verify that the character corresponds to the data originally |
| 199 |
-- written to the file. |
| 200 |
|
| 201 |
while Pos <= First_String'Length loop |
| 202 |
Ada.Wide_Text_IO.Get (Filter_File, Current_Char); -- Get. |
| 203 |
if Current_Char /= First_String(Pos) then |
| 204 |
Report.Failed |
| 205 |
("Incorrect Wide_Character read from file - 2"); |
| 206 |
end if; |
| 207 |
Pos := Pos + 1; |
| 208 |
end loop; |
| 209 |
|
| 210 |
-- The first line of the file has been read, move to the second. |
| 211 |
Ada.Wide_Text_IO.Skip_Line (Filter_File); -- Skip_Line. |
| 212 |
|
| 213 |
-- Read the Wide_String data from the second and third lines of |
| 214 |
-- the file. |
| 215 |
Ada.Wide_Text_IO.Get (Filter_File, TC_String2); -- Get. |
| 216 |
Ada.Wide_Text_IO.Skip_Line (Filter_File); -- Skip_Line. |
| 217 |
Ada.Wide_Text_IO.Get_Line (Filter_File, -- Get_Line. |
| 218 |
TC_String3, Last); |
| 219 |
|
| 220 |
-- Verify data of second and third strings. |
| 221 |
if TC_String2 /= Second_String then |
| 222 |
Report.Failed ("Incorrect Wide_String read from file - 1"); |
| 223 |
end if; |
| 224 |
if TC_String3 /= Third_String then |
| 225 |
Report.Failed ("Incorrect Wide_String read from file - 2"); |
| 226 |
end if; |
| 227 |
|
| 228 |
-- The file should now be at EOF. |
| 229 |
if not Ada.Wide_Text_IO.End_Of_File (Filter_File) then -- EOF. |
| 230 |
Report.Failed ("File not empty following filtering"); |
| 231 |
end if; |
| 232 |
|
| 233 |
exception |
| 234 |
when others => |
| 235 |
Report.Failed ("Exception in Filter_Block"); |
| 236 |
raise; |
| 237 |
end Filter_Block; |
| 238 |
|
| 239 |
exception |
| 240 |
|
| 241 |
when Incomplete => |
| 242 |
raise; |
| 243 |
when others => |
| 244 |
Report.Failed ("Exception raised in Operational Test Block"); |
| 245 |
|
| 246 |
end Operational_Test_Block; |
| 247 |
|
| 248 |
Deletion: |
| 249 |
begin |
| 250 |
if Ada.Wide_Text_IO.Is_Open (Filter_File) then -- Is_Open. |
| 251 |
Ada.Wide_Text_IO.Delete (Filter_File); -- Delete. |
| 252 |
else |
| 253 |
Ada.Wide_Text_IO.Open (Filter_File, -- Open. |
| 254 |
Ada.Wide_Text_IO.Out_File, |
| 255 |
Filter_Filename); |
| 256 |
Ada.Wide_Text_IO.Delete (Filter_File); -- Delete. |
| 257 |
end if; |
| 258 |
exception |
| 259 |
when others => |
| 260 |
Report.Failed ("Delete not properly implemented for Wide_Text_IO"); |
| 261 |
end Deletion; |
| 262 |
|
| 263 |
Report.Result; |
| 264 |
|
| 265 |
exception |
| 266 |
when Incomplete => |
| 267 |
Report.Result; |
| 268 |
when others => |
| 269 |
Report.Failed ( "Unexpected exception" ); |
| 270 |
Report.Result; |
| 271 |
|
| 272 |
end CXAB001; |