Debian Codegraph @

test_cases/panicking.test.go

raw symbols SCIP
1 // Copyright 2011 Aaron Jacobs. All Rights Reserved.
2 // Author: [email protected] (Aaron Jacobs)
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 package oglematchers_test
17
18 import (
19 "fmt"
20 "log"
21 "testing"
22
23 . "github.com/jacobsa/oglematchers"
24 . "github.com/jacobsa/ogletest"
25 )
26
27 func TestPanickingTest(t *testing.T) { RunTests(t) }
28
29 ////////////////////////////////////////////////////////////////////////
30 // PanickingTest
31 ////////////////////////////////////////////////////////////////////////
32
33 func someFuncThatPanics() {
34 panic("Panic in someFuncThatPanics")
35 }
36
37 type PanickingTest struct {
38 }
39
40 func init() { RegisterTestSuite(&PanickingTest{}) }
41
42 func (t *PanickingTest) TearDown() {
43 fmt.Println("TearDown running.")
44 }
45
46 func (t *PanickingTest) ExplicitPanic() {
47 panic("Panic in ExplicitPanic")
48 }
49
50 func (t *PanickingTest) ExplicitPanicInHelperFunction() {
51 someFuncThatPanics()
52 }
53
54 func (t *PanickingTest) NilPointerDerefence() {
55 var p *int
56 log.Println(*p)
57 }
58
59 func (t *PanickingTest) ZzzSomeOtherTest() {
60 ExpectThat(17, Equals(17.0))
61 }
62
63 ////////////////////////////////////////////////////////////////////////
64 // SetUpPanicTest
65 ////////////////////////////////////////////////////////////////////////
66
67 type SetUpPanicTest struct {
68 }
69
70 func init() { RegisterTestSuite(&SetUpPanicTest{}) }
71
72 func (t *SetUpPanicTest) SetUp(ti *TestInfo) {
73 fmt.Println("SetUp about to panic.")
74 panic("Panic in SetUp")
75 }
76
77 func (t *SetUpPanicTest) TearDown() {
78 fmt.Println("TearDown running.")
79 }
80
81 func (t *SetUpPanicTest) SomeTestCase() {
82 }
83
84 ////////////////////////////////////////////////////////////////////////
85 // TearDownPanicTest
86 ////////////////////////////////////////////////////////////////////////
87
88 type TearDownPanicTest struct {
89 }
90
91 func init() { RegisterTestSuite(&TearDownPanicTest{}) }
92
93 func (t *TearDownPanicTest) TearDown() {
94 fmt.Println("TearDown about to panic.")
95 panic("Panic in TearDown")
96 }
97
98 func (t *TearDownPanicTest) SomeTestCase() {
99 }