-
Notifications
You must be signed in to change notification settings - Fork 0
/
timed_value_test.go
39 lines (37 loc) · 965 Bytes
/
timed_value_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
package crdt
import "testing"
func TestTimedValueCompare(t *testing.T) {
tests := []struct {
name string
timedValue1 TimedValue
timedValue2 TimedValue
wantCompare int
}{
{
name: "TimedValue.timestamp == TimedValue.timestamp",
timedValue1: NewTimedValue("foo", 10),
timedValue2: NewTimedValue("bar", 10),
wantCompare: 0,
},
{
name: "TimedValue.timestamp > TimedValue.timestamp",
timedValue1: NewTimedValue("foo", 15),
timedValue2: NewTimedValue("bar", 10),
wantCompare: 1,
},
{
name: "TimedValue.timestamp < TimedValue.timestamp",
timedValue1: NewTimedValue("foo", 10),
timedValue2: NewTimedValue("bar", 15),
wantCompare: -1,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
gotCompare := test.timedValue1.Compare(test.timedValue2)
if gotCompare != test.wantCompare {
t.Errorf("got %d, want %d", gotCompare, test.wantCompare)
}
})
}
}