]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgo/go/math/big/int_test.go
libgo: update to Go1.14beta1
[thirdparty/gcc.git] / libgo / go / math / big / int_test.go
index ade973b20743543b0ef1a4d60db23d84ff294542..e3a1587b3f0ad7acb0cb56091c9fa69902c89eb8 100644 (file)
@@ -757,11 +757,13 @@ var gcdTests = []struct {
 }{
        // a <= 0 || b <= 0
        {"0", "0", "0", "0", "0"},
-       {"0", "0", "0", "0", "7"},
-       {"0", "0", "0", "11", "0"},
-       {"0", "0", "0", "-77", "35"},
-       {"0", "0", "0", "64515", "-24310"},
-       {"0", "0", "0", "-64515", "-24310"},
+       {"7", "0", "1", "0", "7"},
+       {"7", "0", "-1", "0", "-7"},
+       {"11", "1", "0", "11", "0"},
+       {"7", "-1", "-2", "-77", "35"},
+       {"935", "-3", "8", "64515", "24310"},
+       {"935", "-3", "-8", "64515", "-24310"},
+       {"935", "3", "-8", "-64515", "-24310"},
 
        {"1", "-9", "47", "120", "23"},
        {"7", "1", "-2", "77", "35"},
@@ -1071,6 +1073,20 @@ func TestCmpAbs(t *testing.T) {
        }
 }
 
+func TestIntCmpSelf(t *testing.T) {
+       for _, s := range cmpAbsTests {
+               x, ok := new(Int).SetString(s, 0)
+               if !ok {
+                       t.Fatalf("SetString(%s, 0) failed", s)
+               }
+               got := x.Cmp(x)
+               want := 0
+               if got != want {
+                       t.Errorf("x = %s: x.Cmp(x): got %d; want %d", x, got, want)
+               }
+       }
+}
+
 var int64Tests = []string{
        // int64
        "0",
@@ -1813,8 +1829,11 @@ func benchmarkDiv(b *testing.B, aSize, bSize int) {
 }
 
 func BenchmarkDiv(b *testing.B) {
-       min, max, step := 10, 100000, 10
-       for i := min; i <= max; i *= step {
+       sizes := []int{
+               10, 20, 50, 100, 200, 500, 1000,
+               1e4, 1e5, 1e6, 1e7,
+       }
+       for _, i := range sizes {
                j := 2 * i
                b.Run(fmt.Sprintf("%d/%d", j, i), func(b *testing.B) {
                        benchmarkDiv(b, j, i)