forked from vechain/thor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequence_test.go
41 lines (38 loc) · 990 Bytes
/
sequence_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
package logdb
import (
"math"
"testing"
)
func TestSequence(t *testing.T) {
type args struct {
blockNum uint32
index uint32
}
tests := []struct {
name string
args args
want args
}{
{"regular", args{1, 2}, args{1, 2}},
{"max bn", args{math.MaxUint32, 1}, args{math.MaxUint32, 1}},
{"max index", args{5, math.MaxInt32}, args{5, math.MaxInt32}},
{"both max", args{math.MaxUint32, math.MaxInt32}, args{math.MaxUint32, math.MaxInt32}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := newSequence(tt.args.blockNum, tt.args.index)
if bn := got.BlockNumber(); bn != tt.want.blockNum {
t.Errorf("seq.blockNum() = %v, want %v", bn, tt.want.blockNum)
}
if i := got.Index(); i != tt.want.index {
t.Errorf("seq.index() = %v, want %v", i, tt.want.index)
}
})
}
defer func() {
if e := recover(); e == nil {
t.Errorf("newSequence should panic on 2nd arg > math.MaxInt32")
}
}()
newSequence(1, math.MaxInt32+1)
}