1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-06 03:54:22 -04:00
v2fly/common/net/json/network_test.go

30 lines
674 B
Go
Raw Normal View History

2015-11-01 17:01:15 -05:00
package json
import (
"encoding/json"
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
2015-11-01 17:01:15 -05:00
)
func TestArrayNetworkList(t *testing.T) {
v2testing.Current(t)
2015-11-01 17:01:15 -05:00
var list NetworkList
err := json.Unmarshal([]byte("[\"Tcp\"]"), &list)
assert.Error(err).IsNil()
assert.Bool(list.HasNetwork("tcp")).IsTrue()
assert.Bool(list.HasNetwork("udp")).IsFalse()
}
func TestStringNetworkList(t *testing.T) {
v2testing.Current(t)
2015-11-01 17:01:15 -05:00
var list NetworkList
err := json.Unmarshal([]byte("\"TCP, ip\""), &list)
assert.Error(err).IsNil()
assert.Bool(list.HasNetwork("tcp")).IsTrue()
assert.Bool(list.HasNetwork("udp")).IsFalse()
}