This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcore_test.go
62 lines (57 loc) · 1.74 KB
/
core_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright © 2013-2016 Galvanized Logic Inc.
// Use is governed by a BSD-style license found in the LICENSE file.
package main
import (
"testing"
)
func TestToGrid(t *testing.T) {
units := 2.0
gridx, gridy := toGrid(-0.9, 0, -0.9, units)
if gridx != 0 || gridy != 0 {
t.Errorf("Expected 0,0 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(0.9, 0, 0.9, units)
if gridx != 0 || gridy != 0 {
t.Errorf("Expected 0,0 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(-0.9, 0, 0.9, units)
if gridx != 0 || gridy != 0 {
t.Errorf("Expected 0,0 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(0.9, 0, -0.9, units)
if gridx != 0 || gridy != 0 {
t.Errorf("Expected 0,0 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(1.01, 0, -1.01, units)
if gridx != 1 || gridy != 1 {
t.Errorf("Expected 1,1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(2.99, 0, -2.99, units)
if gridx != 1 || gridy != 1 {
t.Errorf("Expected 1,1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(1.01, 0, -2.99, units)
if gridx != 1 || gridy != 1 {
t.Errorf("Expected 1,1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(2.99, 0, -1.01, units)
if gridx != 1 || gridy != 1 {
t.Errorf("Expected 1,1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(-1.01, 0, 1.01, units)
if gridx != -1 || gridy != -1 {
t.Errorf("Expected -1,-1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(-2.99, 0, 2.99, units)
if gridx != -1 || gridy != -1 {
t.Errorf("Expected -1,-1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(-1.01, 0, 2.99, units)
if gridx != -1 || gridy != -1 {
t.Errorf("Expected -1,-1 got %d,%d", gridx, gridy)
}
gridx, gridy = toGrid(-2.99, 0, 1.01, units)
if gridx != -1 || gridy != -1 {
t.Errorf("Expected -1,-1 got %d,%d", gridx, gridy)
}
}