Update Version to not use string anymore
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
This commit is contained in:
parent
345365e7b0
commit
d5795681d4
2 changed files with 8 additions and 8 deletions
|
@ -7,10 +7,10 @@ import (
|
|||
|
||||
type Version string
|
||||
|
||||
func (me Version) compareTo(other string) int {
|
||||
func (me Version) compareTo(other Version) int {
|
||||
var (
|
||||
meTab = strings.Split(string(me), ".")
|
||||
otherTab = strings.Split(other, ".")
|
||||
otherTab = strings.Split(string(other), ".")
|
||||
)
|
||||
for i, s := range meTab {
|
||||
var meInt, otherInt int
|
||||
|
@ -31,22 +31,22 @@ func (me Version) compareTo(other string) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (me Version) LessThan(other string) bool {
|
||||
func (me Version) LessThan(other Version) bool {
|
||||
return me.compareTo(other) == -1
|
||||
}
|
||||
|
||||
func (me Version) LessThanOrEqualTo(other string) bool {
|
||||
func (me Version) LessThanOrEqualTo(other Version) bool {
|
||||
return me.compareTo(other) <= 0
|
||||
}
|
||||
|
||||
func (me Version) GreaterThan(other string) bool {
|
||||
func (me Version) GreaterThan(other Version) bool {
|
||||
return me.compareTo(other) == 1
|
||||
}
|
||||
|
||||
func (me Version) GreaterThanOrEqualTo(other string) bool {
|
||||
func (me Version) GreaterThanOrEqualTo(other Version) bool {
|
||||
return me.compareTo(other) >= 0
|
||||
}
|
||||
|
||||
func (me Version) Equal(other string) bool {
|
||||
func (me Version) Equal(other Version) bool {
|
||||
return me.compareTo(other) == 0
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func assertVersion(t *testing.T, a, b string, result int) {
|
||||
if r := Version(a).compareTo(b); r != result {
|
||||
if r := Version(a).compareTo(Version(b)); r != result {
|
||||
t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue