Created
December 12, 2011 22:12
-
-
Save kortschak/1469375 to your computer and use it in GitHub Desktop.
test the gocheck.Panics checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include $(GOROOT)/src/Make.inc | |
TARG=testtest | |
GOFILES=\ | |
test.go\ | |
include $(GOROOT)/src/Make.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package panictest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package panictest | |
import ( | |
"errors" | |
check "launchpad.net/gocheck" | |
"testing" | |
) | |
func Test(t *testing.T) { check.TestingT(t) } | |
type S struct{} | |
var _ = check.Suite(&S{}) | |
type Runtime struct { | |
error | |
} | |
func (r Runtime) RuntimeError() {} | |
type A struct { | |
field int | |
} | |
func (a *A) Get() int { return a.field } | |
func (s *S) TestPanicRuntimeNil(c *check.C) { | |
var a *A | |
c.Check(a.Get(), check.Panics, Runtime{errors.New("runtime error: invalid memory address or nil pointer dereference")}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment