author | malenkov |
Fri, 16 May 2014 15:51:57 +0400 | |
changeset 25088 | 8d4b058368f0 |
parent 10588 | d8173a78bdca |
permissions | -rw-r--r-- |
10588
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
1 |
/* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
4 |
* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
8 |
* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
13 |
* accompanied this code). |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
14 |
* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
18 |
* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
21 |
* questions. |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
22 |
*/ |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
23 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
24 |
/* |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
25 |
* @test |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
26 |
* @bug 6371401 |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
27 |
* @summary Tests of fooValueExact methods |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
28 |
* @author Joseph D. Darcy |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
29 |
*/ |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
30 |
import java.math.BigInteger; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
31 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
32 |
public class TestValueExact { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
33 |
public static void main(String... args) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
34 |
int errors = 0; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
35 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
36 |
errors += testLongValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
37 |
errors += testIntValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
38 |
errors += testShortValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
39 |
errors += testByteValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
40 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
41 |
if (errors > 0) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
42 |
throw new RuntimeException(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
43 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
44 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
45 |
private static int testLongValueExact() { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
46 |
int errors = 0; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
47 |
BigInteger[] inRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
48 |
BigInteger.valueOf(Long.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
49 |
BigInteger.ZERO, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
50 |
BigInteger.valueOf(Long.MAX_VALUE) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
51 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
52 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
53 |
BigInteger[] outOfRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
54 |
BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
55 |
BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
56 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
57 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
58 |
for (BigInteger bi : inRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
59 |
if (bi.longValueExact() != bi.longValue()) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
60 |
System.err.println("Mismatching int conversion for " + bi); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
61 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
62 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
63 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
64 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
65 |
for (BigInteger bi : outOfRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
66 |
try { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
67 |
long value = bi.longValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
68 |
System.err.println("Failed to get expected exception on " + |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
69 |
bi + " got " + value); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
70 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
71 |
} catch(ArithmeticException ae) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
72 |
; // Expected |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
73 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
74 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
75 |
return errors; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
76 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
77 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
78 |
private static int testIntValueExact() { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
79 |
int errors = 0; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
80 |
BigInteger[] inRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
81 |
BigInteger.valueOf(Integer.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
82 |
BigInteger.ZERO, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
83 |
BigInteger.ONE, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
84 |
BigInteger.TEN, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
85 |
BigInteger.valueOf(Integer.MAX_VALUE) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
86 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
87 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
88 |
BigInteger[] outOfRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
89 |
BigInteger.valueOf((long)Integer.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
90 |
BigInteger.valueOf((long)Integer.MAX_VALUE + 1) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
91 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
92 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
93 |
for (BigInteger bi : inRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
94 |
if (bi.intValueExact() != bi.intValue()) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
95 |
System.err.println("Mismatching int conversion for " + bi); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
96 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
97 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
98 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
99 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
100 |
for (BigInteger bi : outOfRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
101 |
try { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
102 |
int value = bi.intValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
103 |
System.err.println("Failed to get expected exception on " + |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
104 |
bi + " got " + value); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
105 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
106 |
} catch(ArithmeticException ae) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
107 |
; // Expected |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
108 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
109 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
110 |
return errors; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
111 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
112 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
113 |
private static int testShortValueExact() { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
114 |
int errors = 0; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
115 |
BigInteger[] inRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
116 |
BigInteger.valueOf(Short.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
117 |
BigInteger.ZERO, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
118 |
BigInteger.ONE, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
119 |
BigInteger.TEN, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
120 |
BigInteger.valueOf(Short.MAX_VALUE) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
121 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
122 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
123 |
BigInteger[] outOfRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
124 |
BigInteger.valueOf((long)Integer.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
125 |
BigInteger.valueOf((long)Integer.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
126 |
BigInteger.valueOf( (int)Short.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
127 |
BigInteger.valueOf( (int)Short.MAX_VALUE + 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
128 |
BigInteger.valueOf((long)Integer.MAX_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
129 |
BigInteger.valueOf((long)Integer.MAX_VALUE + 1) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
130 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
131 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
132 |
for (BigInteger bi : inRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
133 |
if (bi.shortValueExact() != bi.shortValue()) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
134 |
System.err.println("Mismatching short conversion for " + bi); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
135 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
136 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
137 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
138 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
139 |
for (BigInteger bi : outOfRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
140 |
try { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
141 |
int value = bi.shortValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
142 |
System.err.println("Failed to get expected exception on " + |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
143 |
bi + " got " + value); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
144 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
145 |
} catch(ArithmeticException ae) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
146 |
; // Expected |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
147 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
148 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
149 |
return errors; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
150 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
151 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
152 |
private static int testByteValueExact() { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
153 |
int errors = 0; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
154 |
BigInteger[] inRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
155 |
BigInteger.valueOf(Byte.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
156 |
BigInteger.valueOf(0), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
157 |
BigInteger.ONE, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
158 |
BigInteger.TEN, |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
159 |
BigInteger.valueOf(Byte.MAX_VALUE) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
160 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
161 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
162 |
BigInteger[] outOfRange = { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
163 |
BigInteger.valueOf((long)Integer.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
164 |
BigInteger.valueOf((long)Integer.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
165 |
BigInteger.valueOf( (int)Short.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
166 |
BigInteger.valueOf( (int)Short.MIN_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
167 |
BigInteger.valueOf( (int)Byte.MIN_VALUE - 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
168 |
BigInteger.valueOf( (int)Byte.MAX_VALUE + 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
169 |
BigInteger.valueOf( (int)Short.MAX_VALUE + 1), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
170 |
BigInteger.valueOf( (int)Short.MAX_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
171 |
BigInteger.valueOf((long)Integer.MAX_VALUE), |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
172 |
BigInteger.valueOf((long)Integer.MAX_VALUE + 1) |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
173 |
}; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
174 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
175 |
for (BigInteger bi : inRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
176 |
if (bi.byteValueExact() != bi.byteValue()) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
177 |
System.err.println("Mismatching byte conversion for " + bi); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
178 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
179 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
180 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
181 |
|
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
182 |
for (BigInteger bi : outOfRange) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
183 |
try { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
184 |
int value = bi.byteValueExact(); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
185 |
System.err.println("Failed to get expected exception on " + |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
186 |
bi + " got " + value); |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
187 |
errors++; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
188 |
} catch(ArithmeticException ae) { |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
189 |
; // Expected |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
190 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
191 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
192 |
return errors; |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
193 |
} |
d8173a78bdca
6879143: java.math.BigInteger misses the xxxValueExact methods
darcy
parents:
diff
changeset
|
194 |
} |