github.com/psiphon-inc/goarista@v0.0.0-20160825065156-d002785f4c67/test/panic_test.go (about)

     1  // Copyright (C) 2015  Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  package test
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestShouldPanic(t *testing.T) {
    12  	fn := func() { panic("Here we are") }
    13  
    14  	ShouldPanic(t, fn)
    15  }
    16  
    17  func TestShouldPanicWithString(t *testing.T) {
    18  	fn := func() { panic("Here we are") }
    19  
    20  	ShouldPanicWith(t, "Here we are", fn)
    21  }
    22  
    23  func TestShouldPanicWithInt(t *testing.T) {
    24  	fn := func() { panic(42) }
    25  
    26  	ShouldPanicWith(t, 42, fn)
    27  }
    28  
    29  func TestShouldPanicWithStruct(t *testing.T) {
    30  	fn := func() { panic(struct{ foo string }{foo: "panic"}) }
    31  
    32  	ShouldPanicWith(t, struct{ foo string }{foo: "panic"}, fn)
    33  }