本文整理汇总了Golang中github.com/v2ray/v2ray-core/testing/assert.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestRecivingWindow
func TestRecivingWindow(t *testing.T) {
assert := assert.On(t)
window := NewReceivingWindow(3)
seg0 := &DataSegment{}
seg1 := &DataSegment{}
seg2 := &DataSegment{}
seg3 := &DataSegment{}
assert.Bool(window.Set(0, seg0)).IsTrue()
assert.Pointer(window.RemoveFirst()).Equals(seg0)
e := window.RemoveFirst()
if e != nil {
assert.Fail("Expecting nil.")
}
assert.Bool(window.Set(1, seg1)).IsTrue()
assert.Bool(window.Set(2, seg2)).IsTrue()
window.Advance()
assert.Bool(window.Set(2, seg3)).IsTrue()
assert.Pointer(window.RemoveFirst()).Equals(seg1)
assert.Pointer(window.Remove(1)).Equals(seg2)
assert.Pointer(window.Remove(2)).Equals(seg3)
}
示例2: TestSendingQueue
func TestSendingQueue(t *testing.T) {
assert := assert.On(t)
queue := NewSendingQueue(3)
seg0 := alloc.NewBuffer()
seg1 := alloc.NewBuffer()
seg2 := alloc.NewBuffer()
seg3 := alloc.NewBuffer()
assert.Bool(queue.IsEmpty()).IsTrue()
assert.Bool(queue.IsFull()).IsFalse()
queue.Push(seg0)
assert.Bool(queue.IsEmpty()).IsFalse()
queue.Push(seg1)
queue.Push(seg2)
assert.Bool(queue.IsFull()).IsTrue()
assert.Pointer(queue.Pop()).Equals(seg0)
queue.Push(seg3)
assert.Bool(queue.IsFull()).IsTrue()
assert.Pointer(queue.Pop()).Equals(seg1)
assert.Pointer(queue.Pop()).Equals(seg2)
assert.Pointer(queue.Pop()).Equals(seg3)
assert.Int(int(queue.Len())).Equals(0)
}
示例3: TestPubsub
func TestPubsub(t *testing.T) {
v2testing.Current(t)
messages := make(map[string]app.PubsubMessage)
pubsub := New()
pubsub.Subscribe(&apptesting.Context{}, "t1", func(message app.PubsubMessage) {
messages["t1"] = message
})
pubsub.Subscribe(&apptesting.Context{}, "t2", func(message app.PubsubMessage) {
messages["t2"] = message
})
message := app.PubsubMessage([]byte("This is a pubsub message."))
pubsub.Publish(&apptesting.Context{}, "t2", message)
<-time.Tick(time.Second)
_, found := messages["t1"]
assert.Bool(found).IsFalse()
actualMessage, found := messages["t2"]
assert.Bool(found).IsTrue()
assert.StringLiteral(string(actualMessage)).Equals(string(message))
}
示例4: TestReceiverUser
func TestReceiverUser(t *testing.T) {
assert := assert.On(t)
id := protocol.NewID(uuid.New())
alters := protocol.NewAlterIDs(id, 100)
account := &protocol.VMessAccount{
ID: id,
AlterIDs: alters,
}
user := protocol.NewUser(account, protocol.UserLevel(0), "")
rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user)
assert.Bool(rec.HasUser(user)).IsTrue()
assert.Int(len(rec.Accounts)).Equals(1)
id2 := protocol.NewID(uuid.New())
alters2 := protocol.NewAlterIDs(id2, 100)
account2 := &protocol.VMessAccount{
ID: id2,
AlterIDs: alters2,
}
user2 := protocol.NewUser(account2, protocol.UserLevel(0), "")
assert.Bool(rec.HasUser(user2)).IsFalse()
rec.AddUser(user2)
assert.Bool(rec.HasUser(user2)).IsTrue()
assert.Int(len(rec.Accounts)).Equals(2)
}
示例5: TestBuildMacOS
func TestBuildMacOS(t *testing.T) {
v2testing.Current(t)
binPath = filepath.Join(os.Getenv("GOPATH"), "testing")
cleanBinPath()
build("macos", "amd64", true, "test", "metadata.txt")
assert.Bool(allFilesExists(
"v2ray-macos.zip",
"v2ray-test-macos",
filepath.Join("v2ray-test-macos", "config.json"),
filepath.Join("v2ray-test-macos", "v2ray"))).IsTrue()
build("windows", "amd64", true, "test", "metadata.txt")
assert.Bool(allFilesExists(
"v2ray-windows-64.zip",
"v2ray-test-windows-64",
filepath.Join("v2ray-test-windows-64", "config.json"),
filepath.Join("v2ray-test-windows-64", "v2ray.exe"))).IsTrue()
build("linux", "amd64", true, "test", "metadata.txt")
assert.Bool(allFilesExists(
"v2ray-linux-64.zip",
"v2ray-test-linux-64",
filepath.Join("v2ray-test-linux-64", "vpoint_socks_vmess.json"),
filepath.Join("v2ray-test-linux-64", "vpoint_vmess_freedom.json"),
filepath.Join("v2ray-test-linux-64", "v2ray"))).IsTrue()
}
示例6: TestAlwaysValidStrategy
func TestAlwaysValidStrategy(t *testing.T) {
assert := assert.On(t)
strategy := AlwaysValid()
assert.Bool(strategy.IsValid()).IsTrue()
strategy.Invalidate()
assert.Bool(strategy.IsValid()).IsTrue()
}
示例7: TestEquals
func TestEquals(t *testing.T) {
assert := assert.On(t)
var uuid *UUID = nil
var uuid2 *UUID = nil
assert.Bool(uuid.Equals(uuid2)).IsTrue()
assert.Bool(uuid.Equals(New())).IsFalse()
}
示例8: TestEquals
func TestEquals(t *testing.T) {
v2testing.Current(t)
var uuid *UUID = nil
var uuid2 *UUID = nil
assert.Bool(uuid.Equals(uuid2)).IsTrue()
assert.Bool(uuid.Equals(New())).IsFalse()
}
示例9: TestRawConnection
func TestRawConnection(t *testing.T) {
assert := assert.On(t)
rawConn := RawConnection{net.TCPConn{}}
assert.Bool(rawConn.Reusable()).IsFalse()
rawConn.SetReusable(true)
assert.Bool(rawConn.Reusable()).IsFalse()
}
示例10: TestStringNetworkList
func TestStringNetworkList(t *testing.T) {
v2testing.Current(t)
var list NetworkList
err := json.Unmarshal([]byte("\"TCP, ip\""), &list)
assert.Error(err).IsNil()
assert.Bool(list.HasNetwork(Network("tcp"))).IsTrue()
assert.Bool(list.HasNetwork(Network("udp"))).IsFalse()
}
示例11: TestArrayNetworkList
func TestArrayNetworkList(t *testing.T) {
assert := assert.On(t)
var list NetworkList
err := json.Unmarshal([]byte("[\"Tcp\"]"), &list)
assert.Error(err).IsNil()
assert.Bool(list.HasNetwork(Network("tcp"))).IsTrue()
assert.Bool(list.HasNetwork(Network("udp"))).IsFalse()
}
示例12: TestChinaSites
func TestChinaSites(t *testing.T) {
v2testing.Current(t)
rule := &ChinaSitesRule{}
assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()
assert.Bool(rule.Apply(makeDomainDestination("12306.cn"))).IsTrue()
assert.Bool(rule.Apply(makeDomainDestination("v2ray.com"))).IsFalse()
}
示例13: TestBufferIsFull
func TestBufferIsFull(t *testing.T) {
v2testing.Current(t)
buffer := NewBuffer()
defer buffer.Release()
assert.Bool(buffer.IsFull()).IsTrue()
buffer.Clear()
assert.Bool(buffer.IsFull()).IsFalse()
}
示例14: TestChinaIP
func TestChinaIP(t *testing.T) {
v2testing.Current(t)
rule := NewIPv4Matcher(chinaIPNet)
assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue() // sina.com.cn
assert.Bool(rule.Apply(makeDestination("101.226.103.106"))).IsTrue() // qq.com
assert.Bool(rule.Apply(makeDestination("115.239.210.36"))).IsTrue() // image.baidu.com
assert.Bool(rule.Apply(makeDestination("120.135.126.1"))).IsTrue()
assert.Bool(rule.Apply(makeDestination("8.8.8.8"))).IsFalse()
}
示例15: TestIPParsing
func TestIPParsing(t *testing.T) {
assert := assert.On(t)
rawJson := "\"8.8.8.8\""
var address AddressJson
err := json.Unmarshal([]byte(rawJson), &address)
assert.Error(err).IsNil()
assert.Bool(address.Address.IsIPv4()).IsTrue()
assert.Bool(address.Address.IsDomain()).IsFalse()
assert.Bool(address.Address.IP().Equal(net.ParseIP("8.8.8.8"))).IsTrue()
}