1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-27 20:45:28 -05:00

remove dep of assert lib

This commit is contained in:
Darien Raymond
2019-02-09 15:46:48 +01:00
parent 481b3fd294
commit 932e09a388
7 changed files with 133 additions and 143 deletions

View File

@@ -8,12 +8,9 @@ import (
"v2ray.com/core/common"
. "v2ray.com/core/common/platform"
. "v2ray.com/ext/assert"
)
func TestNormalizeEnvName(t *testing.T) {
assert := With(t)
cases := []struct {
input string
output string
@@ -32,44 +29,37 @@ func TestNormalizeEnvName(t *testing.T) {
},
}
for _, test := range cases {
assert(NormalizeEnvName(test.input), Equals, test.output)
if v := NormalizeEnvName(test.input); v != test.output {
t.Error("unexpected output: ", v, " want ", test.output)
}
}
}
func TestEnvFlag(t *testing.T) {
assert := With(t)
assert(EnvFlag{
if v := EnvFlag{
Name: "xxxxx.y",
}.GetValueAsInt(10), Equals, 10)
}.GetValueAsInt(10); v != 10 {
t.Error("env value: ", v)
}
}
func TestGetAssetLocation(t *testing.T) {
assert := With(t)
exec, err := os.Executable()
common.Must(err)
loc := GetAssetLocation("t")
assert(filepath.Dir(loc), Equals, filepath.Dir(exec))
if filepath.Dir(loc) != filepath.Dir(exec) {
t.Error("asset dir: ", loc, " not in ", exec)
}
os.Setenv("v2ray.location.asset", "/v2ray")
if runtime.GOOS == "windows" {
assert(GetAssetLocation("t"), Equals, "\\v2ray\\t")
if v := GetAssetLocation("t"); v != "\\v2ray\\t" {
t.Error("asset loc: ", v)
}
} else {
assert(GetAssetLocation("t"), Equals, "/v2ray/t")
if v := GetAssetLocation("t"); v != "/v2ray/t" {
t.Error("asset loc: ", v)
}
}
}
func TestGetPluginLocation(t *testing.T) {
assert := With(t)
exec, err := os.Executable()
common.Must(err)
loc := GetPluginDirectory()
assert(loc, Equals, filepath.Join(filepath.Dir(exec), "plugins"))
os.Setenv("V2RAY_LOCATION_PLUGIN", "/v2ray")
assert(GetPluginDirectory(), Equals, "/v2ray")
}