Add test case for "70000000000000000" and fix

This commit is contained in:
Brian Buller 2016-11-14 07:56:52 -06:00
parent 1415b3ea84
commit 1abb8f7e73
2 changed files with 2 additions and 1 deletions

View File

@ -45,7 +45,7 @@ func convertNumStringBase(in string, base int64) (int64, error) {
} }
n += a n += a
if n < 0 { if n <= 0 && in[0] != '0' {
return 0, errors.New("range") return 0, errors.New("range")
} }
} }

View File

@ -30,6 +30,7 @@ var testCases = []struct {
{"2cg134", 0, "syntax"}, {"2cg134", 0, "syntax"},
{"8000000000000000", 0, "range"}, {"8000000000000000", 0, "range"},
{"9223372036854775809", 0, "range"}, {"9223372036854775809", 0, "range"},
{"70000000000000000", 0, "range"},
} }
func TestParseHex(t *testing.T) { func TestParseHex(t *testing.T) {