LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package big | 5 package big |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/hex" | 9 "encoding/hex" |
10 "testing" | 10 "testing" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 fromStringTest{"0", 10, 0, true}, | 144 fromStringTest{"0", 10, 0, true}, |
145 fromStringTest{"0", 16, 0, true}, | 145 fromStringTest{"0", 16, 0, true}, |
146 fromStringTest{"10", 0, 10, true}, | 146 fromStringTest{"10", 0, 10, true}, |
147 fromStringTest{"10", 10, 10, true}, | 147 fromStringTest{"10", 10, 10, true}, |
148 fromStringTest{"10", 16, 16, true}, | 148 fromStringTest{"10", 16, 16, true}, |
149 fromStringTest{"-10", 16, -16, true}, | 149 fromStringTest{"-10", 16, -16, true}, |
150 fromStringTest{in: "0x", ok: false}, | 150 fromStringTest{in: "0x", ok: false}, |
151 fromStringTest{"0x10", 0, 16, true}, | 151 fromStringTest{"0x10", 0, 16, true}, |
152 fromStringTest{in: "0x10", base: 16, ok: false}, | 152 fromStringTest{in: "0x10", base: 16, ok: false}, |
153 fromStringTest{"-0x10", 0, -16, true}, | 153 fromStringTest{"-0x10", 0, -16, true}, |
| 154 fromStringTest{"00", 0, 0, true}, |
| 155 fromStringTest{"0", 8, 0, true}, |
| 156 fromStringTest{"07", 0, 7, true}, |
| 157 fromStringTest{"7", 8, 7, true}, |
| 158 fromStringTest{in: "08", ok: false}, |
| 159 fromStringTest{in: "8", base: 8, ok: false}, |
| 160 fromStringTest{"023", 0, 19, true}, |
| 161 fromStringTest{"23", 8, 19, true}, |
154 } | 162 } |
155 | 163 |
156 | 164 |
157 func TestSetString(t *testing.T) { | 165 func TestSetString(t *testing.T) { |
158 n2 := new(Int) | 166 n2 := new(Int) |
159 for i, test := range fromStringTests { | 167 for i, test := range fromStringTests { |
160 n1, ok1 := new(Int).SetString(test.in, test.base) | 168 n1, ok1 := new(Int).SetString(test.in, test.base) |
161 n2, ok2 := n2.SetString(test.in, test.base) | 169 n2, ok2 := n2.SetString(test.in, test.base) |
162 expected := new(Int).New(test.out) | 170 expected := new(Int).New(test.out) |
163 if ok1 != test.ok || ok2 != test.ok { | 171 if ok1 != test.ok || ok2 != test.ok { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 func TestInt64(t *testing.T) { | 679 func TestInt64(t *testing.T) { |
672 for i, testVal := range int64Tests { | 680 for i, testVal := range int64Tests { |
673 in := NewInt(testVal) | 681 in := NewInt(testVal) |
674 out := in.Int64() | 682 out := in.Int64() |
675 | 683 |
676 if out != testVal { | 684 if out != testVal { |
677 t.Errorf("#%d got %d want %d", i, out, testVal) | 685 t.Errorf("#%d got %d want %d", i, out, testVal) |
678 } | 686 } |
679 } | 687 } |
680 } | 688 } |
LEFT | RIGHT |