code
Feb 17, 2026CODE-006Write comprehensive unit tests for this function. Cover all edge cases, including boundary conditions, error cases, and typical usage. ```python def merge_sorted_streams(*streams, max_items=None): """ Merge multiple sorted iterables into a single sorted output. Args: *streams: Variable number of sorted iterables max_items: Optional limit on total items to yield Yields: Items from all streams in sorted order Raises: ValueError: If any stream is not sorted """ import heapq heap = [] iterators = [iter(s) for s in streams] # Initialize heap with first item from each stream for i, it in enumerate(iterators): try: item = next(it) heapq.heappush(heap, (item, i)) except StopIteration: pass count = 0 prev = None while heap and (max_items is None or count < max_items): item, stream_idx = heapq.heappop(heap) # Validate sorting if prev is not None and item < prev: raise ValueError(f"Stream {stream_idx} is not sorted") yield item prev = item count += 1 # Get next item from same stream try: next_item = next(iterators[stream_idx]) heapq.heappush(heap, (next_item, stream_idx)) except StopIteration: pass ``` Use pytest. Include parametrized tests where appropriate.
Winner
GPT-5.4
openrouter
9.08
WINNER SCORE
matrix avg: 7.20
10×10 Judgment Matrix · 86 judgments
OPEN DATA
| Judge ↓ / Respondent → | GPT-5.4 | Claude Opus 4.6 | Gemini 3.1 Pro | Claude Sonnet 4.6 | Grok 4.20 | DeepSeek V4 | GPT-OSS-120B | Gemini 3 | MiniMax M2.5 | MiMo-V2-Flash |
|---|---|---|---|---|---|---|---|---|---|---|
| GPT-5.4 | — | 3.8 | 0.7 | 2.6 | 5.3 | 7.3 | 2.9 | 7.1 | 2.6 | 4.5 |
| Claude Opus 4.6 | 9.0 | — | 1.6 | 7.7 | 7.6 | 8.0 | 6.8 | 7.5 | 5.3 | 7.7 |
| Gemini 3.1 Pro | 9.6 | 6.4 | — | 4.8 | 5.5 | 9.3 | 6.0 | 9.4 | 5.3 | 7.8 |
| Claude Sonnet 4.6 | 9.0 | 8.0 | 1.2 | — | 8.0 | 8.3 | 7.3 | 8.2 | 7.0 | 8.0 |
| Grok 4.20 | 8.6 | 6.8 | 3.6 | · | — | 6.6 | 8.3 | 8.6 | 7.7 | 7.5 |
| DeepSeek V4 | 9.6 | 8.6 | 8.2 | 8.6 | 9.3 | — | 9.1 | 9.3 | 9.6 | 8.8 |
| GPT-OSS-120B | 8.8 | 6.2 | 2.2 | · | 7.5 | 8.8 | — | 8.8 | 6.5 | 7.5 |
| Gemini 3 | 10.0 | · | 2.9 | 7.8 | 9.6 | 9.8 | 9.0 | — | 6.8 | 9.2 |
| MiniMax M2.5 | 8.8 | 7.5 | 1.2 | 7.5 | 8.2 | 8.6 | 7.3 | · | — | 7.2 |
| MiMo-V2-Flash | 8.3 | 7.8 | 9.0 | 8.0 | 8.8 | 8.6 | 8.6 | 7.8 | 8.6 | — |