panic_test.go 692 B

12345678910111213141516171819202122232425262728293031323334
  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. package test
  5. import (
  6. "testing"
  7. )
  8. func TestShouldPanic(t *testing.T) {
  9. fn := func() { panic("Here we are") }
  10. ShouldPanic(t, fn)
  11. }
  12. func TestShouldPanicWithString(t *testing.T) {
  13. fn := func() { panic("Here we are") }
  14. ShouldPanicWith(t, "Here we are", fn)
  15. }
  16. func TestShouldPanicWithInt(t *testing.T) {
  17. fn := func() { panic(42) }
  18. ShouldPanicWith(t, 42, fn)
  19. }
  20. func TestShouldPanicWithStruct(t *testing.T) {
  21. fn := func() { panic(struct{ foo string }{foo: "panic"}) }
  22. ShouldPanicWith(t, struct{ foo string }{foo: "panic"}, fn)
  23. }