mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-06 03:54:22 -04:00
29 lines
631 B
Go
29 lines
631 B
Go
|
package json
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/v2ray/v2ray-core/testing/unit"
|
||
|
)
|
||
|
|
||
|
func TestArrayNetworkList(t *testing.T) {
|
||
|
assert := unit.Assert(t)
|
||
|
|
||
|
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) {
|
||
|
assert := unit.Assert(t)
|
||
|
|
||
|
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()
|
||
|
}
|