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

Golang assert.Nil函数代码示例

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

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



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

示例1: TestGetGamesByIDS

func TestGetGamesByIDS(t *testing.T) {
	print("GetGamesByIDs\n")
	seedGame()
	user := gu(t)
	g, err := GetGame(1, user)
	assert.Nil(t, err, "GetGame(1,user)")
	g.EbayURL = "My Url"
	g.EbayEnds = "2017-06-22 20:41:25"
	g.EbayPrice = 4.32
	g.EbayUpdated = "2016-06-22 20:41:25"
	err = g.Save()
	assert.Nil(t, err, "g.Save()")

	idl := []int{1, 2, 3, 4, 5}
	gl, err := GetGamesByIDS(idl, user)
	assert.Nil(t, err, "GetGamesByIDS(idl,user)")
	assert.Equal(t, 2, len(gl), "len(gamelist)")
	g = gl[0]
	assert.Equal(t, 1, g.User.ID, "g.User.ID")
	assert.Equal(t, "game1", g.Name, "g.Name")
	assert.Equal(t, "Nintendo", g.Publisher, "g.Publisher")
	assert.Equal(t, 1990, g.Year, "g.Year")
	assert.Equal(t, true, g.Has, "g.Has")
	assert.Equal(t, true, g.HasBox, "g.HasBox")
	assert.Equal(t, true, g.HasManual, "g.HasManual")
	assert.Equal(t, 3, g.Rating, "g.Rating")
	assert.Equal(t, "is good", g.Review, "g.Review")
	assert.Equal(t, false, g.Want, "Want")
	assert.Equal(t, "2016-06-22 20:41:25", g.EbayUpdated, "g.EbayUpdated")
	assert.Equal(t, 4.32, g.EbayPrice, "g.EbayPrice")
	assert.Equal(t, "My Url", g.EbayURL, "g.EbayUrl")
	assert.Equal(t, "2017-06-22 20:41:25", g.EbayEnds, "g.EbayEnds")
}
开发者ID:ChrisKaufmann,项目名称:gameslist,代码行数:33,代码来源:game_test.go


示例2: TestConsole_CheapestGame

func TestConsole_CheapestGame(t *testing.T) {
	print("Console.CheapestGame\n")
	seedConsole()
	user, err := auth.GetUser(1)
	if err != nil {
		t.Errorf("GetUser(1): %s", err)
	}
	c, err := GetConsole("NES", user)
	assert.Nil(t, err, "GetConsole(NES,user)")
	c.WantGames = true
	c.Save()
	p := 1.01
	gl, err := c.WantedGames()
	fmt.Printf("len(wantedgames): %v\n", len(gl))
	assert.Nil(t, err, "c.Games()")
	for _, g := range gl {
		g.EbayPrice = p
		g.Want = true
		p = p + 1.01
		g.EbayEnds = "2999-01-01 01:00:00"
		err := g.Save()
		assert.Nil(t, err, "g.Save()")
	}

	d, err := GetConsole("NES", user)
	if err != nil {
		t.Errorf("GetConsole(NES,user): %s", err)
	}
	g := d.CheapestGame()
	assert.Equal(t, 1.01, g.EbayPrice, "EbayPrice")
	fmt.Printf("%s, %.2v\n", g.Name, g.EbayPrice)
}
开发者ID:ChrisKaufmann,项目名称:gameslist,代码行数:32,代码来源:console_test.go


示例3: TestNewCommentID

