Skip to content

Commit fc86165

Browse files
authored
Add test for nil Len() behavior (#142)
The nil check in Len() was added in PR #95 but lacked test coverage. This adds TestLenNil to verify that calling Len() on a nil *Error returns 0 instead of panicking. Fixes #54
1 parent 996c9fc commit fc86165

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

sort_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,10 @@ func TestSortMultiple(t *testing.T) {
5353
t.Fatalf("bad: %#v", err)
5454
}
5555
}
56+
57+
func TestLenNil(t *testing.T) {
58+
var err *Error
59+
if err.Len() != 0 {
60+
t.Fatalf("expected Len() to return 0 for nil *Error, got %d", err.Len())
61+
}
62+
}

0 commit comments

Comments
 (0)