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


Golang assert.Int函数代码示例

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


在下文中一共展示了Int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: TestTimeOutSettings

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

	reader := NewTimeOutReader(8, nil)
	assert.Int(reader.GetTimeOut()).Equals(8)
	reader.SetTimeOut(8) // no op
	assert.Int(reader.GetTimeOut()).Equals(8)
	reader.SetTimeOut(9)
	assert.Int(reader.GetTimeOut()).Equals(9)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:10,代码来源:timed_io_test.go

示例3: TestBufferClear

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

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

	payload := "Bytes"
	buffer.Append([]byte(payload))
	assert.Int(buffer.Len()).Equals(len(payload))

	buffer.Clear()
	assert.Int(buffer.Len()).Equals(0)
}
开发者ID:earthGavinLee,项目名称:v2ray-core,代码行数:13,代码来源:buffer_test.go

示例4: TestTCPBind

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

	targetPort := v2nettesting.PickPort()
	tcpServer := &tcp.Server{
		Port: targetPort,
		MsgProcessor: func(data []byte) []byte {
			buffer := make([]byte, 0, 2048)
			buffer = append(buffer, []byte("Processed: ")...)
			buffer = append(buffer, data...)
			return buffer
		},
	}
	_, err := tcpServer.Start()
	assert.Error(err).IsNil()
	defer tcpServer.Close()

	assert.Error(InitializeServerSetOnce("test_1")).IsNil()

	socksPort := v2net.Port(50000)

	conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
		IP:   []byte{127, 0, 0, 1},
		Port: int(socksPort),
	})

	authRequest := socks5AuthMethodRequest(byte(0))
	nBytes, err := conn.Write(authRequest)
	assert.Int(nBytes).Equals(len(authRequest))
	assert.Error(err).IsNil()

	authResponse := make([]byte, 1024)
	nBytes, err = conn.Read(authResponse)
	assert.Error(err).IsNil()
	assert.Bytes(authResponse[:nBytes]).Equals([]byte{socks5Version, 0})

	connectRequest := socks5Request(byte(2), v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), targetPort))
	nBytes, err = conn.Write(connectRequest)
	assert.Int(nBytes).Equals(len(connectRequest))
	assert.Error(err).IsNil()

	connectResponse := make([]byte, 1024)
	nBytes, err = conn.Read(connectResponse)
	assert.Error(err).IsNil()
	assert.Bytes(connectResponse[:nBytes]).Equals([]byte{socks5Version, 7, 0, 1, 0, 0, 0, 0, 0, 0})

	conn.Close()

	CloseAllServers()
}
开发者ID:earthGavinLee,项目名称:v2ray-core,代码行数:50,代码来源:socks_end_test.go

示例5: TestRepoVersion

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

	version, err := RepoVersionHead()
	assert.Error(err).IsNil()
	assert.Int(len(version)).GreaterThan(0)
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:7,代码来源:git_test.go

示例6: TestHttpProxy

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

	httpServer := &v2http.Server{
		Port:        v2net.Port(50042),
		PathHandler: make(map[string]http.HandlerFunc),
	}
	_, err := httpServer.Start()
	assert.Error(err).IsNil()
	defer httpServer.Close()

	assert.Error(InitializeServerSetOnce("test_5")).IsNil()

	transport := &http.Transport{
		Proxy: func(req *http.Request) (*url.URL, error) {
			return url.Parse("http://127.0.0.1:50040/")
		},
	}

	client := &http.Client{
		Transport: transport,
	}

	resp, err := client.Get("http://127.0.0.1:50042/")
	assert.Error(err).IsNil()
	assert.Int(resp.StatusCode).Equals(200)

	content, err := ioutil.ReadAll(resp.Body)
	assert.Error(err).IsNil()
	assert.StringLiteral(string(content)).Equals("Home")

	CloseAllServers()
}
开发者ID:airmao,项目名称:v2ray-core,代码行数:33,代码来源:http_test.go

示例7: TestBadSegment

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

	seg, buf := ReadSegment(nil)
	assert.Pointer(seg).IsNil()
	assert.Int(len(buf)).Equals(0)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:7,代码来源:segment_test.go

