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

Function TestCopy_Independent

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

Source from the content-addressed store, hash-verified

93}
94
95func TestCopy_Independent(t *testing.T) {
96 reader := FromSlice([]int{1, 2, 3})
97 copies := reader.Copy(3)
98
99 if len(copies) != 3 {
100 t.Fatalf("expected 3 copies, got %d", len(copies))
101 }
102
103 // 每个副本应该能独立读取所有值
104 for i, cp := range copies {
105 result, err := cp.Collect()
106 if err != nil {
107 t.Errorf("copy %d: unexpected error: %v", i, err)
108 }
109 if len(result) != 3 {
110 t.Errorf("copy %d: expected 3 items, got %d", i, len(result))
111 }
112 for j, v := range result {
113 if v != j+1 {
114 t.Errorf("copy %d, index %d: expected %d, got %d", i, j, j+1, v)
115 }
116 }
117 }
118}
119
120func TestCopy_Concurrent(t *testing.T) {
121 reader, writer := Pipe[int](10)

Callers

nothing calls this directly

Calls 3

FromSliceFunction · 0.85
CopyMethod · 0.80
CollectMethod · 0.80

Tested by

no test coverage detected