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

Function TestForEach

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

Source from the content-addressed store, hash-verified

352}
353
354func TestForEach(t *testing.T) {
355 reader := FromSlice([]int{1, 2, 3})
356
357 var sum int
358 err := ForEach(reader, func(v int) error {
359 sum += v
360 return nil
361 })
362
363 if err != nil {
364 t.Fatalf("unexpected error: %v", err)
365 }
366 if sum != 6 {
367 t.Errorf("expected sum 6, got %d", sum)
368 }
369}
370
371func TestForEach_Error(t *testing.T) {
372 reader := FromSlice([]int{1, 2, 3, 4, 5})

Callers

nothing calls this directly

Calls 2

FromSliceFunction · 0.85
ForEachFunction · 0.85

Tested by

no test coverage detected