diff --git a/src/math/big/intconv_test.go b/src/math/big/intconv_test.go index 5ba29263a6..cf337db63a 100644 --- a/src/math/big/intconv_test.go +++ b/src/math/big/intconv_test.go @@ -7,6 +7,7 @@ package big import ( "bytes" "fmt" + "math/rand/v2" "testing" ) @@ -389,12 +390,14 @@ func TestFormat(t *testing.T) { } } -var scanTests = []struct { +type scanTest struct { input string format string output string remaining int -}{ +} + +var scanTests = []scanTest{ {"1010", "%b", "10", 0}, {"0b1010", "%v", "10", 0}, {"12", "%o", "10", 0}, @@ -410,6 +413,25 @@ var scanTests = []struct { {"0 ", "%v", "0", 1}, {"2+3", "%v", "2", 2}, {"0XABC 12", "%v", "2748", 3}, + + {"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000022222223333333333444444444", "%x", "72999049881955123498258745691204661198291656115976958889267080286388402675338838184094604981077942396458276955120179409196748346461468914795561487752253275293347599221664790586512596660792869956", 0}, + {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff33377fffffffffffffffffffffffffffffffffffffffffffff0000000000022222eee1", "%x", "1167984798111281975972139931059274579172666497855631342228273284582214442805421410945513679697247078343332431249286160621687557589604464869034163736183926240549918956767671325412748661204059352801", 0}, + {"5c0d52f451aec609b15da8e5e5626c4eaa88723bdeac9d25ca9b961269400410ca208a16af9c2fb07d7a11c7772cba02c22f9711078d51a3797eb18e691295293284d988e349fa6deba46b25a4ecd9f715", "%x", "419981998319789881681348172155240145539175961318447822049735313481433836043208347786919222066492311384432264836938599791362288343314139526391998172436831830624710446410781662672086936222288181013", 0}, + {"92fcad4b5c0d52f451aec609b15da8e5e5626c4eaa88723bdeac9d25ca9b961269400410ca208a16af9c2fb07d799c32fe2f3cc5422f9711078d51a3797eb18e691295293284d8f5e69caf6decddfe1df6", "%x", "670619546945481998414061201992255225716434798957375727890607516800039934374391281275121813279544891602026798031004764406015624866771554937391445093144221697436880587924204655403711377861305572854", 0}, + {"10000000000000000000000200000000000000000000003000000000000000000000040000000000000000000000500000000000000000000006", "%d", "10000000000000000000000200000000000000000000003000000000000000000000040000000000000000000000500000000000000000000006", 0}, +} + +func init() { + for i := range 200 { + d := make([]byte, i+1) + for j := range d { + d[j] = '0' + rand.N(byte(10)) + } + if d[0] == '0' { + d[0] = '1' + } + scanTests = append(scanTests, scanTest{input: string(d), format: "%d", output: string(d)}) + } } func TestScan(t *testing.T) { diff --git a/src/math/big/natconv_test.go b/src/math/big/natconv_test.go index 66300e412b..670dc5fdb7 100644 --- a/src/math/big/natconv_test.go +++ b/src/math/big/natconv_test.go @@ -353,7 +353,7 @@ func BenchmarkScan(b *testing.B) { stk := getStack() defer stk.free() - const x = 10 + const x = 9 // avoid tested bases, in case runs of 0s are handled specially for _, base := range []int{2, 8, 10, 16} { for _, y := range []Word{10, 100, 1000, 10000, 100000} { if isRaceBuilder && y > 1000 {