当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.Bool函数代码示例

本文整理汇总了Golang中v2ray/com/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:DZLZHCODE,项目名称:v2ray-core,代码行数:27,代码来源:receiving_test.go

示例2: TestChinaSitesJson

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

	rule := ParseRule([]byte(`{
    "type": "chinasites",
    "outboundTag": "y"
  }`))
	assert.String(rule.Tag).Equals("y")
	cond, err := rule.BuildCondition()
	assert.Error(err).IsNil()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("v.qq.com"), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("www.163.com"), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("ngacn.cc"), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("12306.cn"), 80),
	})).IsTrue()

	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("v2ray.com"), 80),
	})).IsFalse()
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:27,代码来源:router_test.go

示例3: TestDomainRule

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

	rule := ParseRule([]byte(`{
    "type": "field",
    "domain": [
      "ooxx.com",
      "oxox.com",
      "regexp:\\.cn$"
    ],
    "network": "tcp",
    "outboundTag": "direct"
  }`))
	assert.Pointer(rule).IsNotNil()
	cond, err := rule.BuildCondition()
	assert.Error(err).IsNil()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("www.ooxx.com"), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("www.aabb.com"), 80),
	})).IsFalse()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80),
	})).IsFalse()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("www.12306.cn"), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("www.acn.com"), 80),
	})).IsFalse()
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:32,代码来源:router_test.go

示例4: TestChinaIPJson

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

	rule := ParseRule([]byte(`{
    "type": "chinaip",
    "outboundTag": "x"
  }`))
	assert.String(rule.Tag).Equals("x")
	cond, err := rule.BuildCondition()
	assert.Error(err).IsNil()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("121.14.1.189"), 80),
	})).IsTrue() // sina.com.cn
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("101.226.103.106"), 80),
	})).IsTrue() // qq.com
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("115.239.210.36"), 80),
	})).IsTrue() // image.baidu.com
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("120.135.126.1"), 80),
	})).IsTrue()

	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Destination: v2net.TCPDestination(v2net.ParseAddress("8.8.8.8"), 80),
	})).IsFalse()
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:27,代码来源:router_test.go

示例5: TestSourceIPRule

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

	rule := ParseRule([]byte(`{
    "type": "field",
    "source": [
      "10.0.0.0/8",
      "192.0.0.0/24"
    ],
    "outboundTag": "direct"
  }`))
	assert.Pointer(rule).IsNotNil()
	cond, err := rule.BuildCondition()
	assert.Error(err).IsNil()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Source: v2net.TCPDestination(v2net.DomainAddress("www.ooxx.com"), 80),
	})).IsFalse()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Source: v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80),
	})).IsTrue()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Source: v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80),
	})).IsFalse()
	assert.Bool(cond.Apply(&proxy.SessionInfo{
		Source: v2net.TCPDestination(v2net.IPAddress([]byte{192, 0, 0, 1}), 80),
	})).IsTrue()
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:27,代码来源:router_test.go

示例6: TestSocksInboundConfig

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

	rawJson := `{
    "auth": "password",
    "accounts": [
      {
        "user": "my-username",
        "pass": "my-password"
      }
    ],
    "udp": false,
    "ip": "127.0.0.1",
    "timeout": 5
  }`

	config := new(SocksServerConfig)
	err := json.Unmarshal([]byte(rawJson), &config)
	assert.Error(err).IsNil()

	message, err := config.Build()
	assert.Error(err).IsNil()

	iConfig, err := message.GetInstance()
	assert.Error(err).IsNil()

	socksConfig := iConfig.(*socks.ServerConfig)
	assert.Bool(socksConfig.AuthType == socks.AuthType_PASSWORD).IsTrue()
	assert.Int(len(socksConfig.Accounts)).Equals(1)
	assert.String(socksConfig.Accounts["my-username"]).Equals("my-password")
	assert.Bool(socksConfig.UdpEnabled).IsFalse()
	assert.Address(socksConfig.Address.AsAddress()).Equals(net.LocalHostIP)
	assert.Uint32(socksConfig.Timeout).Equals(5)
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:34,代码来源:socks_test.go

示例7: TestBuildMacOS

func TestBuildMacOS(t *testing.T) {
	assert := assert.On(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:DZLZHCODE,项目名称:v2ray-core,代码行数:27,代码来源:build_test.go

示例8: 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:DZLZHCODE,项目名称:v2ray-core,代码行数:8,代码来源:uuid_test.go

示例9: 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:v2ray,项目名称:v2ray-core,代码行数:8,代码来源:server_spec_test.go

示例10: TestStringNetworkList

func TestStringNetworkList(t *testing.T) {
	assert := assert.On(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:DZLZHCODE,项目名称:v2ray-core,代码行数:9,代码来源:network_json_test.go

示例11: 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:DZLZHCODE,项目名称:v2ray-core,代码行数:9,代码来源:connection_test.go

示例12: TestBufferIsFull

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

	buffer := NewBuffer()
	defer buffer.Release()

	assert.Bool(buffer.IsFull()).IsTrue()

	buffer.Clear()
	assert.Bool(buffer.IsFull()).IsFalse()
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:11,代码来源:buffer_test.go

示例13: TestRequestOptionClear

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

	var option RequestOption
	option.Set(RequestOptionChunkStream)
	option.Set(RequestOptionConnectionReuse)

	option.Clear(RequestOptionChunkStream)
	assert.Bool(option.Has(RequestOptionChunkStream)).IsFalse()
	assert.Bool(option.Has(RequestOptionConnectionReuse)).IsTrue()
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:11,代码来源:headers_test.go

示例14: TestArrayNetworkList

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

	var list NetworkList
	err := json.Unmarshal([]byte("[\"Tcp\"]"), &list)
	assert.Error(err).IsNil()

	nlist := list.Build()
	assert.Bool(nlist.HasNetwork(v2net.ParseNetwork("tcp"))).IsTrue()
	assert.Bool(nlist.HasNetwork(v2net.ParseNetwork("udp"))).IsFalse()
}
开发者ID:v2ray,项目名称:v2ray-core,代码行数:11,代码来源:common_test.go

示例15: 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.Family().Either(AddressFamilyIPv4)).IsFalse()
	assert.Bool(address.Address.Family().Either(AddressFamilyDomain)).IsTrue()
	assert.String(address.Address.Domain()).Equals("v2ray.com")
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:11,代码来源:address_json_test.go


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