本文整理汇总了Golang中github.com/GlenKelley/battleref/testing.T.ErrorNowf方法的典型用法代码示例。如果您正苦于以下问题:Golang T.ErrorNowf方法的具体用法?Golang T.ErrorNowf怎么用?Golang T.ErrorNowf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/GlenKelley/battleref/testing.T
的用法示例。
在下文中一共展示了T.ErrorNowf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPush
func TestPush(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, host *LocalDirHost) {
t.CheckError(host.InitRepository("foo", nil, nil))
repoURL := host.RepositoryURL("foo")
var head string
if repo, err := (TempRemote{}).CheckoutRepository(repoURL); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
t.CheckError(ioutil.WriteFile(filepath.Join(repo.Dir(), "foo.txt"), []byte("hello"), os.ModePerm))
t.CheckError(repo.AddFiles([]string{"foo.txt"}))
t.CheckError(repo.CommitFiles([]string{"foo.txt"}, "commit message"))
t.CheckError(repo.Push())
if h, err := repo.Head(); err != nil {
t.ErrorNow(err)
} else {
head = h
}
}
if repo, err := (TempRemote{}).CheckoutRepository(repoURL); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
if head2, err := repo.Head(); err != nil {
t.ErrorNow(err)
} else if head != head2 {
t.ErrorNowf("Expected <%v> != Actual <%v>", head, head2)
}
}
})
}
示例2: TestInitLocalRepo
func TestInitLocalRepo(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, local *LocalDirHost) {
t.CheckError(local.InitRepository("foo", nil, nil))
repoURL := local.RepositoryURL("foo")
if stat, err := os.Stat(repoURL); err != nil {
t.ErrorNow(err)
} else if !stat.IsDir() {
t.ErrorNowf("%s is not a directory", repoURL)
} else {
CheckDirectoryContent(t, repoURL, []string{"HEAD", "branches", "config", "description", "hooks", "info", "objects", "refs"})
}
})
}
示例3: TestListCategories
func TestListCategories(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
categories := tm.ListCategories()
if len(categories) != 3 {
t.ErrorNowf("expected 3 category, got %v", len(categories))
}
as := []string{}
bs := []string{string(CategoryBattlecode2014), string(CategoryBattlecode2015), string(CategoryBattlecode2016)}
for _, category := range categories {
as = append(as, string(category))
}
t.CompareStringsUnsorted(as, bs)
})
}
示例4: TestRunMatch
func TestRunMatch(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
p1 := Submission{"p1", "c1"}
p2 := Submission{"p2", "c2"}
t.CheckError(tm.CreateMap("MapFoo", "SourceFoo", CategoryTest))
if id, result, err := tm.RunMatch(CategoryTest, "MapFoo", p1, p2, SystemClock()); err != nil {
t.ErrorNow(err)
} else if result != "WinA" {
t.ErrorNowf("Expected WinA not %v\n", result)
} else if result2, err := tm.GetMatchResult(id); err != nil {
t.ErrorNow(err)
} else if result != result2 {
t.ErrorNowf("Expected %v not %v\n", result, result2)
} else if matches, err := tm.ListMatches(CategoryTest); err != nil {
t.ErrorNow(err)
} else if len(matches) != 1 {
t.ErrorNowf("Expected 1 match not %v\n", len(matches))
} else if matches[0].Result != result {
t.ErrorNowf("Expected %v not %v\n", result, matches[0].Result)
}
})
}