返回 DeepSeek-Reasonix
nil_test.go
根目录 / internal / nilutil / nil_test.go
1 package nilutil
2
3 import "testing"
4
5 type sampleInterface interface {
6 Do()
7 }
8
9 type sampleImpl struct{}
10
11 func (*sampleImpl) Do() {}
12
13 func TestIsNilDetectsTypedNilInterface(t *testing.T) {
14 var p *sampleImpl
15 var i sampleInterface = p
16
17 if !IsNil(i) {
18 t.Fatal("IsNil should detect typed nil interface")
19 }
20 }
21
22 func TestIsNilRejectsConcreteValues(t *testing.T) {
23 var p sampleInterface = &sampleImpl{}
24
25 if IsNil(p) {
26 t.Fatal("IsNil should not reject a concrete interface value")
27 }
28 if IsNil("x") {
29 t.Fatal("IsNil should not reject non-nil scalar values")
30 }
31 }
32
32 lines GO