• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang assert.Equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TestRegister

func TestRegister(t *testing.T) {
	c.nick = "nick"
	c.Username = "user"
	c.Realname = "rn"
	c.register()
	assert.Equal(t, "NICK nick\r\n", <-conn.hook)
	assert.Equal(t, "USER user 0 * :rn\r\n", <-conn.hook)

	c.Password = "pass"
	c.register()
	assert.Equal(t, "PASS pass\r\n", <-conn.hook)
	assert.Equal(t, "NICK nick\r\n", <-conn.hook)
	assert.Equal(t, "USER user 0 * :rn\r\n", <-conn.hook)
}
开发者ID:postfix,项目名称:name_pending,代码行数:14,代码来源:client_test.go


示例17: TestRemotePrecedence

func TestRemotePrecedence(t *testing.T) {
	initJSON()

	remote := bytes.NewReader(remoteExample)
	assert.Equal(t, "0001", Get("id"))
	marshalReader(remote, v.kvstore)
	assert.Equal(t, "0001", Get("id"))
	assert.NotEqual(t, "cronut", Get("type"))
	assert.Equal(t, "remote", Get("newkey"))
	Set("newkey", "newvalue")
	assert.NotEqual(t, "remote", Get("newkey"))
	assert.Equal(t, "newvalue", Get("newkey"))
	Set("newkey", "remote")
}
开发者ID:postfix,项目名称:name_pending,代码行数:14,代码来源:viper_test.go


示例18: TestRecv

func TestRecv(t *testing.T) {
	buf := &bytes.Buffer{}
	buf.WriteString("CMD\r\n")
	buf.WriteString("PING :test\r\n")
	buf.WriteString("001\r\n")
	c.reader = bufio.NewReader(buf)

	c.ready.Add(1)
	close(c.quit)
	go c.recv()

	assert.Equal(t, "PONG :test\r\n", <-conn.hook)
	assert.Equal(t, &Message{Command: "CMD"}, <-c.Messages)
	initTestClient()
}
开发者ID:postfix,项目名称:name_pending,代码行数:15,代码来源:conn_test.go


示例19: TestAllKeys

func TestAllKeys(t *testing.T) {
	initConfigs()

	ks := sort.StringSlice{"title", "newkey", "owner", "name", "beard", "ppu", "batters", "hobbies", "clothing", "age", "hacker", "id", "type", "eyes", "p_id", "p_ppu", "p_batters.batter.type", "p_type", "p_name"}
	dob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z")
	all := map[string]interface{}{"owner": map[string]interface{}{"organization": "MongoDB", "Bio": "MongoDB Chief Developer Advocate & Hacker at Large", "dob": dob}, "title": "TOML Example", "ppu": 0.55, "eyes": "brown", "clothing": map[interface{}]interface{}{"trousers": "denim", "jacket": "leather"}, "id": "0001", "batters": map[string]interface{}{"batter": []interface{}{map[string]interface{}{"type": "Regular"}, map[string]interface{}{"type": "Chocolate"}, map[string]interface{}{"type": "Blueberry"}, map[string]interface{}{"type": "Devil's Food"}}}, "hacker": true, "beard": true, "hobbies": []interface{}{"skateboarding", "snowboarding", "go"}, "age": 35, "type": "donut", "newkey": "remote", "name": "Cake", "p_id": "0001", "p_ppu": "0.55", "p_name": "Cake", "p_batters.batter.type": "Regular", "p_type": "donut"}

	var allkeys sort.StringSlice
	allkeys = AllKeys()
	allkeys.Sort()
	ks.Sort()

	assert.Equal(t, ks, allkeys)
	assert.Equal(t, all, AllSettings())
}
开发者ID:postfix,项目名称:name_pending,代码行数:15,代码来源:viper_test.go


示例20: TestAutoEnv

func TestAutoEnv(t *testing.T) {
	Reset()

	AutomaticEnv()
	os.Setenv("FOO_BAR", "13")
	assert.Equal(t, "13", Get("foo_bar"))
}
开发者ID:postfix,项目名称:name_pending,代码行数:7,代码来源:viper_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang errors.UnsupportedError函数代码示例发布时间:2022-05-23
下一篇:
Golang bolt.DB类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap