3 -- Grant of Unlimited Rights
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
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.
27 -- Check that the function Valid with Packed_Decimal and Packed_Format
28 -- parameters returns True if Item (the Packed_Decimal parameter) has
29 -- a value consistent with the Packed_Format parameter.
31 -- Check that the function Length with Packed_Format parameter returns
32 -- the minimal length of a Packed_Decimal value sufficient to hold any
33 -- value of type Num when represented according to parameter Format.
35 -- Check that the function To_Decimal with Packed_Decimal and
36 -- Packed_Format parameters produces a decimal type value corresponding
37 -- to the Packed_Decimal parameter value Item, under the conditions of
38 -- the Packed_Format parameter Format.
40 -- Check that the function To_Packed with Decimal (Num) and
41 -- Packed_Format parameters produces a Packed_Decimal result that
42 -- corresponds to the decimal parameter under conditions of the
43 -- Packed_Format parameter.
45 -- Check that Conversion_Error is propagated by function To_Packed if
46 -- the value of the decimal parameter Item is negative and the specified
47 -- Packed_Format parameter is Packed_Unsigned.
51 -- This test checks the results from instantiated versions of
52 -- several functions that deal with parameters or results of type
53 -- Packed_Decimal. Since the rules for the formation of Packed_Decimal
54 -- values are implementation defined, several of the subtests cannot
55 -- directly check the accuracy of the results produced. Instead, they
56 -- verify that the result is within a range of possible values, or
57 -- that the result of one function can be converted back to the original
58 -- actual parameter using a "mirror image" conversion function.
60 -- APPLICABILITY CRITERIA:
61 -- This test is applicable to all implementations that provide
62 -- package Interfaces.COBOL. If an implementation provides
63 -- package Interfaces.COBOL, this test must compile, execute, and
68 -- 12 Feb 96 SAIC Initial release for 2.1.
69 -- 30 May 96 SAIC Incorporated reviewer comments for ACVC 2.1.
70 -- 27 Oct 96 SAIC Incorporated reviewer comments.
76 with Interfaces
.COBOL
; -- N/A => ERROR
81 Report
.Test
("CXB4006", "Check that the functions Valid, Length, " &
82 "To_Decimal, and To_Packed specific to " &
83 "Packed_Decimal parameters produce correct " &
91 use type Interfaces
.COBOL
.Numeric
;
93 type Decimal_Type_1
is delta 0.1 digits 6;
94 type Decimal_Type_2
is delta 0.01 digits 8;
95 type Decimal_Type_3
is delta 0.001 digits 10;
96 type Decimal_Type_4
is delta 0.0001 digits 12;
98 package Pack_1
is new Decimal_Conversions
(Decimal_Type_1
);
99 package Pack_2
is new Decimal_Conversions
(Decimal_Type_2
);
100 package Pack_3
is new Decimal_Conversions
(Decimal_Type_3
);
101 package Pack_4
is new Decimal_Conversions
(Decimal_Type_4
);
103 TC_Dec_1
: Decimal_Type_1
:= 12345.6;
104 TC_Dec_2
: Decimal_Type_2
:= 123456.78;
105 TC_Dec_3
: Decimal_Type_3
:= 1234567.890;
106 TC_Dec_4
: Decimal_Type_4
:= 12345678.9012;
107 TC_Min_Length
: Natural := 1;
108 TC_Max_Length
: Natural := 16;
112 -- Check that the function Valid with Packed_Decimal and Packed_Format
113 -- parameters returns True if Item (the Packed_Decimal parameter) has
114 -- a value consistent with the Packed_Format parameter.
115 -- Note: Since the formation rules for Packed_Decimal values are
116 -- implementation defined, the parameter values here are
117 -- created by function To_Packed.
120 if not Pack_1
.Valid
(Item
=> Pack_1
.To_Packed
(TC_Dec_1
,
122 Format
=> Packed_Unsigned
)
124 Report
.Failed
("Incorrect result from function Valid - 1");
127 TC_Dec_2
:= -4321.03;
128 if not Pack_2
.Valid
(Pack_2
.To_Packed
(TC_Dec_2
, Packed_Signed
),
129 Format
=> Packed_Signed
) or
130 Pack_2
.Valid
(Pack_2
.To_Packed
(TC_Dec_2
, Packed_Signed
),
131 Format
=> Packed_Unsigned
)
133 Report
.Failed
("Incorrect result from function Valid - 2");
136 TC_Dec_3
:= 1234567.890;
137 if not Pack_3
.Valid
(Pack_3
.To_Packed
(TC_Dec_3
, Packed_Unsigned
),
140 Report
.Failed
("Incorrect result from function Valid - 3");
143 TC_Dec_4
:= -234.6789;
144 if not Pack_4
.Valid
(Item
=> Pack_4
.To_Packed
(TC_Dec_4
,
146 Format
=> Packed_Signed
) or
147 Pack_4
.Valid
(Item
=> Pack_4
.To_Packed
(TC_Dec_4
, Packed_Signed
),
148 Format
=> Packed_Unsigned
)
150 Report
.Failed
("Incorrect result from function Valid - 4");
155 -- Check that the function Length with Packed_Format parameter returns
156 -- the minimal length of a Packed_Decimal value sufficient to hold any
157 -- value of type Num when represented according to parameter Format.
159 if NOT (Pack_1
.Length
(Packed_Signed
) >= TC_Min_Length
AND
160 Pack_1
.Length
(Packed_Signed
) <= TC_Max_Length
AND
161 Pack_1
.Length
(Packed_Unsigned
) >= TC_Min_Length
AND
162 Pack_1
.Length
(Packed_Unsigned
) <= TC_Max_Length
)
164 Report
.Failed
("Incorrect result from function Length - 1");
167 if NOT (Pack_2
.Length
(Packed_Signed
) >= TC_Min_Length
AND
168 Pack_2
.Length
(Packed_Signed
) <= TC_Max_Length
AND
169 Pack_2
.Length
(Packed_Unsigned
) >= TC_Min_Length
AND
170 Pack_2
.Length
(Packed_Unsigned
) <= TC_Max_Length
)
172 Report
.Failed
("Incorrect result from function Length - 2");
175 if NOT (Pack_3
.Length
(Packed_Signed
) >= TC_Min_Length
AND
176 Pack_3
.Length
(Packed_Signed
) <= TC_Max_Length
AND
177 Pack_3
.Length
(Packed_Unsigned
) >= TC_Min_Length
AND
178 Pack_3
.Length
(Packed_Unsigned
) <= TC_Max_Length
)
180 Report
.Failed
("Incorrect result from function Length - 3");
183 if NOT (Pack_4
.Length
(Packed_Signed
) >= TC_Min_Length
AND
184 Pack_4
.Length
(Packed_Signed
) <= TC_Max_Length
AND
185 Pack_4
.Length
(Packed_Unsigned
) >= TC_Min_Length
AND
186 Pack_4
.Length
(Packed_Unsigned
) <= TC_Max_Length
)
188 Report
.Failed
("Incorrect result from function Length - 4");
193 -- Check that the function To_Decimal with Packed_Decimal and
194 -- Packed_Format parameters produces a decimal type value corresponding
195 -- to the Packed_Decimal parameter value Item, under the conditions of
196 -- the Packed_Format parameter Format.
200 if Pack_1
.To_Decimal
(Item
=> Pack_1
.To_Packed
(TC_Dec_1
,
202 Format
=> Packed_Unsigned
) /= TC_Dec_1
204 Report
.Failed
("Incorrect result from function To_Decimal - 1");
207 when The_Error
: others =>
208 Report
.Failed
("The following exception was raised in " &
209 "subtest 1 of function To_Decimal: " &
210 Exception_Name
(The_Error
));
214 TC_Dec_2
:= -123456.50;
215 if Pack_2
.To_Decimal
(Pack_2
.To_Packed
(TC_Dec_2
, Packed_Signed
),
216 Format
=> Packed_Signed
) /= TC_Dec_2
218 Report
.Failed
("Incorrect result from function To_Decimal - 2");
221 when The_Error
: others =>
222 Report
.Failed
("The following exception was raised in " &
223 "subtest 2 of function To_Decimal: " &
224 Exception_Name
(The_Error
));
228 TC_Dec_3
:= 1234567.809;
229 if Pack_3
.To_Decimal
(Pack_3
.To_Packed
(TC_Dec_3
, Packed_Unsigned
),
230 Packed_Unsigned
) /= TC_Dec_3
232 Report
.Failed
("Incorrect result from function To_Decimal - 3");
235 when The_Error
: others =>
236 Report
.Failed
("The following exception was raised in " &
237 "subtest 3 of function To_Decimal: " &
238 Exception_Name
(The_Error
));
242 TC_Dec_4
:= -789.1234;
243 if Pack_4
.To_Decimal
(Item
=> Pack_4
.To_Packed
(TC_Dec_4
,
245 Format
=> Packed_Signed
) /= TC_Dec_4
247 Report
.Failed
("Incorrect result from function To_Decimal - 4");
250 when The_Error
: others =>
251 Report
.Failed
("The following exception was raised in " &
252 "subtest 4 of function To_Decimal: " &
253 Exception_Name
(The_Error
));
258 -- Check that the function To_Packed with Decimal (Num) and
259 -- Packed_Format parameters produces a Packed_Decimal result that
260 -- corresponds to the decimal parameter under conditions of the
261 -- Packed_Format parameter.
263 if Pack_1
.To_Packed
(Item
=> 123.4, Format
=> Packed_Unsigned
) =
264 Pack_1
.To_Packed
(Item
=> -123.4, Format
=> Packed_Signed
)
266 Report
.Failed
("Incorrect result from function To_Packed - 1");
269 if Pack_2
.To_Packed
( 123.45, Format
=> Packed_Unsigned
) =
270 Pack_2
.To_Packed
(-123.45, Format
=> Packed_Signed
)
272 Report
.Failed
("Incorrect result from function To_Packed - 2");
275 if Pack_3
.To_Packed
(Item
=> 123.456, Format
=> Packed_Unsigned
) =
276 Pack_3
.To_Packed
(Item
=> -123.456, Format
=> Packed_Signed
)
278 Report
.Failed
("Incorrect result from function To_Packed - 3");
281 if (Pack_4
.To_Packed
( 123.4567, Packed_Unsigned
) =
282 Pack_4
.To_Packed
(-123.4567, Packed_Signed
)) or
283 (Pack_4
.To_Packed
(12345678.9012, Packed_Unsigned
) =
284 Pack_4
.To_Packed
(12345678.9013, Packed_Unsigned
)) or
285 (Pack_4
.To_Packed
(12345678.9012, Packed_Unsigned
) =
286 Pack_4
.To_Packed
(22345678.9012, Packed_Unsigned
))
288 Report
.Failed
("Incorrect result from function To_Packed - 4");
292 -- Check that Conversion_Error is propagated by function To_Packed if
293 -- the value of the decimal parameter Item is negative and the
294 -- specified Packed_Format parameter is Packed_Unsigned.
297 if Pack_1
.To_Packed
(Item
=> -12.3, Format
=> Packed_Unsigned
) =
298 Pack_1
.To_Packed
(Item
=> 12.3, Format
=> Packed_Signed
)
300 Report
.Comment
("Should never be printed");
302 Report
.Failed
("Conversion_Error not raised following call to " &
303 "function To_Packed with a negative parameter " &
304 "Item and Packed_Format parameter Packed_Unsigned");
306 when Conversion_Error
=> null; -- OK, expected exception.
307 when The_Error
: others =>
308 Report
.Failed
(Exception_Name
(The_Error
) & " was incorrectly " &
309 "raised following call to function To_Packed " &
310 "with a negative parameter Item and " &
311 "Packed_Format parameter Packed_Unsigned");
315 when The_Error
: others =>
316 Report
.Failed
("The following exception was raised in the " &
317 "Test_Block: " & Exception_Name
(The_Error
));