MCPcopy
hub / github.com/duke-git/lancet / TestGetWithPanicStandard

Function TestGetWithPanicStandard

datastructure/optional/optional_test.go:126–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestGetWithPanicStandard(t *testing.T) {
127 assert := internal.NewAssert(t, "TestGetWithPanicStandard")
128
129 // Test when value is present
130 optWithValue := Of(42)
131 func() {
132 defer func() {
133 r := recover()
134 assert.IsNil(r)
135 }()
136 val := optWithValue.Unwarp()
137 if val != 42 {
138 t.Errorf("Expected Unwarp to return 42, got %v", val)
139 }
140 }()
141
142 // Test when value is not present
143 optDefault := Default[int]()
144 func() {
145 defer func() {
146 r := recover()
147 assert.IsNotNil(r)
148 }()
149 _ = optDefault.Unwarp()
150 }()
151}

Callers

nothing calls this directly

Calls 5

IsNilMethod · 0.95
IsNotNilMethod · 0.95
NewAssertFunction · 0.92
UnwarpMethod · 0.80
OfFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…