}{
// 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"},
}
}
+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",
}
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)