func TestNewCommentID(t *testing.T) {
	c, err := NewComment("This behavior is undocumented", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Nil(t, comment.ID)
}
开发者ID:git-comment,项目名称:git-comment,代码行数:7,代码来源:comment_test.go


示例4: TestEntry_ViewMode

func TestEntry_ViewMode(t *testing.T) {
	e := ef()
	assert.Equal(t, "default", e.ViewMode(), "initial entry.ViewMode")
	f, err := GetFeed(1)
	assert.Nil(t, err, "GetFeed(1)")
	f.ViewMode = "link"
	err = f.Save()
	assert.Nil(t, err)
	assert.Equal(t, "link", e.ViewMode())
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:entry_test.go


示例5: TestEntry_AutoscrollPX

func TestEntry_AutoscrollPX(t *testing.T) {
	e := ef()
	assert.Equal(t, 0, e.AutoscrollPX())
	f, err := GetFeed(1)
	assert.Nil(t, err)
	f.AutoscrollPX = 1234
	err = f.Save()
	assert.Nil(t, err)
	assert.Equal(t, 1234, e.AutoscrollPX())
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:10,代码来源:entry_test.go


示例6: TestGetAllWantedGames

func TestGetAllWantedGames(t *testing.T) {
	print("GetAllWantedGames\n")
	seedGame()
	user := gu(t)
	c, err := GetConsole("Atari 2600", user)
	assert.Nil(t, err, "GetConsole(Atari 2600,user)")
	c2, err := GetConsole("NES", user)
	assert.Nil(t, err, "GetConsole(NES,user)")
	print("\tInitial\n")
	wg, err := GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 0, len(wg), "GetAllWantedGames")

	print("\tMarking individual games\n")
	g, err := GetGame(1, user)
	assert.Nil(t, err, "GetGame(1,user)")
	g.Want = true
	err = g.Save()
	assert.Nil(t, err, "g.Save()")
	wg, err = GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 1, len(wg), "GetAllWantedGames()")

	print("\tMarking Console WantGames\n")
	c.WantGames = true
	err = c.Save()
	assert.Nil(t, err, "c.Save()")
	c2.WantGames = true
	err = c2.Save()
	assert.Nil(t, err, "c2.Save()")
	wg, err = GetAllWantedGames()
	assert.Nil(t, err, "GetAllWantedGames()")
	assert.Equal(t, 1321, len(wg), "GetAllWantedGames()")

}
开发者ID:ChrisKaufmann,项目名称:gameslist,代码行数:35,代码来源:game_test.go


示例7: TestEntry_UnMark

func TestEntry_UnMark(t *testing.T) {
	e := ef()
	err := e.Mark()
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "1", e.Marked)
	err = e.UnMark()
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "0", e.Marked)
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:11,代码来源:entry_test.go


示例8: TestEntry_MarkUnread

func TestEntry_MarkUnread(t *testing.T) {
	e := ef()
	err := e.MarkRead()
	assert.Nil(t, err)
	e = ge()
	assert.False(t, e.Unread)
	err = e.MarkUnread()
	assert.Nil(t, err)
	e = ge()
	assert.True(t, e.Unread)
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:11,代码来源:entry_test.go


示例9: TestCategory_SearchTitles

func TestCategory_SearchTitles(t *testing.T) {
	seed()
	c1 := GetCat("1")
	assert.Equal(t, 2, len(c1.SearchTitles("asdf", "unread")))
	assert.Equal(t, 2, len(c1.SearchTitles("asdf", "all")))
	e1 := GetEntry("1", "test")
	err := e1.MarkRead()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(c1.SearchTitles("asdf", "read")))
	err = e1.Mark()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(c1.SearchTitles("asdf", "marked")))
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:13,代码来源:category_test.go


示例10: TestEntry_ToggleMark

