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


Golang assert.Nil函数代码示例

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


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


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