1-- CXF3002.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 functionality contained in package 28-- Ada.Wide_Text_IO.Editing is available and produces correct results. 29-- 30-- TEST DESCRIPTION: 31-- This test is designed to validate the procedures and functions that 32-- are found in package Ada.Wide_Text_IO.Editing, the "wide" 33-- complementary package to Ada.Text_IO.Editing. The test is similar 34-- to CXF3301, which tested a large portion of the Ada.Text_IO.Editing 35-- package. Additional testing has been added here to cover the balance 36-- of the Wide_Text_IO.Editing child package. 37 38-- This test is structured using tables of data, consisting of 39-- numerical values, picture strings, and expected image 40-- result strings. 41-- 42-- Each picture string is checked for validity, and an invalid picture 43-- string will cause immediate test failure on its first pass through 44-- the evaluation loop. Inside the evaluation loop, each decimal data 45-- item is combined with each of the picture strings as parameters to a 46-- call to Image, and the result of each call is compared to an 47-- expected edited output result string. 48-- 49-- Note: Each of the functions Valid, To_Picture, and Pic_String has 50-- String (rather than Wide_String) as its parameter or result 51-- subtype, since a picture String is not localizable. 52-- 53-- 54-- CHANGE HISTORY: 55-- 22 Jun 95 SAIC Initial prerelease version. 56-- 22 Aug 95 SAIC Test name changed to CXF3002 (from CXF3401) to 57-- conform with naming conventions. 58-- 24 Feb 97 PWB.CTA Corrected picture strings and expected values. 59--! 60 61with Ada.Wide_Text_IO.Editing; 62with Report; 63 64procedure CXF3002 is 65begin 66 67 Report.Test ("CXF3002", "Check that the functionality contained " & 68 "in package Ada.Wide_Text_IO.Editing is " & 69 "available and produces correct results"); 70 71 Test_Block: 72 declare 73 74 use Ada.Wide_Text_IO; 75 76 Number_Of_Decimal_Items : constant := 5; 77 Number_Of_Picture_Strings : constant := 4; 78 Number_Of_Expected_Results : constant := Number_Of_Decimal_Items * 79 Number_Of_Picture_Strings; 80 81 Def_Cur : constant Wide_String := "$"; 82 Def_Fill : constant Wide_Character := '*'; 83 Def_Sep : constant Wide_Character := Editing.Default_Separator; 84 Def_Radix : constant Wide_Character := Editing.Default_Radix_Mark; 85 86 type String_Pointer_Type is access String; 87 type Wide_String_Pointer_Type is access Wide_String; 88 89 -- Define a decimal data type, and instantiate the Decimal_Output 90 -- generic package for the data type. 91 92 type Decimal_Data_Type is delta 0.01 digits 16; 93 94 package Wide_Ed_Out is 95 new Editing.Decimal_Output(Num => Decimal_Data_Type, 96 Default_Currency => Def_Cur, 97 Default_Fill => Def_Fill, 98 Default_Separator => Def_Sep, 99 Default_Radix_Mark => Def_Radix); 100 101 -- Define types for the arrays of data that will hold the decimal data 102 -- values, picture strings, and expected edited output results. 103 104 type Decimal_Data_Array_Type is 105 array (Integer range <>) of Decimal_Data_Type; 106 107 type Picture_String_Array_Type is 108 array (Integer range <>) of String_Pointer_Type; 109 110 type Edited_Output_Results_Array_Type is 111 array (Integer range <>) of Wide_String_Pointer_Type; 112 113 -- Define the data arrays for this test. 114 115 Decimal_Data : 116 Decimal_Data_Array_Type(1..Number_Of_Decimal_Items) := 117 ( 1 => 5678.90, 118 2 => -6789.01, 119 3 => 0.00, 120 4 => 0.20, 121 5 => 3.45 122 ); 123 124 Picture_Strings : 125 Picture_String_Array_Type(1..Number_Of_Picture_Strings) := 126 ( 1 => new String'("-$$_$$9.99"), 127 2 => new String'("-$$_$$$.$$"), 128 3 => new String'("-ZZZZ.ZZ"), 129 4 => new String'("-$$$_999.99") 130 ); 131 132 133 Edited_Output : 134 Edited_Output_Results_Array_Type(1..Number_Of_Expected_Results) := 135 ( 1 => new Wide_String'(" $5,678.90"), 136 2 => new Wide_String'(" $5,678.90"), 137 3 => new Wide_String'(" 5678.90"), 138 4 => new Wide_String'(" $5,678.90"), 139 140 5 => new Wide_String'("-$6,789.01"), 141 6 => new Wide_String'("-$6,789.01"), 142 7 => new Wide_String'("-6789.01"), 143 8 => new Wide_String'("- $6,789.01"), 144 145 9 => new Wide_String'(" $0.00"), 146 10 => new Wide_String'(" "), 147 11 => new Wide_String'(" "), 148 12 => new Wide_String'(" $ 000.00"), 149 150 13 => new Wide_String'(" $0.20"), 151 14 => new Wide_String'(" $.20"), 152 15 => new Wide_String'(" .20"), 153 16 => new Wide_String'(" $ 000.20"), 154 155 17 => new Wide_String'(" $3.45"), 156 18 => new Wide_String'(" $3.45"), 157 19 => new Wide_String'(" 3.45"), 158 20 => new Wide_String'(" $ 003.45") 159 ); 160 161 TC_Picture : Editing.Picture; 162 TC_Loop_Count : Natural := 0; 163 164 begin 165 166 -- Compare string result of Image with expected edited output wide 167 -- string. 168 169 Evaluate_Edited_Output: 170 for i in 1..Number_Of_Decimal_Items loop 171 for j in 1..Number_Of_Picture_Strings loop 172 173 TC_Loop_Count := TC_Loop_Count + 1; 174 175 -- Check on the validity of the picture strings prior to 176 -- processing. 177 178 if Editing.Valid(Picture_Strings(j).all) then 179 180 -- Create the picture object from the picture string. 181 TC_Picture := Editing.To_Picture(Picture_Strings(j).all); 182 183 -- Check results of function Decimal_Output.Valid. 184 if not Wide_Ed_Out.Valid(Decimal_Data(i), TC_Picture) then 185 Report.Failed("Incorrect result from function Valid " & 186 "when examining the picture string that " & 187 "was produced from string " & 188 Integer'Image(j) & " in conjunction with " & 189 "decimal data item # " & Integer'Image(i)); 190 end if; 191 192 -- Check results of function Editing.Pic_String. 193 if Editing.Pic_String(TC_Picture) /= Picture_Strings(j).all then 194 Report.Failed("Incorrect result from To_Picture/" & 195 "Pic_String conversion for picture " & 196 "string # " & Integer'Image(j)); 197 end if; 198 199 -- Compare actual edited output result of Function Image with 200 -- the expected result. 201 202 if Wide_Ed_Out.Image(Decimal_Data(i), TC_Picture) /= 203 Edited_Output(TC_Loop_Count).all 204 then 205 Report.Failed("Incorrect result from Function Image, " & 206 "when used with decimal data item # " & 207 Integer'Image(i) & 208 " and picture string # " & 209 Integer'Image(j)); 210 end if; 211 212 else 213 Report.Failed("Picture String # " & Integer'Image(j) & 214 "reported as being invalid"); 215 end if; 216 217 end loop; 218 end loop Evaluate_Edited_Output; 219 220 exception 221 when Editing.Picture_Error => 222 Report.Failed ("Picture_Error raised in Test_Block"); 223 when Layout_Error => 224 Report.Failed ("Layout_Error raised in Test_Block"); 225 when others => 226 Report.Failed ("Exception raised in Test_Block"); 227 end Test_Block; 228 229 Report.Result; 230 231end CXF3002; 232