• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Bool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/v2ray/v2ray-core/testing/assert.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Bool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:27,代码来源:receiving_test.go


示例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)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:31,代码来源:sending_test.go


示例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))
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:25,代码来源:pubsub_test.go


示例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)
}
开发者ID:xiaomotou,项目名称:v2ray-core,代码行数:27,代码来源:receiver_test.go


示例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()
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:27,代码来源:build_test.go


示例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()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:8,代码来源:server_spec_test.go


示例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()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:8,代码来源:uuid_test.go


示例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()
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:8,代码来源:uuid_test.go


示例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()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:9,代码来源:connection_test.go


示例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()
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:9,代码来源:network_json_test.go


示例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()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:9,代码来源:network_json_test.go


示例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()
}
开发者ID:JohnTsaiAndroid,项目名称:v2ray-core,代码行数:11,代码来源:chinasites_test.go


示例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()
}
开发者ID:earthGavinLee,项目名称:v2ray-core,代码行数:11,代码来源:buffer_test.go


示例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()
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:11,代码来源:chinaip_test.go


示例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()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:11,代码来源:address_json_test.go


示例16: TestUserPassConfig

func TestUserPassConfig(t *testing.T) {
	v2testing.Current(t)

	var config SocksConfig
	err := json.Unmarshal([]byte("{\"auth\":\"password\", \"accounts\":[{\"user\":\"x\", \"pass\":\"y\"}], \"udp\":true}"), &config)
	assert.Error(err).IsNil()
	assert.Bool(config.IsNoAuth()).IsFalse()
	assert.Bool(config.IsPassword()).IsTrue()
	assert.Bool(config.HasAccount("x", "y")).IsTrue()
	assert.Bool(config.UDPEnabled()).IsTrue()
}
开发者ID:adoot,项目名称:v2ray-core,代码行数:11,代码来源:config_test.go


示例17: TestNoAuthConfig

func TestNoAuthConfig(t *testing.T) {
	v2testing.Current(t)

	var config SocksConfig
	err := json.Unmarshal([]byte("{\"auth\":\"noauth\", \"ip\":\"8.8.8.8\"}"), &config)
	assert.Error(err).IsNil()
	assert.Bool(config.IsNoAuth()).IsTrue()
	assert.Bool(config.IsPassword()).IsFalse()
	assert.String(config.IP()).Equals("8.8.8.8")
	assert.Bool(config.UDPEnabled()).IsFalse()
}
开发者ID:adoot,项目名称:v2ray-core,代码行数:11,代码来源:config_test.go


示例18: TestDomainParsing

func TestDomainParsing(t *testing.T) {
	assert := assert.On(t)

	rawJson := "\"v2ray.com\""
	var address AddressJson
	err := json.Unmarshal([]byte(rawJson), &address)
	assert.Error(err).IsNil()
	assert.Bool(address.Address.IsIPv4()).IsFalse()
	assert.Bool(address.Address.IsDomain()).IsTrue()
	assert.String(address.Address.Domain()).Equals("v2ray.com")
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:11,代码来源:address_json_test.go


示例19: TestIPParsing

func TestIPParsing(t *testing.T) {
	v2testing.Current(t)

	rawJson := "\"8.8.8.8\""
	host := &Host{}
	err := json.Unmarshal([]byte(rawJson), host)
	assert.Error(err).IsNil()
	assert.Bool(host.IsIP()).IsTrue()
	assert.Bool(host.IsDomain()).IsFalse()
	assert.Bool(host.IP().Equal(net.ParseIP("8.8.8.8"))).IsTrue()
}
开发者ID:JohnTsaiAndroid,项目名称:v2ray-core,代码行数:11,代码来源:host_test.go


示例20: TestDomainParsing

func TestDomainParsing(t *testing.T) {
	v2testing.Current(t)

	rawJson := "\"v2ray.com\""
	host := &Host{}
	err := json.Unmarshal([]byte(rawJson), host)
	assert.Error(err).IsNil()
	assert.Bool(host.IsIP()).IsFalse()
	assert.Bool(host.IsDomain()).IsTrue()
	assert.StringLiteral(host.Domain()).Equals("v2ray.com")
}
开发者ID:JohnTsaiAndroid,项目名称:v2ray-core,代码行数:11,代码来源:host_test.go



注:本文中的github.com/v2ray/v2ray-core/testing/assert.Bool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.Byte函数代码示例发布时间:2022-05-28
下一篇:
Golang testing.Current函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap