forked from chsc/gogl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs_test.go
42 lines (37 loc) · 956 Bytes
/
structs_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
// Copyright 2011 The GoGL Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE.mkd file.
package main
import (
"testing"
)
type versionTest struct {
In string
Out Version
Err bool
}
var versionTests = []versionTest{
{"0.0", Version{0, 0}, false},
{"0.1", Version{0, 1}, false},
{"1.0", Version{1, 0}, false},
{"5.6", Version{5, 6}, false},
{"0.", Version{0, 0}, true},
{"", Version{0, 0}, true},
{".", Version{0, 0}, true},
{"a", Version{0, 0}, true},
}
func TestVersion(t *testing.T) {
for i := range versionTests {
test := &versionTests[i]
v, err := MakeVersionFromString(test.In)
if err != nil != test.Err {
t.Errorf("Converison failed %v, %v", test, err)
}
if v.Valid() != test.Out.Valid() {
t.Errorf("Input and output must be valid or invalid: %v", test)
}
if v.Compare(test.Out) != 0 {
t.Errorf("Input != output %v", test)
}
}
}