forked from utahta/pythonbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion_test.go
More file actions
37 lines (31 loc) · 754 Bytes
/
version_test.go
File metadata and controls
37 lines (31 loc) · 754 Bytes
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 origin
import "testing"
func TestParseVersion(t *testing.T) {
testcases := []struct {
version string
expected string
major int
minor int
}{
{"1.2", "1.2", 1, 2},
{"1.2-dev", "1.2-dev", 1, 2},
{"1.2.3", "1.2.3", 1, 2},
{"1.2.3-dev", "1.2.3-dev", 1, 2},
{"1.2.3rc1", "1.2.3rc1", 1, 2},
}
for _, testcase := range testcases {
v, err := ParseVersion(testcase.version)
if err != nil {
t.Error(err)
}
if v.String() != testcase.expected {
t.Errorf("Expected %s, got %v", testcase.expected, v)
}
if v.Major() != testcase.major {
t.Errorf("Expected %v, got %v", testcase.major, v.Major())
}
if v.Minor() != testcase.minor {
t.Errorf("Expected %v, got %v", testcase.minor, v.Minor())
}
}
}