-
Notifications
You must be signed in to change notification settings - Fork 7
/
delta_test.go
53 lines (43 loc) · 850 Bytes
/
delta_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
package topojson
import (
"testing"
"github.com/cheekybits/is"
)
// Converts arcs to delta encoding
func TestDeltaConverts(t *testing.T) {
is := is.New(t)
topo := &Topology{
Arcs: [][][]float64{
{
{0, 0}, {9999, 0}, {0, 9999}, {0, 0},
},
},
opts: &TopologyOptions{PostQuantize: 1e4},
}
expected := [][][]float64{
{
{0, 0}, {9999, 0}, {-9999, 9999}, {0, -9999},
},
}
topo.delta()
is.Equal(topo.Arcs, expected)
}
// Does not skip coincident points
func TestDeltaDoesntSkip(t *testing.T) {
is := is.New(t)
topo := &Topology{
Arcs: [][][]float64{
{
{0, 0}, {9999, 0}, {9999, 0}, {0, 9999}, {0, 0},
},
},
opts: &TopologyOptions{PostQuantize: 1e4},
}
expected := [][][]float64{
{
{0, 0}, {9999, 0}, {0, 0}, {-9999, 9999}, {0, -9999},
},
}
topo.delta()
is.Equal(topo.Arcs, expected)
}