mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
774 B
33 lines
774 B
9 years ago
|
// +build json
|
||
|
|
||
|
package net_test
|
||
9 years ago
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"testing"
|
||
|
|
||
9 years ago
|
. "github.com/v2ray/v2ray-core/common/net"
|
||
9 years ago
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
||
|
"github.com/v2ray/v2ray-core/testing/assert"
|
||
9 years ago
|
)
|
||
|
|
||
|
func TestArrayNetworkList(t *testing.T) {
|
||
9 years ago
|
v2testing.Current(t)
|
||
9 years ago
|
|
||
|
var list NetworkList
|
||
|
err := json.Unmarshal([]byte("[\"Tcp\"]"), &list)
|
||
|
assert.Error(err).IsNil()
|
||
9 years ago
|
assert.Bool(list.HasNetwork(Network("tcp"))).IsTrue()
|
||
|
assert.Bool(list.HasNetwork(Network("udp"))).IsFalse()
|
||
9 years ago
|
}
|
||
|
|
||
|
func TestStringNetworkList(t *testing.T) {
|
||
9 years ago
|
v2testing.Current(t)
|
||
9 years ago
|
|
||
|
var list NetworkList
|
||
|
err := json.Unmarshal([]byte("\"TCP, ip\""), &list)
|
||
|
assert.Error(err).IsNil()
|
||
9 years ago
|
assert.Bool(list.HasNetwork(Network("tcp"))).IsTrue()
|
||
|
assert.Bool(list.HasNetwork(Network("udp"))).IsFalse()
|
||
9 years ago
|
}
|