-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_test.go
More file actions
38 lines (32 loc) · 1.6 KB
/
math_test.go
File metadata and controls
38 lines (32 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"testing"
)
/* # Python test reference code
res = []
for x in range(-10,11):
for y in range(-10,11):
if y == 0: continue
res.append(x%y)
','.join(['{}'.format(x) for x in res])*/
func TestPmod(t *testing.T) {
rightAnswers := []int{0,-1,-2,-3,-4,0,-2,-1,0,0,0,0,2,2,0,2,4,6,8,0,-9,0,-1,-2,-3,-4,-1,0,-1,0,0,1,0,3,1,3,5,7,0,1,-8,-8,0,-1,-2,-3,0,-2,0,0,0,0,1,0,2,4,6,0,1,2,-7,-7,-7,0,-1,-2,-3,-1,-1,0,0,1,2,1,3,5,0,1,2,3,-6,-6,-6,-6,0,-1,-2,0,0,0,0,0,0,2,4,0,1,2,3,4,-5,-5,-5,-5,-5,0,-1,-2,-1,0,0,1,1,3,0,1,2,3,4,5,-4,-4,-4,-4,-4,-4,0,-1,0,0,0,0,2,0,1,2,3,4,5,6,-3,-3,-3,-3,-3,-3,-3,0,-1,0,0,1,0,1,2,3,4,5,6,7,-2,-2,-2,-2,-2,-2,-2,-2,0,0,0,0,1,2,3,4,5,6,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,0,1,1,1,1,1,1,1,1,1,-8,-7,-6,-5,-4,-3,-2,-1,0,0,0,0,2,2,2,2,2,2,2,2,-7,-6,-5,-4,-3,-2,-1,0,-1,0,0,1,0,3,3,3,3,3,3,3,-6,-5,-4,-3,-2,-1,0,-2,0,0,0,0,1,0,4,4,4,4,4,4,-5,-4,-3,-2,-1,0,-3,-1,-1,0,0,1,2,1,0,5,5,5,5,5,-4,-3,-2,-1,0,-4,-2,0,0,0,0,0,0,2,1,0,6,6,6,6,-3,-2,-1,0,-5,-3,-1,-2,-1,0,0,1,1,3,2,1,0,7,7,7,-2,-1,0,-6,-4,-2,0,-1,0,0,0,0,2,0,3,2,1,0,8,8,-1,0,-7,-5,-3,-1,-3,0,-1,0,0,1,0,1,4,3,2,1,0,9,0,-8,-6,-4,-2,0,-2,-2,0,0,0,0,1,2,0,4,3,2,1,0}
var x, y int
var res []int
for x = -10; x <= 10; x ++ {
for y = -10; y <= 10; y++ {
if y == 0 {
continue
}
res = append(res, pmod(x, y))
}
}
if len(rightAnswers) != len(res) {
t.Error("Length error:", len(rightAnswers), len(res))
}
for i := range res {
if rightAnswers[i] != res[i] {
t.Error("Mismatch:", i, rightAnswers[i], res[i])
}
}
}