]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: fix TestBytes test
authorRobert Griesemer <gri@golang.org>
Fri, 21 Aug 2015 18:30:19 +0000 (11:30 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 21 Aug 2015 20:02:40 +0000 (20:02 +0000)
Fixes #12231.

Change-Id: I1f07c444623cd864667e21b2fee534eacdc193bb
Reviewed-on: https://go-review.googlesource.com/13814
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/math/big/int_test.go

index 88c8c2bb64167e749ef98422dd38f760010a30ba..97874626f336fddee773f0369673faeb2aaba89c 100644 (file)
@@ -387,6 +387,11 @@ func TestSetBytes(t *testing.T) {
 }
 
 func checkBytes(b []byte) bool {
+       // trim leading zero bytes since Bytes() won't return them
+       // (was issue 12231)
+       for len(b) > 0 && b[0] == 0 {
+               b = b[1:]
+       }
        b2 := new(Int).SetBytes(b).Bytes()
        return bytes.Equal(b, b2)
 }