forked from apache/cassandra-gocql-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host_source_test.go
44 lines (37 loc) · 1.01 KB
/
host_source_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
package gocql
import "testing"
func TestUnmarshalCassVersion(t *testing.T) {
tests := [...]struct {
data string
version cassVersion
}{
{"3.2", cassVersion{3, 2, 0}},
{"2.10.1-SNAPSHOT", cassVersion{2, 10, 1}},
{"1.2.3", cassVersion{1, 2, 3}},
}
for i, test := range tests {
v := &cassVersion{}
if err := v.UnmarshalCQL(nil, []byte(test.data)); err != nil {
t.Errorf("%d: %v", i, err)
} else if *v != test.version {
t.Errorf("%d: expected %#+v got %#+v", i, test.version, *v)
}
}
}
func TestCassVersionBefore(t *testing.T) {
tests := [...]struct {
version cassVersion
major, minor, patch int
}{
{cassVersion{1, 0, 0}, 0, 0, 0},
{cassVersion{0, 1, 0}, 0, 0, 0},
{cassVersion{0, 0, 1}, 0, 0, 0},
{cassVersion{1, 0, 0}, 0, 1, 0},
{cassVersion{0, 1, 0}, 0, 0, 1},
}
for i, test := range tests {
if !test.version.Before(test.major, test.minor, test.patch) {
t.Errorf("%d: expected v%d.%d.%d to be before %v", i, test.major, test.minor, test.patch, test.version)
}
}
}