InferenceAI

Enter at least two characters to search.

Start free
Repository challenges

Write regression tests for chunk windows

Testing · Intermediate · AI engineering · 35 minutes

Engineering ticket

Write unittest tests in tests/ for chunks(words, size, overlap), defined in chunks.py. size must be positive and 0 <= overlap < size, otherwise raise ValueError. Emit overlapping slices until the last word is covered, with no trailing duplicate chunk. Empty input returns []. The implementation is correct and is restored on Submit. Your tests must pass it and reject all three defective variants. Add tests for boundary conditions and explain which regression each test catches.

Review rubric

  • Correctness on documented inputs
  • Tests and edge cases
  • Clear explanation of trade-offs

Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.

Starter repository

README.md
# InferenceAI engineering lab

Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
chunks.py
def chunks(words, size, overlap):
    if size <= 0 or overlap < 0 or overlap >= size:
        raise ValueError("Invalid window")
    out = []
    start = 0
    while start < len(words):
        out.append(words[start:start+size])
        if start+size >= len(words):
            break
        start += size-overlap
    return out
tests/test_chunks.py
import unittest
from chunks import chunks

class ChunkTest(unittest.TestCase):
    def test_empty(self):
        self.assertEqual(chunks([], 2, 0), [])