當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.Error方法代碼示例

本文整理匯總了Golang中github.com/dvln/check.C.Error方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Error方法的具體用法?Golang C.Error怎麽用?Golang C.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/dvln/check.C的用法示例。


在下文中一共展示了C.Error方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestSkip

func (s *FoundationS) TestSkip(c *check.C) {
	helper := SkipTestHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})

	if output.value != "" {
		c.Error("Skip() logged something:\n", output.value)
	}
}
開發者ID:dvln,項目名稱:check,代碼行數:9,代碼來源:foundation_test.go

示例2: TestError

func (s *FoundationS) TestError(c *check.C) {
	expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
		"    c\\.Error\\(\"Error \", \"message!\"\\)\n"+
		"\\.\\.\\. Error: Error message!\n\n",
		getMyLine()+1)
	c.Error("Error ", "message!")
	checkState(c, nil,
		&expectedState{
			name:   "Error(`Error `, `message!`)",
			failed: true,
			log:    expectedLog,
		})
}
開發者ID:dvln,項目名稱:check,代碼行數:13,代碼來源:foundation_test.go

示例3: TestSucceedNow

func (s *FoundationS) TestSucceedNow(c *check.C) {
	defer (func() {
		if c.Failed() {
			c.Error("SucceedNow() didn't succeed the test")
		}
		if c.GetTestLog() != "" {
			c.Error("Something got logged:\n" + c.GetTestLog())
		}
	})()

	c.Fail()
	c.SucceedNow()
	c.Log("SucceedNow() didn't stop the test")
}
開發者ID:dvln,項目名稱:check,代碼行數:14,代碼來源:foundation_test.go

示例4: TestSkipVerbose

func (s *FoundationS) TestSkipVerbose(c *check.C) {
	helper := SkipTestHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})

	expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
		" \\(Wrong platform or whatever\\)"
	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("Skip() didn't log properly:\n", output.value)
	}
}
開發者ID:dvln,項目名稱:check,代碼行數:14,代碼來源:foundation_test.go

示例5: TestExpectFailureSucceedVerbose

func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) {
	helper := ExpectFailureSucceedHelper{}
	output := String{}
	result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})

	expected := "" +
		"FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, check.Equals, 1)
}
開發者ID:dvln,項目名稱:check,代碼行數:18,代碼來源:foundation_test.go

示例6: TestExpectFailureFail

func (s *FoundationS) TestExpectFailureFail(c *check.C) {
	helper := ExpectFailureFailHelper{}
	output := String{}
	result := check.Run(&helper, &check.RunConf{Output: &output})

	expected := "" +
		"^\n-+\n" +
		"FAIL: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureFailHelper\\.TestFail\n\n" +
		"\\.\\.\\. Error: Test succeeded, but was expected to fail\n" +
		"\\.\\.\\. Reason: Bug #XYZ\n$"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, check.Equals, 0)
}
開發者ID:dvln,項目名稱:check,代碼行數:21,代碼來源:foundation_test.go

示例7: TestFatalf

func (s *FoundationS) TestFatalf(c *check.C) {
	var line int
	defer (func() {
		if !c.Failed() {
			c.Error("Fatalf() didn't fail the test")
		} else {
			c.Succeed()
			expected := fmt.Sprintf("foundation_test.go:%d:\n"+
				"    c.Fatalf(\"Die %%s!\", \"now\")\n"+
				"... Error: Die now!\n\n",
				line)
			if c.GetTestLog() != expected {
				c.Error("Incorrect log:", c.GetTestLog())
			}
		}
	})()

	line = getMyLine() + 1
	c.Fatalf("Die %s!", "now")
	c.Log("Fatalf() didn't stop the test")
}
開發者ID:dvln,項目名稱:check,代碼行數:21,代碼來源:foundation_test.go

示例8: TestMethod

func (s *EmbeddedInternalS) TestMethod(c *check.C) {
	c.Error("TestMethod() of the embedded type was called!?")
}
開發者ID:dvln,項目名稱:check,代碼行數:3,代碼來源:foundation_test.go

示例9: TestFail

func (s *SkipTestHelper) TestFail(c *check.C) {
	c.Skip("Wrong platform or whatever")
	c.Error("Boom!")
}
開發者ID:dvln,項目名稱:check,代碼行數:4,代碼來源:foundation_test.go

示例10: TestSucceed

func (s *ExpectFailureSucceedHelper) TestSucceed(c *check.C) {
	c.ExpectFailure("It booms!")
	c.Error("Boom!")
}
開發者ID:dvln,項目名稱:check,代碼行數:4,代碼來源:foundation_test.go


注:本文中的github.com/dvln/check.C.Error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。