-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlttb_test.go
36 lines (32 loc) · 841 Bytes
/
lttb_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
package lttb
import (
"reflect"
"testing"
)
// TestPointSelectionWithZeroArea is a regression test for the
// correct selection of a "b" point in a bucket where all computed
// areas have a value of zero.
func TestPointSelectionWithZeroArea(t *testing.T) {
data := []Point[float64]{
{0, 0}, // sentinel value
{1299456, 116.3707},
{1300320, 116.3752}, // a
{1301184, 116.3648}, // b --> Should be selected even when triangle area is zero.
{1302048, 116.3544}, // c
{1302912, 116.3328},
{1306368, 116.3277},
{1307232, 116.2676},
}
want := []Point[float64]{
{0, 0},
{1299456, 116.3707},
{1300320, 116.3752},
{1301184, 116.3648},
{1302048, 116.3544},
{1306368, 116.3277},
{1307232, 116.2676},
}
if have := LTTB(data, 7); !reflect.DeepEqual(have, want) {
t.Errorf("\nhave %v\nwant %v", have, want)
}
}