func TestEntry_ToggleMark(t *testing.T) {
	e := ef()
	nm, err := e.ToggleMark()
	assert.Nil(t, err)
	assert.Equal(t, "set", nm)
	e = ge()
	assert.Equal(t, "1", e.Marked)
	assert.Nil(t, err)
	nm, err = e.ToggleMark()
	assert.Equal(t, "unset", nm)
	assert.Nil(t, err)
	e = ge()
	assert.Equal(t, "0", e.Marked)
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:14,代码来源:entry_test.go


示例11: TestGetGamesByConsole

func TestGetGamesByConsole(t *testing.T) {
	print("GetGamesByConsole\n")
	c := gsc(t)
	gl, err := GetGamesByConsole(c)
	assert.Nil(t, err, "GetGamesByConsole()")
	assert.Equal(t, 801, len(gl), "GetGamesByConsole")
}
开发者ID:ChrisKaufmann,项目名称:gameslist,代码行数:7,代码来源:game_test.go


示例12: TestFlatMapOnSuccessReturnsNewValue

func TestFlatMapOnSuccessReturnsNewValue(t *testing.T) {
  result := NewSuccess(5)
  resultantResult := result.FlatMap(func(value interface{}) Result { return NewSuccess(value.(int) * 2) })

  assert.Equal(t, resultantResult.Success, 10)
  assert.Nil(t, resultantResult.Failure)
}
开发者ID:kylef,项目名称:result.go,代码行数:7,代码来源:result_test.go


示例13: TestSuccess

func TestSuccess(t *testing.T) {
  value := 5
  result := NewSuccess(value)

  assert.Equal(t, result.Success, value)
  assert.Nil(t, result.Failure)
}
开发者ID:kylef,项目名称:result.go,代码行数:7,代码来源:result_test.go


示例14: TestCompareVersionsRepoCorrupted

func TestCompareVersionsRepoCorrupted(t *testing.T) {
	status, err := compareVersion("1.4.5", "2.0").Dematerialize()
	assert.NotNil(t, err)
	assert.True(t, strings.Contains(err.Error(), "1.4.5"))
	assert.True(t, strings.Contains(err.Error(), "2.0"))
	assert.Nil(t, status)
}
开发者ID:git-comment,项目名称:git-comment,代码行数:7,代码来源:version_test.go


示例15: TestDematerializeWithSuccess

func TestDematerializeWithSuccess(t *testing.T) {
  result := NewSuccess(5)
  value, err := result.Dematerialize()

  assert.Equal(t, value, 5)
  assert.Nil(t, err)
}
开发者ID:kylef,项目名称:result.go,代码行数:7,代码来源:result_test.go


示例16: TestAllMarkedEntries

func TestAllMarkedEntries(t *testing.T) {
	e := ef()
	assert.Equal(t, 0, len(AllMarkedEntries("test")))
	err := e.Mark()
	assert.Nil(t, err)
	assert.Equal(t, 1, len(AllMarkedEntries("test")))
}
开发者ID:ChrisKaufmann,项目名称:feedinator-go,代码行数:7,代码来源:entry_test.go


示例17: TestAllUsers

func TestAllUsers(t *testing.T) {
	initTest(t)
	print("AllUsers\n")
	ul, err := AllUsers()
	assert.Nil(t, err, "AllUsers()")
	assert.Equal(t, len(ul), 12, "len(AllUsers())")
}
开发者ID:ChrisKaufmann,项目名称:goauth,代码行数:7,代码来源:user_test.go


示例18: TestNewCommentContent

func TestNewCommentContent(t *testing.T) {
	c, err := NewComment("Season the chex mix", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, comment.Content, "Season the chex mix")
}
开发者ID:git-comment,项目名称:git-comment,代码行数:7,代码来源:comment_test.go


示例19: TestNewCommentDeleted

func TestNewCommentDeleted(t *testing.T) {
	c, err := NewComment("What is happening here?", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.False(t, comment.Deleted)
}
开发者ID:git-comment,项目名称:git-comment,代码行数:7,代码来源:comment_test.go


示例20: TestNewCommentCommit

func TestNewCommentCommit(t *testing.T) {
	c, err := NewComment("Wat?", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.Equal(t, *comment.Commit, "abcdefg")
}
开发者ID:git-comment,项目名称:git-comment,代码行数:7,代码来源:comment_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang fs.Filesystem类代码示例发布时间:2022-05-29
下一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-29
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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