-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorient_test.go
More file actions
33 lines (29 loc) · 1.18 KB
/
Copy pathorient_test.go
File metadata and controls
33 lines (29 loc) · 1.18 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
package robust
import (
"testing"
"github.com/franela/goblin"
)
func TestRobustOrient(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("Orientation", func() {
g.It("test robust orient 2D", func() {
g.Assert(Orientation2D(af(0.1, 0.1), af(0.1, 0.1), af(0.3, 0.7)) == 0).IsTrue()
g.Assert(Orientation2D(af(0, 0), af(-1e-64, 0), af(0, 1)) > 0).IsTrue()
g.Assert(Orientation2D(af(0, 0), af(1e-64, 1e-64), af(1, 1)) == 0).IsTrue()
g.Assert(Orientation2D(af(0, 0), af(1e-64, 0), af(0, 1)) < 0).IsTrue()
x := 1e-64
for i := 0; i < 200; i++ {
g.Assert(Orientation2D(af(-x, 0), af(0, 1), af(x, 0)) > 0).IsTrue()
g.Assert(Orientation2D(af(-x, 0), af(0, 0), af(x, 0)) == 0).IsTrue()
g.Assert(Orientation2D(af(-x, 0), af(0, -1), af(x, 0)) < 0).IsTrue()
g.Assert(Orientation2D(af(0, 1), af(0, 0), af(x, x)) < 0).IsTrue()
x *= 10
}
})
g.It("test robust orient 3D", func() {
g.Assert(Orientation3D(af(0, 0, 0), af(1, 0, 0), af(0, 1, 0), af(0, 0, 1)) < 0).IsTrue()
g.Assert(Orientation3D(af(0, 0, 0), af(1, 0, 0), af(0, 0, 1), af(0, 1, 0)) > 0).IsTrue()
g.Assert(Orientation3D(af(0, 0, 0), af(1e-64, 0, 0), af(0, 0, 1), af(0, 1e64, 0)) > 0).IsTrue()
})
})
}