MCPcopy
hub / github.com/stretchr/testify / checkResultAndErrMsg

Method checkResultAndErrMsg

assert/assertions_test.go:3665–3695  ·  assert/assertions_test.go::captureTestingT.checkResultAndErrMsg
(t *testing.T, expectedRes, res bool, expectedErrMsg string)

Source from the content-addressed store, hash-verified

3663}
3664
3665func (ctt *captureTestingT) checkResultAndErrMsg(t *testing.T, expectedRes, res bool, expectedErrMsg string) {
3666 t.Helper()
3667 if res != expectedRes {
3668 t.Errorf("Should return %t", expectedRes)
3669 return
3670 }
3671 if res == ctt.failed {
3672 t.Errorf("The test result (%t) should be reflected in the testing.T type (%t)", res, !ctt.failed)
3673 return
3674 }
3675 contents := parseLabeledOutput(ctt.msg)
3676 if res == true {
3677 if contents != nil {
3678 t.Errorf("Should not log an error. Log output: %q", ctt.msg)
3679 }
3680 return
3681 }
3682 if contents == nil {
3683 t.Errorf("Should log an error. Log output: %q", ctt.msg)
3684 return
3685 }
3686 for _, content := range contents {
3687 if content.label == "Error" {
3688 if expectedErrMsg == content.content {
3689 return
3690 }
3691 t.Errorf("Recorded Error: %q", content.content)
3692 }
3693 }
3694 t.Errorf("Expected Error: %q", expectedErrMsg)
3695}
3696
3697func TestErrorIs(t *testing.T) {
3698 t.Parallel()

Callers 6

TestEmptyFunction · 0.80
TestNotEmptyFunction · 0.80
TestErrorIsFunction · 0.80
TestNotErrorIsFunction · 0.80
TestErrorAsFunction · 0.80
TestNotErrorAsFunction · 0.80

Calls 3

parseLabeledOutputFunction · 0.85
HelperMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected