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


Golang assert.Equal函数代码示例

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


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

示例1: TestConnect

func TestConnect(t *testing.T) {
	c.Connect("127.0.0.1:45678")
	assert.Equal(t, c.Host, "127.0.0.1")
	assert.Equal(t, c.Server, "127.0.0.1:45678")
	waitConnAndClose(t)
	initTestClient()
}
开发者ID:postfix,项目名称:name_pending,代码行数:7,代码来源:conn_test.go

示例2: TestToFloat64

func TestToFloat64(t *testing.T) {
	var eight interface{} = 8
	assert.Equal(t, ToFloat64(8), 8.00)
	assert.Equal(t, ToFloat64(8.31), 8.31)
	assert.Equal(t, ToFloat64("8.31"), 8.31)
	assert.Equal(t, ToFloat64(eight), 8.0)
}
开发者ID:postfix,项目名称:name_pending,代码行数:7,代码来源:cast_test.go

示例3: TestMarshal

func TestMarshal(t *testing.T) {
	SetDefault("port", 1313)
	Set("name", "Steve")

	type config struct {
		Port int
		Name string
	}

	var C config

	err := Marshal(&C)
	if err != nil {
		t.Fatalf("unable to decode into struct, %v", err)
	}

	assert.Equal(t, &C, &config{Name: "Steve", Port: 1313})

	Set("port", 1234)
	err = Marshal(&C)
	if err != nil {
		t.Fatalf("unable to decode into struct, %v", err)
	}
	assert.Equal(t, &C, &config{Name: "Steve", Port: 1234})
}
开发者ID:postfix,项目名称:name_pending,代码行数:25,代码来源:viper_test.go

示例4: TestAliasInConfigFile

