Skip to content

Commit

Permalink
Add UnsafeStreamToSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
Primetalk committed Aug 18, 2022
1 parent d6d77b2 commit f109957
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stream/common_test.go
Expand Up @@ -2,8 +2,11 @@ package stream_test

import (
"fmt"
"testing"

"github.com/primetalk/goio/io"
"github.com/primetalk/goio/stream"
"github.com/stretchr/testify/assert"
)

var nats = stream.Unfold(0, func(s int) int {
Expand All @@ -16,3 +19,9 @@ var Mul2 = stream.MapPipe(func(i int) int { return i * 2 })
var pipeMul2IO = stream.PipeToPairOfChannels(Mul2)

var printInt = stream.NewSink(func(i int) { fmt.Printf("%d", i) })

func UnsafeStreamToSlice[A any](t *testing.T, stm stream.Stream[A]) []A {
res, err1 := io.UnsafeRunSync(stream.ToSlice(stm))
assert.NoError(t, err1)
return res
}

0 comments on commit f109957

Please sign in to comment.