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

Function TestMap

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

Source from the content-addressed store, hash-verified

313}
314
315func TestMap(t *testing.T) {
316 reader := FromSlice([]string{"hello", "world"})
317
318 lengths := Map(reader, func(s string) int {
319 return len(s)
320 })
321 defer lengths.Close()
322
323 result, err := lengths.Collect()
324 if err != nil {
325 t.Fatalf("unexpected error: %v", err)
326 }
327
328 if len(result) != 2 || result[0] != 5 || result[1] != 5 {
329 t.Errorf("unexpected result: %v", result)
330 }
331}
332
333func TestTake(t *testing.T) {
334 reader := FromSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})

Callers

nothing calls this directly

Calls 4

FromSliceFunction · 0.85
MapFunction · 0.85
CollectMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected