-
Notifications
You must be signed in to change notification settings - Fork 0
/
binner_test.go
48 lines (46 loc) · 1.23 KB
/
binner_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
package main
import (
"github.com/acj/krapslog/internal/test"
"reflect"
"testing"
)
func Test_BinTimestampsToFitLineWidth(t *testing.T) {
type args struct {
timestampsFromLines []int64
terminalWidth int
}
tests := []struct {
name string
args args
want []float64
}{
{
name: "zero timestamps", args: args{
timestampsFromLines: []int64{},
terminalWidth: 5,
},
want: test.RepeatFloat(0, 5),
},
{
name: "one timestamp", args: args{
timestampsFromLines: []int64{0},
terminalWidth: 5,
},
want: []float64{1, 0, 0, 0, 0},
},
{
name: "10 timestamps", args: args{
timestampsFromLines: []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
terminalWidth: 80,
},
want: []float64{1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := binTimestamps(tt.args.timestampsFromLines, tt.args.terminalWidth); !reflect.DeepEqual(got, tt.want) {
t.Errorf("binTimestamps() = %v, want %v", got, tt.want)
}
})
}
}