2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 * @author Elena Semukhina
22 package libcore.java.math;
24 import java.math.BigInteger;
25 import junit.framework.TestCase;
27 public class OldBigIntegerToStringTest extends TestCase {
29 public void test_toString1() {
31 String s = "0000000000";
32 BigInteger bi = new BigInteger(s);
33 String sBI = bi.toString();
34 assertEquals("toString method returns incorrect value instead of " + s, sBI, "0");
37 public void test_toString2() {
38 String s = "1234567890987654321";
39 BigInteger bi = new BigInteger(s);
40 String sBI = bi.toString();
41 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
44 public void test_toString3() {
45 String s = "-1234567890987654321";
46 BigInteger bi = new BigInteger(s);
47 String sBI = bi.toString();
48 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
51 public void test_toString4() {
52 String s = "12345678901234";
53 long l = 12345678901234L;
54 BigInteger bi = BigInteger.valueOf(l);
55 String sBI = bi.toString();
56 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
59 public void test_toString5() {
60 String s = "-12345678901234";
61 long l = -12345678901234L;
62 BigInteger bi = BigInteger.valueOf(l);
63 String sBI = bi.toString();
64 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
67 public void test_toString() {
69 12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91
71 String s = "247856948764430159964673417020251";
72 BigInteger bi = new BigInteger(aBytes);
73 String sBI = bi.toString();
74 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
76 -12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91
78 s = "-238920881723209930210060613844133";
79 bi = new BigInteger(aBytes_);
81 assertEquals("toString method returns incorrect value instead of " + s, sBI, s);