本文整理汇总了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")
}
示例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)
}
示例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)
}
示例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())
}
示例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())
}
示例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()")
}
示例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)
}
示例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)
}
示例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")))
}
示例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)
}
示例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")
}
示例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)
}
示例13: TestSuccess
func TestSuccess(t *testing.T) {
value := 5
result := NewSuccess(value)
assert.Equal(t, result.Success, value)
assert.Nil(t, result.Failure)
}
示例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)
}
示例15: TestDematerializeWithSuccess
func TestDematerializeWithSuccess(t *testing.T) {
result := NewSuccess(5)
value, err := result.Dematerialize()
assert.Equal(t, value, 5)
assert.Nil(t, err)
}