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

Function TestMerge_Basic

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

Source from the content-addressed store, hash-verified

165}
166
167func TestMerge_Basic(t *testing.T) {
168 r1 := FromSlice([]int{1, 3, 5})
169 r2 := FromSlice([]int{2, 4, 6})
170
171 merged := Merge(r1, r2)
172 defer merged.Close()
173
174 result, err := merged.Collect()
175 if err != nil {
176 t.Fatalf("unexpected error: %v", err)
177 }
178
179 if len(result) != 6 {
180 t.Errorf("expected 6 items, got %d", len(result))
181 }
182
183 // 检查所有值都存在(顺序可能不同)
184 expected := map[int]bool{1: true, 2: true, 3: true, 4: true, 5: true, 6: true}
185 for _, v := range result {
186 if !expected[v] {
187 t.Errorf("unexpected value: %d", v)
188 }
189 delete(expected, v)
190 }
191 if len(expected) > 0 {
192 t.Errorf("missing values: %v", expected)
193 }
194}
195
196func TestMergeNamed_SourceEOF(t *testing.T) {
197 r1, w1 := Pipe[string](2)

Callers

nothing calls this directly

Calls 5

FromSliceFunction · 0.85
MergeFunction · 0.85
deleteFunction · 0.85
CollectMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected