-
Notifications
You must be signed in to change notification settings - Fork 1
/
counter_test.go
37 lines (35 loc) · 1.18 KB
/
counter_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
package chotki
import (
"github.com/drpcorg/chotki/protocol"
"github.com/drpcorg/chotki/rdx"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCounterMerge(t *testing.T) {
args := [][]byte{
protocol.Concat(
protocol.Record('I', rdx.IDFromString("b-345").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(2)),
protocol.Record('I', rdx.IDFromString("a-123").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(1)),
),
protocol.Concat(
protocol.Record('I', rdx.IDFromString("c-567").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(3)),
protocol.Record('I', rdx.IDFromString("b-344").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(1)),
protocol.Record('I', rdx.IDFromString("a-234").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(2)),
),
}
result := CMerge(args)
correct := protocol.Concat(
protocol.Record('I', rdx.IDFromString("c-567").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(3)),
protocol.Record('I', rdx.IDFromString("b-345").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(2)),
protocol.Record('I', rdx.IDFromString("a-234").ZipBytes()),
protocol.Record('C', rdx.ZipZagInt64(2)),
)
assert.Equal(t, correct, result)
}