diff --git a/callstack/stack.go b/callstack/stack.go index fa4ccc3..0982312 100644 --- a/callstack/stack.go +++ b/callstack/stack.go @@ -35,6 +35,11 @@ func GetSkip(skip int) Stack { } } +// IsZero determines if this stack is a zero-value +func (st Stack) IsZero() bool { + return len(st.s) == 0 +} + // A shallow wrapper around [runtime.CallersFrames] func (st Stack) CallersFrames() *runtime.Frames { return runtime.CallersFrames(st.s) diff --git a/callstack/stack_test.go b/callstack/stack_test.go index a630b38..a2364be 100644 --- a/callstack/stack_test.go +++ b/callstack/stack_test.go @@ -48,7 +48,10 @@ func TestStackIters(t *testing.T) { func TestStackString(t *testing.T) { c := check.NewT(t) - c.Equal(Stack{}.String(), "") + + var stack Stack + c.True(stack.IsZero()) + c.Equal(stack.String(), "") } func BenchmarkGet(b *testing.B) {