示例8: TestACKSegment

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

	seg := &AckSegment{
		Conv:            1,
		ReceivingWindow: 2,
		ReceivingNext:   3,
		Count:           5,
		NumberList:      []uint32{1, 3, 5, 7, 9},
		TimestampList:   []uint32{2, 4, 6, 8, 10},
	}

	nBytes := seg.ByteSize()
	bytes := seg.Bytes(nil)

	assert.Int(len(bytes)).Equals(nBytes)

	iseg, _ := ReadSegment(bytes)
	seg2 := iseg.(*AckSegment)
	assert.Uint16(seg2.Conv).Equals(seg.Conv)
	assert.Uint32(seg2.ReceivingWindow).Equals(seg.ReceivingWindow)
	assert.Uint32(seg2.ReceivingNext).Equals(seg.ReceivingNext)
	assert.Byte(seg2.Count).Equals(seg.Count)
	for i := byte(0); i < seg2.Count; i++ {
		assert.Uint32(seg2.TimestampList[i]).Equals(seg.TimestampList[i])
		assert.Uint32(seg2.NumberList[i]).Equals(seg.NumberList[i])
	}
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:28,代码来源:segment_test.go

示例9: TestSwitchAccount

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

	sa := &SwitchAccount{
		Port:       1234,
		ID:         uuid.New(),
		AlterIds:   1024,
		ValidUntil: time.Now(),
	}

	cmd, err := CreateResponseCommand(1)
	assert.Error(err).IsNil()

	buffer := bytes.NewBuffer(make([]byte, 0, 1024))
	nBytes, err := sa.Marshal(buffer)
	assert.Error(err).IsNil()
	assert.Int(nBytes).Equals(buffer.Len())

	cmd.Unmarshal(buffer.Bytes())
	sa2, ok := cmd.(*SwitchAccount)
	assert.Bool(ok).IsTrue()
	netassert.Port(sa.Port).Equals(sa2.Port)
	assert.String(sa.ID).Equals(sa2.ID.String())
	assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value())
	assert.Int64(sa.ValidUntil.Unix()).Equals(sa2.ValidUntil.Unix())
}
开发者ID:ibmendoza,项目名称:v2ray-core,代码行数:26,代码来源:accounts_test.go

示例10: TestNormalGetRequest

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

	testPacketDispatcher := testdispatcher.NewTestPacketDispatcher(nil)

	port := v2nettesting.PickPort()
	httpProxy := NewServer(
		&Config{},
		testPacketDispatcher,
		&proxy.InboundHandlerMeta{
			Address: v2net.LocalHostIP,
			Port:    port,
			StreamSettings: &internet.StreamSettings{
				Type: internet.StreamConnectionTypeRawTCP,
			}})
	defer httpProxy.Close()

	err := httpProxy.Start()
	assert.Error(err).IsNil()
	assert.Port(port).Equals(httpProxy.Port())

	httpClient := &http.Client{}
	resp, err := httpClient.Get("http://127.0.0.1:" + port.String() + "/")
	assert.Error(err).IsNil()
	assert.Int(resp.StatusCode).Equals(400)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:26,代码来源:server_test.go

示例11: TestRevParse

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

	rev, err := RevParse("HEAD")
	assert.Error(err).IsNil()
	assert.Int(len(rev)).GreaterThan(0)
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:7,代码来源:git_test.go

示例12: 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

示例13: TestSizedQueue

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

	queue := collect.NewSizedQueue(2)
	assert.Pointer(queue.Put(1)).IsNil()
	assert.Pointer(queue.Put(2)).IsNil()
	assert.Int(queue.Put(3).(int)).Equals(1)
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:8,代码来源:sized_queue_test.go

示例14: TestReceiverUser

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

	id := proto.NewID(uuid.New())
	user := proto.NewUser(id, proto.UserLevel(0), 100, "")
	rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user)
	assert.Bool(rec.HasUser(user)).IsTrue()
	assert.Int(len(rec.Accounts)).Equals(1)

	id2 := proto.NewID(uuid.New())
	user2 := proto.NewUser(id2, proto.UserLevel(0), 100, "")
	assert.Bool(rec.HasUser(user2)).IsFalse()

	rec.AddUser(user2)
	assert.Bool(rec.HasUser(user2)).IsTrue()
	assert.Int(len(rec.Accounts)).Equals(2)
}
开发者ID:wangyou,项目名称:v2ray-core,代码行数:17,代码来源:receiver_test.go

示例15: TestRecivingQueue

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

	queue := NewReceivingQueue(2)
	queue.Put(alloc.NewSmallBuffer().Clear().AppendString("abcd"))
	queue.Put(alloc.NewSmallBuffer().Clear().AppendString("efg"))
	assert.Bool(queue.IsFull()).IsTrue()

	b := make([]byte, 1024)
	nBytes := queue.Read(b)
	assert.Int(nBytes).Equals(7)
	assert.String(string(b[:nBytes])).Equals("abcdefg")

	queue.Put(alloc.NewSmallBuffer().Clear().AppendString("1"))
	queue.Close()
	nBytes = queue.Read(b)
	assert.Int(nBytes).Equals(0)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:18,代码来源:receiving_test.go


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