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

Function TestTake

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

Source from the content-addressed store, hash-verified

331}
332
333func TestTake(t *testing.T) {
334 reader := FromSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
335
336 first3 := Take(reader, 3)
337 defer first3.Close()
338
339 result, err := first3.Collect()
340 if err != nil {
341 t.Fatalf("unexpected error: %v", err)
342 }
343
344 if len(result) != 3 {
345 t.Fatalf("expected 3 items, got %d", len(result))
346 }
347 for i, v := range result {
348 if v != i+1 {
349 t.Errorf("at index %d: expected %d, got %d", i, i+1, v)
350 }
351 }
352}
353
354func TestForEach(t *testing.T) {
355 reader := FromSlice([]int{1, 2, 3})

Callers

nothing calls this directly

Calls 4

FromSliceFunction · 0.85
TakeFunction · 0.85
CollectMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected