github.com/astaxie/beego@v1.12.3/utils/utils_test.go (about)

     1  package utils
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestCompareGoVersion(t *testing.T) {
     8  	targetVersion := "go1.8"
     9  	if compareGoVersion("go1.12.4", targetVersion) != 1 {
    10  		t.Error("should be 1")
    11  	}
    12  
    13  	if compareGoVersion("go1.8.7", targetVersion) != 1 {
    14  		t.Error("should be 1")
    15  	}
    16  
    17  	if compareGoVersion("go1.8", targetVersion) != 0 {
    18  		t.Error("should be 0")
    19  	}
    20  
    21  	if compareGoVersion("go1.7.6", targetVersion) != -1 {
    22  		t.Error("should be -1")
    23  	}
    24  
    25  	if compareGoVersion("go1.12.1rc1", targetVersion) != 1 {
    26  		t.Error("should be 1")
    27  	}
    28  
    29  	if compareGoVersion("go1.8rc1", targetVersion) != 0 {
    30  		t.Error("should be 0")
    31  	}
    32  
    33  	if compareGoVersion("go1.7rc1", targetVersion) != -1 {
    34  		t.Error("should be -1")
    35  	}
    36  }