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


Golang assert.Pointer函数代码示例

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


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

示例1: TestSwitchAccount

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

	sa := &SwitchAccount{
		Port:     1234,
		ID:       uuid.New(),
		AlterIds: 1024,
		Level:    128,
		ValidMin: 16,
	}

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

	buffer := bytes.NewBuffer(make([]byte, 0, 1024))
	sa.Marshal(buffer)

	cmd.Unmarshal(buffer.Bytes())
	sa2, ok := cmd.(*SwitchAccount)
	assert.Bool(ok).IsTrue()
	assert.Pointer(sa.Host).IsNil()
	assert.Pointer(sa2.Host).IsNil()
	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.Byte(byte(sa.Level)).Equals(byte(sa2.Level))
	assert.Byte(sa.ValidMin).Equals(sa2.ValidMin)
}
开发者ID:airmao,项目名称:v2ray-core,代码行数:28,代码来源:accounts_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: TestSwitchAccount

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

	sa := &protocol.CommandSwitchAccount{
		Port:     1234,
		ID:       uuid.New(),
		AlterIds: 1024,
		Level:    128,
		ValidMin: 16,
	}

	buffer := alloc.NewBuffer().Clear()
	err := MarshalCommand(sa, buffer)
	assert.Error(err).IsNil()

	cmd, err := UnmarshalCommand(1, buffer.Value[2:])
	assert.Error(err).IsNil()

	sa2, ok := cmd.(*protocol.CommandSwitchAccount)
	assert.Bool(ok).IsTrue()
	assert.Pointer(sa.Host).IsNil()
	assert.Pointer(sa2.Host).IsNil()
	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.Byte(byte(sa.Level)).Equals(byte(sa2.Level))
	assert.Byte(sa.ValidMin).Equals(sa2.ValidMin)
}
开发者ID:wangyou,项目名称:v2ray-core,代码行数:28,代码来源:commands_test.go

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

示例5: TestParseOS

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

	assert.Pointer(parseOS("windows")).Equals(Windows)
	assert.Pointer(parseOS("macos")).Equals(MacOS)
	assert.Pointer(parseOS("linux")).Equals(Linux)
	assert.Pointer(parseOS("test")).Equals(UnknownOS)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:8,代码来源:env_test.go

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

示例7: TestParseArch

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

	assert.Pointer(parseArch("x86")).Equals(X86)
	assert.Pointer(parseArch("x64")).Equals(Amd64)
	assert.Pointer(parseArch("arm")).Equals(Arm)
	assert.Pointer(parseArch("arm64")).Equals(Arm64)
	assert.Pointer(parseArch("test")).Equals(UnknownArch)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:9,代码来源:env_test.go

示例8: TestLogLevelSetting

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

	assert.Pointer(debugLogger).Equals(noOpLoggerInstance)
	SetLogLevel(DebugLevel)
	assert.Pointer(debugLogger).Equals(streamLoggerInstance)

	SetLogLevel(InfoLevel)
	assert.Pointer(debugLogger).Equals(noOpLoggerInstance)
	assert.Pointer(infoLogger).Equals(streamLoggerInstance)
}
开发者ID:wangyou,项目名称:v2ray-core,代码行数:11,代码来源:log_test.go

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

示例10: TestServerSampleConfig

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

	// TODO: fix for Windows
	baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"

	pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
	assert.Error(err).IsNil()

	netassert.Port(pointConfig.Port).IsValid()
	assert.Pointer(pointConfig.InboundConfig).IsNotNil()
	assert.Pointer(pointConfig.OutboundConfig).IsNotNil()

	assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("vmess")
	assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()

	assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
}
开发者ID:ducktsmt,项目名称:v2ray-core,代码行数:19,代码来源:config_json_test.go

示例11: TestServerSampleConfig

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

	GOPATH := os.Getenv("GOPATH")
	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")

	pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
	assert.Error(err).IsNil()

	netassert.Port(pointConfig.Port).IsValid()
	assert.Pointer(pointConfig.InboundConfig).IsNotNil()
	assert.Pointer(pointConfig.OutboundConfig).IsNotNil()

	assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("vmess")
	assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()

	assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
}
开发者ID:jim1568cas,项目名称:v2ray-core,代码行数:19,代码来源:config_json_test.go

示例12: TestClientSampleConfig

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

	GOPATH := os.Getenv("GOPATH")
	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")

	pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
	assert.Error(err).IsNil()

	assert.Pointer(pointConfig.InboundConfig).IsNotNil()
	assert.Port(pointConfig.InboundConfig.Port).IsValid()
	assert.Pointer(pointConfig.OutboundConfig).IsNotNil()

	assert.String(pointConfig.InboundConfig.Protocol).Equals("socks")
	assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()

	assert.String(pointConfig.OutboundConfig.Protocol).Equals("vmess")
	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:19,代码来源:config_json_test.go

示例13: TestIPRule

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

	rule := ParseRule([]byte(`{
    "type": "field",
    "ip": [
      "10.0.0.0/8",
      "192.0.0.0/24"
    ],
    "network": "tcp",
    "outboundTag": "direct"
  }`))
	assert.Pointer(rule).IsNotNil()
	assert.Bool(rule.Apply(v2net.TCPDestination(v2net.DomainAddress("www.ooxx.com"), 80))).IsFalse()
	assert.Bool(rule.Apply(v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80))).IsTrue()
	assert.Bool(rule.Apply(v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80))).IsFalse()
	assert.Bool(rule.Apply(v2net.TCPDestination(v2net.IPAddress([]byte{192, 0, 0, 1}), 80))).IsTrue()
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:18,代码来源:config_json_test.go

示例14: TestRegisterOutboundConfig

func TestRegisterOutboundConfig(t *testing.T) {
	v2testing.Current(t)
	initializeConfigCache()

	protocol := "test_protocol"
	creator := func() interface{} {
		return true
	}

	err := RegisterOutboundConnectionConfig(protocol, creator)
	assert.Error(err).IsNil()

	configObj := CreateConfig(protocol, config.TypeOutbound)
	assert.Bool(configObj.(bool)).IsTrue()

	configObj = CreateConfig(protocol, config.TypeInbound)
	assert.Pointer(configObj).IsNil()
}
开发者ID:adoot,项目名称:v2ray-core,代码行数:18,代码来源:config_cache_test.go

示例15: TestServerList

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

	list := NewServerList()
	list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(1)), AlwaysValid()))
	assert.Uint32(list.Size()).Equals(1)
	list.AddServer(NewServerSpec(v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(2)), BeforeTime(time.Now().Add(time.Second))))
	assert.Uint32(list.Size()).Equals(2)

	server := list.GetServer(1)
	assert.Port(server.Destination().Port()).Equals(2)
	time.Sleep(2 * time.Second)
	server = list.GetServer(1)
	assert.Pointer(server).IsNil()

	server = list.GetServer(0)
	assert.Port(server.Destination().Port()).Equals(1)
}
开发者ID:ChoyesYan,项目名称:v2ray-core,代码行数:18,代码来源:server_picker_test.go


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