Commit de20cec9 authored by Evan Shaw's avatar Evan Shaw Committed by Robert Griesemer

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
parent 42687d6c
......@@ -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)
......
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment