MCPcopy Create free account
hub / github.com/astercloud/aster / TestFilter

Function TestFilter

pkg/stream/stream_test.go:296–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestFilter(t *testing.T) {
297 reader := FromSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
298
299 filtered := Filter(reader, func(v int) bool {
300 return v > 5
301 })
302 defer filtered.Close()
303
304 result, err := filtered.Collect()
305 if err != nil {
306 t.Fatalf("unexpected error: %v", err)
307 }
308
309 expected := []int{6, 7, 8, 9, 10}
310 if len(result) != len(expected) {
311 t.Fatalf("expected %d items, got %d", len(expected), len(result))
312 }
313}
314
315func TestMap(t *testing.T) {
316 reader := FromSlice([]string{"hello", "world"})

Callers

nothing calls this directly

Calls 4

FromSliceFunction · 0.85
CollectMethod · 0.80
FilterFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected