Skip to content

Commit

Permalink
#86 Add empty but not emptyIterable test case
Browse files Browse the repository at this point in the history
  • Loading branch information
meian committed Feb 5, 2022
1 parent d7eaa9d commit cd6f5ea
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ func testBeforeAndAfter[T any](t *testing.T, itb gcf.Iterable[T]) {
// On function called with emptyIterable should be emptyIterable.
func testEmptyChain(t *testing.T, f func(itb gcf.Iterable[int]) gcf.Iterable[int]) {
t.Helper()
itbe := gcf.FromSlice([]int{})
t.Run("is empty Iterable", func(t *testing.T) {
itb := f(itbe)
t.Run("is emptyIterable", func(t *testing.T) {
itb := gcf.FromSlice([]int{})
itb = f(itb)
assert.True(t, gcf.IsEmptyIterable(itb), "%v", gcf.ToSlice(itb))
})
t.Run("is empty but not emptyIterable", func(t *testing.T) {
defer func() {
err := recover()
if err != nil {
t.Errorf("%v", err)
}
}()
itb := gcf.FromSlice([]int{1})
itb = gcf.Filter(itb, func(v int) bool { return false })
itb = f(itb)
_ = gcf.ToSlice(itb)
})
}

0 comments on commit cd6f5ea

Please sign in to comment.