-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathutil_test.go
42 lines (40 loc) · 1.07 KB
/
util_test.go
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
39
40
41
42
package main
import (
"testing"
)
func TestGetMapblockPosFromNode(t *testing.T) {
type args struct {
x int
y int
z int
}
tests := []struct {
name string
args args
wantx int
wanty int
wantz int
}{
{"coords for node 0,0,0", args{0, 0, 0}, 0, 0, 0},
{"coords for node 15,15,15", args{15, 15, 15}, 0, 0, 0},
{"coords for node 16,16,16", args{16, 16, 16}, 1, 1, 1},
{"coords for node 31,16,16", args{31, 16, 16}, 1, 1, 1},
{"coords for node -15,-15,-15", args{-15, -15, -15}, -1, -1, -1},
{"coords for node -1565,4,-386", args{-1565, 4, -386}, -98, 0, -25},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
x, y, z := GetMapblockPosFromNode(tt.args.x, tt.args.y, tt.args.z)
t.Logf("GetMapblockPosFromNode %v: %v, %v, %v", tt.args, x, y, z)
if x != tt.wantx {
t.Errorf("GetMapblockPosFromNode() x = %v, want %v", x, tt.wantx)
}
if y != tt.wanty {
t.Errorf("GetMapblockPosFromNode() y = %v, want %v", y, tt.wanty)
}
if z != tt.wantz {
t.Errorf("GetMapblockPosFromNode() z = %v, want %v", z, tt.wantz)
}
})
}
}