diff options
author | Evan Shaw <chickencha@gmail.com> | 2011-08-24 14:55:03 -0700 |
---|---|---|
committer | Evan Shaw <chickencha@gmail.com> | 2011-08-24 14:55:03 -0700 |
commit | 126ba87dd0c5c1b398349bf2686c2992df37ef19 (patch) | |
tree | f79815d18e8d5d29ed73861dcd51c7ed78e6273a /src/pkg/big | |
parent | 054cb2b8651897e88d466ebf4e200b06ee7b85fe (diff) | |
download | go-126ba87dd0c5c1b398349bf2686c2992df37ef19.tar.gz |
big: fix nat.scan bug
Scanning "0" with detected base did not actually set the nat to 0.
R=gri
CC=golang-dev
http://codereview.appspot.com/4923050
Committer: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/pkg/big')
-rwxr-xr-x | src/pkg/big/int_test.go | 3 | ||||
-rwxr-xr-x | src/pkg/big/nat.go | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/big/int_test.go b/src/pkg/big/int_test.go index 03446d6ae..b2e169217 100755 --- a/src/pkg/big/int_test.go +++ b/src/pkg/big/int_test.go @@ -301,6 +301,9 @@ func TestGetString(t *testing.T) { func TestSetString(t *testing.T) { tmp := new(Int) for i, test := range stringTests { + // initialize to a non-zero value so that issues with parsing + // 0 are detected + tmp.SetInt64(1234567890) n1, ok1 := new(Int).SetString(test.in, test.base) n2, ok2 := tmp.SetString(test.in, test.base) expected := NewInt(test.val) diff --git a/src/pkg/big/nat.go b/src/pkg/big/nat.go index be3aff29d..33d6bb16f 100755 --- a/src/pkg/big/nat.go +++ b/src/pkg/big/nat.go @@ -646,7 +646,7 @@ func (z nat) scan(r io.RuneScanner, base int) (nat, int, os.Error) { } } case os.EOF: - return z, 10, nil + return z.make(0), 10, nil default: return z, 10, err } |