(t *testing.T)
| 369 | } |
| 370 | |
| 371 | func TestForEach_Error(t *testing.T) { |
| 372 | reader := FromSlice([]int{1, 2, 3, 4, 5}) |
| 373 | |
| 374 | customErr := errors.New("stop at 3") |
| 375 | err := ForEach(reader, func(v int) error { |
| 376 | if v == 3 { |
| 377 | return customErr |
| 378 | } |
| 379 | return nil |
| 380 | }) |
| 381 | |
| 382 | if !errors.Is(err, customErr) { |
| 383 | t.Errorf("expected custom error, got %v", err) |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | func TestErrorPropagation(t *testing.T) { |
| 388 | reader, writer := Pipe[int](2) |