1
0
mirror of https://github.com/golang/go synced 2024-11-12 04:40:22 -07:00

big: fix nat.scan bug

Scanning "0" with detected base did not actually set the nat to 0.

R=gri
CC=golang-dev
https://golang.org/cl/4923050
This commit is contained in:
Evan Shaw 2011-08-24 14:55:03 -07:00 committed by Robert Griesemer
parent 42687d6ce4
commit de20cec9c9
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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
}