v2ray-core/common/platform/platform_test.go

42 lines
587 B
Go
Raw Normal View History

2017-05-25 23:11:38 +00:00
package platform_test
import (
"testing"
. "v2ray.com/core/common/platform"
2017-10-24 14:15:35 +00:00
. "v2ray.com/ext/assert"
2017-05-25 23:11:38 +00:00
)
func TestNormalizeEnvName(t *testing.T) {
2017-10-24 14:15:35 +00:00
assert := With(t)
2017-05-25 23:11:38 +00:00
cases := []struct {
input string
output string
}{
{
input: "a",
output: "A",
},
{
input: "a.a",
output: "A_A",
},
{
input: "A.A.B",
output: "A_A_B",
},
}
for _, test := range cases {
2017-10-24 14:15:35 +00:00
assert(NormalizeEnvName(test.input), Equals, test.output)
2017-05-25 23:11:38 +00:00
}
}
func TestEnvFlag(t *testing.T) {
2017-10-24 14:15:35 +00:00
assert := With(t)
2017-05-25 23:11:38 +00:00
2017-10-24 14:15:35 +00:00
assert(EnvFlag{
2017-05-25 23:11:38 +00:00
Name: "xxxxx.y",
2017-10-24 14:15:35 +00:00
}.GetValueAsInt(10), Equals, 10)
2017-05-25 23:11:38 +00:00
}