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

Golang assert.Equal函数代码示例

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

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



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

示例1: TestEndpointsOpen

func TestEndpointsOpen(t *testing.T) {
	assert := assert.Assert(t)

	var yml string
	var setting *kasi_conf.CoreSetting
	var err error

	yml = loadFile("config_simple_endpoint0.yml")
	setting, err = kasi.ParseConfig(yml)
	assert.Nil(err)
	assert.Equal(len(setting.Services[0].Endpoints), 1)

	yml = loadFile("config_opened_endpoint.yml")
	setting, err = kasi.ParseConfig(yml)
	assert.Nil(err)
	assert.Equal(len(setting.Services[0].Endpoints), 1)

	yml = loadFile("config_closed_endpoint.yml")

	setting, err = kasi.ParseConfig(yml)
	assert.Nil(err)

	assert.False(setting.Services[0].Opened(), "")
	assert.Equal(len(setting.Services[0].Endpoints), 0)
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:25,代码来源:conf_endpoint_test.go


示例2: TestJoinURL

func TestJoinURL(t *testing.T) {
	assert := assert.Assert(t)

	var base, target string

	// 2 FQDN url
	base = "http://a0.com/b0/c0.html"
	target = "http://a1.com/b1/c1.html"
	assert.Equal(joinURL(base, target), target)

	// 1 FQDN and 1 path
	base = "http://a0.com/b0/c0.html"
	target = "/b1/c1.html"
	assert.Equal(joinURL(base, target), "http://a0.com"+target)

	// 1 invalid url and 1 valid url
	base = "****************\\*"
	target = "/b1/c1.html"
	assert.Equal(joinURL(base, target), target)

	// 2 path, but one is relative
	base = "/b0/c0.html"
	target = "b1/c1.html"
	assert.Equal(joinURL(base, target), base+"/"+target)

	// merge querystring
	base = "/b0/c0.html?a=1&b=2"
	target = "b1/c1.html?a=3"
	assert.Equal(joinURL(base, target), "/b0/c0.html/b1/c1.html?a=3&b=2")
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:30,代码来源:util_test.go


示例3: TestHostnamesInheritFromDefault

func TestHostnamesInheritFromDefault(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("config_hostnames_inherit_from_default.yml")
	setting, err := kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	assert.Equal(len(setting.Services), 1)
	assert.Equal(len(setting.Services[0].Hostnames), 2)

	for _, h := range []string{"my0.github.com", "my1.github.com"} {
		if sort.SearchStrings(setting.Services[0].Hostnames, h) == 2 {
			t.Error("failed to parse hostnames")
		}
	}

	ymlOverride := loadFile("config_hostnames_override_default.yml")
	setting, err = kasi.ParseConfig(ymlOverride)
	assert.Nil(err)

	assert.Equal(len(setting.Services), 1)
	assert.Equal(len(setting.Services[0].Hostnames), 1)

	for _, h := range []string{"my2.github.com"} {
		if sort.SearchStrings(setting.Services[0].Hostnames, h) == 2 {
			t.Error("failed to parse hostnames")
		}
	}
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:29,代码来源:conf_hostnames_test.go


示例4: TestServices

func TestServices(t *testing.T) {
	assert := assert.Assert(t)
	services := new(Services)
	assert.Equal(len(services.Services), 0)

	// Addition
	services.Add(Service{Name: "google.com", Password: "asdf1234", Meta: "Personal"})
	assert.Equal(len(services.Services), 1)
	assert.Equal(services.Services[0].Name, "google.com")

	// replacement
	services.Add(Service{Name: "google.com", Password: "lkjpoiu"})
	assert.Equal(len(services.Services), 1)
	assert.Equal(services.Services[0].Password, "lkjpoiu")

	// Addition
	services.Add(Service{Name: "facebook.com", Password: "1234"})
	assert.Equal(len(services.Services), 2)

	// another replacement
	services.Add(Service{Name: "google.com", Password: "asghasd"})
	assert.Equal(services.Get("google.com").Password, "asghasd")
	assert.Equal(len(services.Services), 2)

	services.Add(Service{Name: "golang.org"})
	goServices := services.Search("go")
	assert.Equal(len(goServices), 2)
	assert.True(goServices[0].Name[:2] == "go", "Service 0 begins with go")
	assert.True(goServices[1].Name[:2] == "go", "Service 1 begins with go")
	assert.Equal(len(services.Search("*")), 3)
}
开发者ID:seanpont,项目名称:passman,代码行数:31,代码来源:passman_test.go


示例5: TestPasswordGenerationWithWords

func TestPasswordGenerationWithWords(t *testing.T) {
	assert := assert.Assert(t)
	generator := NewPasswordGenerator("w24")
	assert.Equal(generator.length, 24)
	assert.Equal(generator.words, true)
	password := generator.generate()
	assert.True(len(password) >= 24, "length")
}
开发者ID:seanpont,项目名称:passman,代码行数:8,代码来源:passman_test.go


示例6: TestBoard_turn_switches_after_each_play

func TestBoard_turn_switches_after_each_play(t *testing.T) {
	assert := assert.Assert(t)
	g := NewGame()
	assert.Equal(g.Turn(), byte(1))
	g.Play(1)
	assert.Equal(g.Turn(), byte(2))
	g.Play(1)
	assert.Equal(g.Turn(), byte(1))
}
开发者ID:seanpont,项目名称:connect4,代码行数:9,代码来源:game_test.go


示例7: Test_HasWonUtilityFunction_returns_1_when_won

func Test_HasWonUtilityFunction_returns_1_when_won(t *testing.T) {
	assert := assert.Assert(t)
	game := NewGame()
	wrapper := GameWrapper{game}
	game.SetRows("1110000")
	assert.Equal(HasWon(wrapper), 0)
	hasWon, _ := game.Play(4) // now it's player 2's turn, but 1 won
	assert.True(hasWon, "should have won")
	assert.Equal(HasWon(wrapper), 1)
}
开发者ID:seanpont,项目名称:connect4,代码行数:10,代码来源:solver_test.go


示例8: Test_Copy

func Test_Copy(t *testing.T) {
	assert := assert.Assert(t)
	g := NewGame()
	g.SetRows("1212000")
	g1 := g.Copy()
	g1.Play(5)
	assert.Equal(g.turn, p1)
	assert.Equal(g1.turn, p2)
	assert.Equal(g.board[0], []byte{1, 2, 1, 2, 0, 0, 0})
	assert.Equal(g1.board[0], []byte{1, 2, 1, 2, 1, 0, 0})
}
开发者ID:seanpont,项目名称:connect4,代码行数:11,代码来源:game_test.go


示例9: TestHostnamesWithString

func TestHostnamesWithString(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("config_hostnames_string.yml")
	setting, err := kasi.ParseConfig(yml)
	assert.Nil(err)

	assert.Equal(len(setting.Services), 1)
	assert.Equal(len(setting.Services[0].Hostnames), 1)
	assert.Equal(setting.Services[0].Hostnames[0], "my0.github.com")
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:11,代码来源:conf_hostnames_test.go


示例10: TestPasswordGeneration

func TestPasswordGeneration(t *testing.T) {
	assert := assert.Assert(t)
	generator := NewPasswordGenerator("lunc20")
	assert.Equal(generator.length, 20)
	password := generator.generate()
	assert.Equal(len(password), 20)
	assert.True(strings.ContainsAny(password, LOWERCASE), "missing characters")
	assert.True(strings.ContainsAny(password, UPPERCASE), "missing characters")
	assert.True(strings.ContainsAny(password, NUMBERS), "missing characters")
	assert.True(strings.ContainsAny(password, CHARACTERS), "missing characters")
}
开发者ID:seanpont,项目名称:passman,代码行数:11,代码来源:passman_test.go


示例11: TestMinimax

func TestMinimax(t *testing.T) {
	assert := assert.Assert(t)
	//                     p1   [--p2--]  [------p1------]
	game := NewHeapGame(0, 0, 1, 0, 1, -1, 0, 0, 1, -1, 0, 1, 2, 0, 1)
	fmt.Println(game.utility)
	// best move: 1
	solver := &Solver{HeapUtilityFunction, 2}
	move, utility := solver.Solve(game)
	moveInt := move.(int)
	assert.Equal(moveInt, 1)
	assert.Equal(utility, 1)
}
开发者ID:seanpont,项目名称:connect4,代码行数:12,代码来源:minimax_test.go


示例12: Test_LegalMoves

func Test_LegalMoves(t *testing.T) {
	assert := assert.Assert(t)
	g := NewGame()
	assert.Equal(g.LegalMoves(),
		[]int{1, 2, 3, 4, 5, 6, 7})

	for row := 0; row < ROWS/2; row++ {
		g.Play(1)
		g.Play(1)
		g.Play(4)
		g.Play(4)
	}
	assert.Equal(g.LegalMoves(),
		[]int{2, 3, 5, 6, 7})
}
开发者ID:seanpont,项目名称:connect4,代码行数:15,代码来源:game_test.go


示例13: TestID

func TestID(t *testing.T) {
	assert := assert.Assert(t)

	var yml string
	var setting *kasi_conf.CoreSetting
	var err error

	yml = loadFile("config_check_id.yml")
	setting, err = kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	assert.Equal(setting.Services[0].GetID(), "this-is-service-id")
	assert.Equal(setting.Services[0].Endpoints[0].GetID(), "findme")
	assert.Equal(len(setting.Services[0].Endpoints[1].GetID()), 36)
	assert.Equal(setting.Services[0].Endpoints[1].GetID(), setting.Services[0].Endpoints[1].GetID())
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:16,代码来源:conf_id_test.go


示例14: TestHostnamesWithStrings

func TestHostnamesWithStrings(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("config_hostnames_strings.yml")
	setting, err := kasi.ParseConfig(yml)
	assert.Nil(err)

	assert.Equal(len(setting.Services), 1)
	assert.Equal(len(setting.Services[0].Hostnames), 2)

	for _, h := range []string{"my0.github.com", "my1.github.com"} {
		if sort.SearchStrings(setting.Services[0].Hostnames, h) == 2 {
			t.Error("failed to parse hostnames")
		}
	}
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:16,代码来源:conf_hostnames_test.go


示例15: TestParseTimeUnit

func TestParseTimeUnit(t *testing.T) {
	assert := assert.Assert(t)

	cases := []struct {
		in   string
		want time.Duration
	}{
		{"10", time.Nanosecond * 10},
		{"100000", time.Nanosecond * 100 * 1000},
		{"1s", time.Second * 1},
		{"2s", time.Second * 2},
		{"3m", time.Minute * 3},
		{"4h", time.Hour * 4},
		{"5d", time.Hour * 24 * 5},
		{"6M", time.Hour * 24 * 30 * 6},
		{"7y", time.Hour * 24 * 365 * 7},
	}
	for _, c := range cases {
		assert.Equal(
			func() time.Duration {
				p, err := parseTimeUnit(c.in)
				assert.Nil(err)
				return p
			}(),
			c.want,
		)
	}
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:28,代码来源:util_test.go


示例16: TestBindInheritFromDefault

func TestBindInheritFromDefault(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("conf_default_bind.yml")

	setting, err := kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	cases := map[string]*net.TCPAddr{
		"a.com": setting.GetDefaultSetting().Bind,
		"b.com": &net.TCPAddr{Port: 90},
	}

	for _, service := range setting.Services {
		assert.Equal(cases[service.Hostnames[0]], service.Bind)
	}
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:17,代码来源:conf_bind_test.go


示例17: TestTimeout

func TestTimeout(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("config_timeout.yml")
	setting, err := kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	cases := map[string]time.Duration{
		"a.com": time.Second * 9,
		"b.com": time.Second * 0,
		"c.com": setting.GetDefaultSetting().Timeout,
		"d.com": setting.GetDefaultSetting().Timeout,
	}

	for _, service := range setting.Services {
		assert.Equal(service.Timeout, cases[service.Hostnames[0]])
	}
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:18,代码来源:conf_timeout_test.go


示例18: TestEnv

func TestEnv(t *testing.T) {
	assert := assert.Assert(t)

	yml := loadFile("config_env.yml")
	setting, err := kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	assert.NotEqual(setting.Env.Hostname, "")
	assert.NotEqual(setting.Env.GOOS, "")
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:10,代码来源:conf_env_test.go


示例19: TestEndpoints

func TestEndpoints(t *testing.T) {
	assert := assert.Assert(t)

	var yml string
	var setting *kasi_conf.CoreSetting
	var err error

	yml = loadFile("config_simple_endpoint0.yml")

	setting, err = kasi.ParseConfig(yml)
	assert.Nil(err)
	assert.Equal(len(setting.Services[0].Endpoints), 1)

	yml = loadFile("config_simple_endpoint1.yml")

	setting, err = kasi.ParseConfig(yml)
	assert.Nil(err)
	assert.Equal(len(setting.Services[0].Endpoints), 2)
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:19,代码来源:conf_endpoint_test.go


示例20: TestGetEndpointByID

func TestGetEndpointByID(t *testing.T) {
	assert := assert.Assert(t)

	var yml string
	var setting *kasi_conf.CoreSetting
	var endpointSetting *kasi_conf.EndpointSetting
	var err error

	yml = loadFile("config_check_id.yml")
	setting, err = kasi.ParseConfig(yml)
	assert.Equal(err, nil)

	endpointSetting, err = setting.GetEndpointByID("findme")
	assert.Equal(endpointSetting, setting.Services[0].Endpoints[0])

	endpointSettingToFind := setting.Services[0].Endpoints[1]
	endpointSetting, err = setting.GetEndpointByID(endpointSettingToFind.GetID())
	assert.Equal(endpointSettingToFind, endpointSetting)
}
开发者ID:haiheipijuan,项目名称:kasi,代码行数:19,代码来源:conf_id_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang libseccomp-golang.GetNativeArch函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.Assert函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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