當前位置: 首頁>>代碼示例>>Golang>>正文


Golang assert.Bool函數代碼示例

本文整理匯總了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)
}
開發者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


注:本文中的github.com/v2ray/v2ray-core/testing/assert.Bool函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。