func TestAliasInConfigFile(t *testing.T) {
	// the config file specifies "beard".  If we make this an alias for
	// "hasbeard", we still want the old config file to work with beard.
	RegisterAlias("beard", "hasbeard")
	assert.Equal(t, true, Get("hasbeard"))
	Set("hasbeard", false)
	assert.Equal(t, false, Get("beard"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:8,代码来源:viper_test.go

示例5: TestNick

func TestNick(t *testing.T) {
	c.Nick("test2")
	assert.Equal(t, "test2", c.GetNick())
	assert.Equal(t, "NICK test2\r\n", <-conn.hook)

	c.writeNick("nick")
	assert.Equal(t, "NICK nick\r\n", <-conn.hook)
}
开发者ID:postfix,项目名称:name_pending,代码行数:8,代码来源:client_test.go

示例6: TestAddRemoveUser

func TestAddRemoveUser(t *testing.T) {
	channelStore := NewChannelStore()
	channelStore.AddUser("user", "srv", "#chan")
	channelStore.AddUser("user2", "srv", "#chan")
	assert.Equal(t, channelStore.GetUsers("srv", "#chan"), []string{"user", "user2"})
	channelStore.RemoveUser("user", "srv", "#chan")
	assert.Equal(t, []string{"user2"}, channelStore.GetUsers("srv", "#chan"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:8,代码来源:channel_test.go

示例7: TestRenameUser

func TestRenameUser(t *testing.T) {
	channelStore := NewChannelStore()
	channelStore.AddUser("user", "srv", "#chan1")
	channelStore.AddUser("user", "srv", "#chan2")
	channelStore.RenameUser("user", "new", "srv")
	assert.Equal(t, []string{"new"}, channelStore.GetUsers("srv", "#chan1"))
	assert.Equal(t, []string{"new"}, channelStore.GetUsers("srv", "#chan2"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:8,代码来源:channel_test.go

示例8: TestIndirectPointers

func TestIndirectPointers(t *testing.T) {
	x := 13
	y := &x
	z := &y

	assert.Equal(t, ToInt(y), 13)
	assert.Equal(t, ToInt(z), 13)
}
开发者ID:postfix,项目名称:name_pending,代码行数:8,代码来源:cast_test.go

示例9: TestLevels

func TestLevels(t *testing.T) {
	SetStdoutThreshold(LevelError)
	assert.Equal(t, StdoutThreshold(), LevelError)
	SetLogThreshold(LevelCritical)
	assert.Equal(t, LogThreshold(), LevelCritical)
	assert.NotEqual(t, StdoutThreshold(), LevelCritical)
	SetStdoutThreshold(LevelWarn)
	assert.Equal(t, StdoutThreshold(), LevelWarn)
}
开发者ID:postfix,项目名称:name_pending,代码行数:9,代码来源:jww_test.go

示例10: TestQuit

func TestQuit(t *testing.T) {
	c.connected = true
	c.Quit()
	assert.Equal(t, "QUIT\r\n", <-conn.hook)
	_, ok := <-c.quit
	assert.Equal(t, false, ok)

	initTestClient()
}
开发者ID:postfix,项目名称:name_pending,代码行数:9,代码来源:client_test.go

示例11: TestWrite

func TestWrite(t *testing.T) {
	c.write("test")
	assert.Equal(t, "test\r\n", <-conn.hook)
	c.Write("test")
	assert.Equal(t, "test\r\n", <-conn.hook)
	c.writef("test %d", 2)
	assert.Equal(t, "test 2\r\n", <-conn.hook)
	c.Writef("test %d", 2)
	assert.Equal(t, "test 2\r\n", <-conn.hook)
}
开发者ID:postfix,项目名称:name_pending,代码行数:10,代码来源:conn_test.go

示例12: TestConnectDefaultPorts

func TestConnectDefaultPorts(t *testing.T) {
	c.Connect("127.0.0.1")
	assert.Equal(t, "127.0.0.1:6667", c.Server)
	initTestClient()

	c.TLS = true
	c.Connect("127.0.0.1")
	assert.Equal(t, "127.0.0.1:6697", c.Server)
	initTestClient()
}
开发者ID:postfix,项目名称:name_pending,代码行数:10,代码来源:conn_test.go

示例13: TestMode

func TestMode(t *testing.T) {
	channelStore := NewChannelStore()
	channelStore.AddUser("+user", "srv", "#chan")
	channelStore.SetMode("srv", "#chan", "user", "o", "v")
	assert.Equal(t, []string{"@user"}, channelStore.GetUsers("srv", "#chan"))
	channelStore.SetMode("srv", "#chan", "user", "v", "")
	assert.Equal(t, []string{"+user"}, channelStore.GetUsers("srv", "#chan"))
	channelStore.SetMode("srv", "#chan", "user", "", "v")
	assert.Equal(t, []string{"user"}, channelStore.GetUsers("srv", "#chan"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:10,代码来源:channel_test.go

示例14: TestMarshalling

func TestMarshalling(t *testing.T) {
	SetConfigType("yaml")
	r := bytes.NewReader(yamlExample)

	marshalReader(r, v.config)
	assert.True(t, InConfig("name"))
	assert.False(t, InConfig("state"))
	assert.Equal(t, "steve", Get("name"))
	assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, Get("hobbies"))
	assert.Equal(t, map[interface{}]interface{}{"jacket": "leather", "trousers": "denim"}, Get("clothing"))
	assert.Equal(t, 35, Get("age"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:12,代码来源:viper_test.go

示例15: TestReadBufConfig

func TestReadBufConfig(t *testing.T) {
	v := New()
	v.SetConfigType("yaml")
	v.ReadConfig(bytes.NewBuffer(yamlExample))
	t.Log(v.AllKeys())

	assert.True(t, v.InConfig("name"))
	assert.False(t, v.InConfig("state"))
	assert.Equal(t, "steve", v.Get("name"))
	assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, v.Get("hobbies"))
	assert.Equal(t, map[interface{}]interface{}{"jacket": "leather", "trousers": "denim"}, v.Get("clothing"))
	assert.Equal(t, 35, v.Get("age"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:13,代码来源:viper_test.go


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