Skip to content

Instantly share code, notes, and snippets.

@kortschak
Created December 12, 2011 22:12
Show Gist options
  • Save kortschak/1469375 to your computer and use it in GitHub Desktop.
Save kortschak/1469375 to your computer and use it in GitHub Desktop.
test the gocheck.Panics checker
include $(GOROOT)/src/Make.inc
TARG=testtest
GOFILES=\
test.go\
include $(GOROOT)/src/Make.pkg
package panictest
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