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


Golang T.ErrorNowf方法代码示例

本文整理汇总了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)
			}
		}

	})
}
开发者ID:GlenKelley,项目名称:battleref,代码行数:32,代码来源:repo_test.go

示例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"})
		}
	})
}
开发者ID:GlenKelley,项目名称:battleref,代码行数:13,代码来源:host_test.go

示例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)
	})
}
开发者ID:GlenKelley,项目名称:battleref,代码行数:14,代码来源:tournament_test.go

示例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)
		}
	})
}
开发者ID:GlenKelley,项目名称:battleref,代码行数:22,代码来源:tournament_test.go


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