| 1 |
720 |
jeremybenn |
-- CXF3004.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 statically identifiable picture strings can be used
|
| 28 |
|
|
-- in conjunction with function Image to produce output strings
|
| 29 |
|
|
-- appropriate to foreign currency representations.
|
| 30 |
|
|
--
|
| 31 |
|
|
-- Check that statically identifiable picture strings will cause
|
| 32 |
|
|
-- function Image to raise Layout_Error under the appropriate
|
| 33 |
|
|
-- conditions.
|
| 34 |
|
|
--
|
| 35 |
|
|
-- TEST DESCRIPTION:
|
| 36 |
|
|
-- This test defines several picture strings that are statically
|
| 37 |
|
|
-- identifiable, (i.e., Pic : Picture := To_Picture("..."); ).
|
| 38 |
|
|
-- These picture strings are used in conjunction with decimal data
|
| 39 |
|
|
-- as parameters in calls to function Image.
|
| 40 |
|
|
--
|
| 41 |
|
|
--
|
| 42 |
|
|
-- CHANGE HISTORY:
|
| 43 |
|
|
-- 11 Apr 96 SAIC Initial release for 2.1.
|
| 44 |
|
|
--
|
| 45 |
|
|
--!
|
| 46 |
|
|
|
| 47 |
|
|
with Report;
|
| 48 |
|
|
with Ada.Text_IO.Editing;
|
| 49 |
|
|
with Ada.Exceptions;
|
| 50 |
|
|
|
| 51 |
|
|
procedure CXF3004 is
|
| 52 |
|
|
begin
|
| 53 |
|
|
|
| 54 |
|
|
Report.Test ("CXF3004", "Check that statically identifiable " &
|
| 55 |
|
|
"picture strings will cause function Image " &
|
| 56 |
|
|
"to raise Layout_Error under appropriate " &
|
| 57 |
|
|
"conditions");
|
| 58 |
|
|
|
| 59 |
|
|
Test_Block:
|
| 60 |
|
|
declare
|
| 61 |
|
|
|
| 62 |
|
|
use Ada.Exceptions;
|
| 63 |
|
|
use Ada.Text_IO.Editing;
|
| 64 |
|
|
|
| 65 |
|
|
FF_Currency : constant String := "FF";
|
| 66 |
|
|
DM_Currency : constant String := "DM";
|
| 67 |
|
|
FF_Separator : constant Character := '.';
|
| 68 |
|
|
DM_Separator : constant Character := ',';
|
| 69 |
|
|
FF_Radix : constant Character := ',';
|
| 70 |
|
|
DM_Radix : constant Character := '.';
|
| 71 |
|
|
Blank_Fill : constant Character := ' ';
|
| 72 |
|
|
Star_Fill : constant Character := '*';
|
| 73 |
|
|
|
| 74 |
|
|
|
| 75 |
|
|
-- Define a decimal data type, and instantiate the Decimal_Output
|
| 76 |
|
|
-- generic package for the data type.
|
| 77 |
|
|
|
| 78 |
|
|
type Decimal_Data_Type is delta 0.01 digits 16;
|
| 79 |
|
|
|
| 80 |
|
|
package Image_IO is
|
| 81 |
|
|
new Decimal_Output(Num => Decimal_Data_Type,
|
| 82 |
|
|
Default_Currency => "$",
|
| 83 |
|
|
Default_Fill => Star_Fill,
|
| 84 |
|
|
Default_Separator => Default_Separator,
|
| 85 |
|
|
Default_Radix_Mark => DM_Radix);
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
-- The following decimal data items are used with picture strings
|
| 90 |
|
|
-- in evaluating use of foreign currency symbols.
|
| 91 |
|
|
|
| 92 |
|
|
Dec_Data_1 : Decimal_Data_Type := 123456.78;
|
| 93 |
|
|
Dec_Data_2 : Decimal_Data_Type := 32.10;
|
| 94 |
|
|
Dec_Data_3 : Decimal_Data_Type := -1234.57;
|
| 95 |
|
|
Dec_Data_4 : Decimal_Data_Type := 123456.78;
|
| 96 |
|
|
Dec_Data_5 : Decimal_Data_Type := 12.34;
|
| 97 |
|
|
Dec_Data_6 : Decimal_Data_Type := 12.34;
|
| 98 |
|
|
Dec_Data_7 : Decimal_Data_Type := 12345.67;
|
| 99 |
|
|
|
| 100 |
|
|
|
| 101 |
|
|
-- Statically identifiable picture strings.
|
| 102 |
|
|
-- These strings are used in conjunction with non-default values
|
| 103 |
|
|
-- for Currency string, Radix mark, and Separator in calls to
|
| 104 |
|
|
-- function Image.
|
| 105 |
|
|
|
| 106 |
|
|
Picture_1 : Picture := To_Picture("-###**_***_**9.99"); -- FF
|
| 107 |
|
|
Picture_2 : Picture := To_Picture("###z_ZZ9.99"); -- FF
|
| 108 |
|
|
Picture_3 : Picture := To_Picture("<<<<_<<<.<<###>"); -- DM
|
| 109 |
|
|
Picture_4 : Picture := To_Picture("-$_$$$_$$$_$$9.99"); -- DM
|
| 110 |
|
|
Picture_5 : Picture := To_Picture("$Zz9.99"); -- DM
|
| 111 |
|
|
Picture_6 : Picture := To_Picture("$$$9.99"); -- DM
|
| 112 |
|
|
Picture_7 : Picture := To_Picture("###_###_##9.99"); -- CHF
|
| 113 |
|
|
|
| 114 |
|
|
|
| 115 |
|
|
-- The following ten edited output strings correspond to the ten
|
| 116 |
|
|
-- foreign currency picture strings.
|
| 117 |
|
|
|
| 118 |
|
|
Output_1 : constant String := " FF***123.456,78";
|
| 119 |
|
|
Output_2 : constant String := " FF 32,10";
|
| 120 |
|
|
Output_3 : constant String := " (1,234.57DM )";
|
| 121 |
|
|
Output_4 : constant String := " DM123,456.78";
|
| 122 |
|
|
Output_5 : constant String := "DM 12.34";
|
| 123 |
|
|
Output_6 : constant String := " DM12.34";
|
| 124 |
|
|
Output_7 : constant String := " CHF12,345.67";
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
begin
|
| 128 |
|
|
|
| 129 |
|
|
-- Check the results of function Image, using the picture strings
|
| 130 |
|
|
-- constructed above, in creating foreign currency edited output
|
| 131 |
|
|
-- strings.
|
| 132 |
|
|
|
| 133 |
|
|
if Image_IO.Image(Item => Dec_Data_1,
|
| 134 |
|
|
Pic => Picture_1,
|
| 135 |
|
|
Currency => FF_Currency,
|
| 136 |
|
|
Fill => Star_Fill,
|
| 137 |
|
|
Separator => FF_Separator,
|
| 138 |
|
|
Radix_Mark => FF_Radix) /= Output_1
|
| 139 |
|
|
then
|
| 140 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_1");
|
| 141 |
|
|
end if;
|
| 142 |
|
|
|
| 143 |
|
|
if Image_IO.Image(Item => Dec_Data_2,
|
| 144 |
|
|
Pic => Picture_2,
|
| 145 |
|
|
Currency => FF_Currency,
|
| 146 |
|
|
Fill => Blank_Fill,
|
| 147 |
|
|
Separator => FF_Separator,
|
| 148 |
|
|
Radix_Mark => FF_Radix) /= Output_2
|
| 149 |
|
|
then
|
| 150 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_2");
|
| 151 |
|
|
end if;
|
| 152 |
|
|
|
| 153 |
|
|
if Image_IO.Image(Item => Dec_Data_3,
|
| 154 |
|
|
Pic => Picture_3,
|
| 155 |
|
|
Currency => DM_Currency,
|
| 156 |
|
|
Fill => Blank_Fill,
|
| 157 |
|
|
Separator => DM_Separator,
|
| 158 |
|
|
Radix_Mark => DM_Radix) /= Output_3
|
| 159 |
|
|
then
|
| 160 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_3");
|
| 161 |
|
|
end if;
|
| 162 |
|
|
|
| 163 |
|
|
if Image_IO.Image(Item => Dec_Data_4,
|
| 164 |
|
|
Pic => Picture_4,
|
| 165 |
|
|
Currency => DM_Currency,
|
| 166 |
|
|
Fill => Blank_Fill,
|
| 167 |
|
|
Separator => DM_Separator,
|
| 168 |
|
|
Radix_Mark => DM_Radix) /= Output_4
|
| 169 |
|
|
then
|
| 170 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_4");
|
| 171 |
|
|
end if;
|
| 172 |
|
|
|
| 173 |
|
|
if Image_IO.Image(Item => Dec_Data_5,
|
| 174 |
|
|
Pic => Picture_5,
|
| 175 |
|
|
Currency => DM_Currency,
|
| 176 |
|
|
Fill => Blank_Fill,
|
| 177 |
|
|
Separator => DM_Separator,
|
| 178 |
|
|
Radix_Mark => DM_Radix) /= Output_5
|
| 179 |
|
|
then
|
| 180 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_5");
|
| 181 |
|
|
end if;
|
| 182 |
|
|
|
| 183 |
|
|
if Image_IO.Image(Item => Dec_Data_6,
|
| 184 |
|
|
Pic => Picture_6,
|
| 185 |
|
|
Currency => DM_Currency,
|
| 186 |
|
|
Fill => Blank_Fill,
|
| 187 |
|
|
Separator => DM_Separator,
|
| 188 |
|
|
Radix_Mark => DM_Radix) /= Output_6
|
| 189 |
|
|
then
|
| 190 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_6");
|
| 191 |
|
|
end if;
|
| 192 |
|
|
|
| 193 |
|
|
if Image_IO.Image(Item => Dec_Data_7,
|
| 194 |
|
|
Pic => Picture_7,
|
| 195 |
|
|
Currency => "CHF",
|
| 196 |
|
|
Fill => Blank_Fill,
|
| 197 |
|
|
Separator => ',',
|
| 198 |
|
|
Radix_Mark => '.') /= Output_7
|
| 199 |
|
|
then
|
| 200 |
|
|
Report.Failed("Incorrect result from Fn. Image using Picture_7");
|
| 201 |
|
|
end if;
|
| 202 |
|
|
|
| 203 |
|
|
|
| 204 |
|
|
-- The following calls of Function Image, using the specific
|
| 205 |
|
|
-- decimal values and picture strings provided, will cause
|
| 206 |
|
|
-- a Layout_Error to be raised.
|
| 207 |
|
|
-- Note: The data and the picture strings used in the following
|
| 208 |
|
|
-- evaluations are not themselves erroneous, but when used in
|
| 209 |
|
|
-- combination will cause Layout_Error to be raised.
|
| 210 |
|
|
|
| 211 |
|
|
Exception_Block_1 :
|
| 212 |
|
|
declare
|
| 213 |
|
|
Erroneous_Data_1 : Decimal_Data_Type := 12.34;
|
| 214 |
|
|
Erroneous_Picture_1 : Picture := To_Picture("9.99");
|
| 215 |
|
|
N : constant Natural := Image_IO.Length(Erroneous_Picture_1);
|
| 216 |
|
|
TC_String : String(1..N);
|
| 217 |
|
|
begin
|
| 218 |
|
|
TC_String := Image_IO.Image(Erroneous_Data_1, Erroneous_Picture_1);
|
| 219 |
|
|
Report.Failed("Layout_Error not raised by combination of " &
|
| 220 |
|
|
"Erroneous_Picture_1 and Erroneous_Data_1");
|
| 221 |
|
|
Report.Comment("Should never be printed: " & TC_String);
|
| 222 |
|
|
exception
|
| 223 |
|
|
when Ada.Text_IO.Layout_Error => null; -- OK, expected exception.
|
| 224 |
|
|
when The_Error : others =>
|
| 225 |
|
|
Report.Failed
|
| 226 |
|
|
("The following exception was incorrectly raised in " &
|
| 227 |
|
|
"Exception_Block_1: " & Exception_Name(The_Error));
|
| 228 |
|
|
end Exception_Block_1;
|
| 229 |
|
|
|
| 230 |
|
|
Exception_Block_2 :
|
| 231 |
|
|
declare
|
| 232 |
|
|
Erroneous_Data_2 : Decimal_Data_Type := -12.34;
|
| 233 |
|
|
Erroneous_Picture_2 : Picture := To_Picture("99.99");
|
| 234 |
|
|
N : constant Natural := Image_IO.Length(Erroneous_Picture_2);
|
| 235 |
|
|
TC_String : String(1..N);
|
| 236 |
|
|
begin
|
| 237 |
|
|
TC_String := Image_IO.Image(Erroneous_Data_2, Erroneous_Picture_2);
|
| 238 |
|
|
Report.Failed("Layout_Error not raised by combination of " &
|
| 239 |
|
|
"Erroneous_Picture_2 and Erroneous_Data_2");
|
| 240 |
|
|
Report.Comment("Should never be printed: " & TC_String);
|
| 241 |
|
|
exception
|
| 242 |
|
|
when Ada.Text_IO.Layout_Error => null; -- OK, expected exception.
|
| 243 |
|
|
when The_Error : others =>
|
| 244 |
|
|
Report.Failed
|
| 245 |
|
|
("The following exception was incorrectly raised in " &
|
| 246 |
|
|
"Exception_Block_2: " & Exception_Name(The_Error));
|
| 247 |
|
|
end Exception_Block_2;
|
| 248 |
|
|
|
| 249 |
|
|
exception
|
| 250 |
|
|
when The_Error : others =>
|
| 251 |
|
|
Report.Failed("The following exception was raised in the " &
|
| 252 |
|
|
"Test_Block: " & Exception_Name(The_Error));
|
| 253 |
|
|
end Test_Block;
|
| 254 |
|
|
|
| 255 |
|
|
Report.Result;
|
| 256 |
|
|
|
| 257 |
|
|
end CXF3004;
|