-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrstack_test.go
More file actions
executable file
·118 lines (100 loc) · 2.38 KB
/
errstack_test.go
File metadata and controls
executable file
·118 lines (100 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package replify_test
import (
"fmt"
"strings"
"testing"
"github.com/sivaosorg/replify"
)
func TestStackTrace(t *testing.T) {
callers := replify.Callers()
trace := callers.StackTrace()
if len(trace) == 0 {
t.Errorf("Expected non-empty stack trace")
}
}
func TestFrameMarshalText(t *testing.T) {
callers := replify.Callers()
trace := callers.StackTrace()
for _, frame := range trace {
text, err := frame.MarshalText()
if err != nil {
t.Errorf("MarshalText returned an error: %v", err)
}
if len(text) == 0 {
t.Errorf("MarshalText returned empty text")
}
}
}
func TestFrameFormat(t *testing.T) {
callers := replify.Callers()
trace := callers.StackTrace()
for _, frame := range trace {
buffer := &strings.Builder{}
fmt.Fprintf(buffer, "%+v", frame)
if buffer.Len() == 0 {
t.Errorf("Formatted frame is empty")
}
}
}
func TestStackTraceFormat(t *testing.T) {
callers := replify.Callers()
trace := callers.StackTrace()
buffer := &strings.Builder{}
fmt.Fprintf(buffer, "%+v", trace)
if buffer.Len() == 0 {
t.Errorf("Formatted stack trace is empty")
}
}
func TestStackFormat(t *testing.T) {
callers := replify.Callers()
buffer := &strings.Builder{}
fmt.Fprintf(buffer, "%+v", callers)
if buffer.Len() == 0 {
t.Errorf("Formatted stack is empty")
}
}
func TestCallers(t *testing.T) {
callers := replify.Callers()
if callers == nil {
t.Errorf("Callers returned nil")
}
if callers == nil || len(*callers) == 0 {
t.Errorf("Callers returned an empty stack")
}
}
// func TestFrameFile(t *testing.T) {
// callers := replify.Callers()
// trace := callers.StackTrace()
// for _, frame := range trace {
// file := frame.File()
// if file == replify.ErrUnknown {
// t.Errorf("Frame file returned ErrUnknown")
// }
// if len(file) == 0 {
// t.Errorf("Frame file is empty")
// }
// }
// }
// func TestFrameLine(t *testing.T) {
// callers := replify.Callers()
// trace := callers.StackTrace()
// for _, frame := range trace {
// line := frame.Line()
// if line == 0 {
// t.Errorf("Frame line returned 0")
// }
// }
// }
// func TestFrameName(t *testing.T) {
// callers := replify.Callers()
// trace := callers.StackTrace()
// for _, frame := range trace {
// name := frame.Name()
// if name == "unknown" {
// t.Errorf("Frame name returned unknown")
// }
// if len(name) == 0 {
// t.Errorf("Frame name is empty")
// }
// }
// }