generated from openacid/gotmpl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathballot_test.go
35 lines (26 loc) · 1 KB
/
ballot_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
package traft
// func TestNewBallot(t *testing.T) {
// ta := require.New(t)
// got := NewBallot(1, 2, 3, 4, 5)
// ta.Equal(int64(1), got.Current.Term)
// ta.Equal(int64(2), got.Current.Id)
// ta.Equal(int64(5), got.MaxLogSeq)
// ta.Equal(int64(3), got.Committer.Term)
// ta.Equal(int64(4), got.Committer.Id)
// }
// func TestBallog_CmpLog(t *testing.T) {
// ta := require.New(t)
// cases := []struct {
// a, b *Ballot
// want int
// }{
// {a: NewBallot(0, 0, 1, 1, 1), b: NewBallot(0, 0, 1, 1, 1), want: 0},
// {a: NewBallot(0, 0, 1, 1, 2), b: NewBallot(0, 0, 1, 1, 1), want: 1},
// {a: NewBallot(0, 0, 1, 2, 0), b: NewBallot(0, 0, 1, 1, 1), want: 1},
// {a: NewBallot(0, 0, 2, 0, 0), b: NewBallot(0, 0, 1, 1, 1), want: 1},
// }
// for i, c := range cases {
// ta.Equal(c.want, c.a.CmpLog(c.b), "%d-th: case: %+v", i+1, c)
// ta.Equal(-c.want, c.b.CmpLog(c.a), "%d-th: case: %+v", i+1, c)
// }
// }