1/*
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
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17/**
18 * @author Elena Semukhina
19 * @version $Revision$
20 */
21
22package libcore.java.math;
23
24import java.math.BigInteger;
25import junit.framework.TestCase;
26
27public class OldBigIntegerToStringTest extends TestCase {
28
29    public void test_toString1() {
30
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");
35    }
36
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);
42    }
43
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);
49    }
50
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);
57    }
58
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);
65    }
66
67    public void test_toString() {
68        byte aBytes[] = {
69                12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91
70        };
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);
75        byte aBytes_[] = {
76                -12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91
77        };
78        s = "-238920881723209930210060613844133";
79        bi = new BigInteger(aBytes_);
80        sBI = bi.toString();
81        assertEquals("toString method returns incorrect value instead of " + s, sBI, s);
82    }
83}
84