Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halprin committed Aug 24, 2024
1 parent 910b5d9 commit c1e6425
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
25 changes: 24 additions & 1 deletion internal/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package generator

import (
"github.com/stretchr/testify/assert"
"slices"
"testing"
)

Expand Down Expand Up @@ -120,7 +121,7 @@ func TestMapNotPanicsGivenMap(t *testing.T) {
assert.NotPanics(t, func() {
FromMap(map[string]int{
"DogCow": 1,
"Moof": 1976,
"Moof": 1976,
})
})
}
Expand All @@ -145,6 +146,28 @@ func TestMapEndsWithError(t *testing.T) {
assert.ErrorIs(err, Exhausted)
}

func TestFromIteratorWithLastTimeError(t *testing.T) {
assert := assert.New(t)

generator := FromIterator(slices.Values([]interface{}{9}))

_, err := generator()

assert.NoError(err)

_, err = generator()

assert.ErrorIs(err, Exhausted)
}

func TestFromIteratorEmpty(t *testing.T) {
generator := FromIterator(slices.Values([]interface{}{}))

_, err := generator()

assert.ErrorIs(t, err, Exhausted)
}

func createTestChannel(size int) chan interface{} {
intChannel := make(chan interface{})

Expand Down
7 changes: 0 additions & 7 deletions internal/helper/type.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package helper

import (
"iter"
"reflect"
)

Expand All @@ -24,9 +23,3 @@ func IsMap(value interface{}) bool {
concreteValue := reflect.ValueOf(value)
return concreteValue.Kind() == reflect.Map
}

func IsIterator(value interface{}) bool {
_, ok := value.(iter.Seq[any])

return ok
}

0 comments on commit c1e6425

Please sign in to comment.