Opens in a new tab

DGTULS PROMPT LIBRARY

Write unit tests for a function

Write unit tests for the function below using {{test_framework}}.

Cover:
- The normal case
- Edge cases (empty input, boundaries, unusual types)
- Error cases
Name each test so it reads as a sentence describing the behavior.
If the function is hard to test (hidden dependencies, time, randomness), say what to change and show the smallest refactor.

```{{language}}
{{code}}
```

Essential cookies keep DGTULS working and are always on. Optional cookies help us measure traffic and show ads. Accept, reject or choose which ones to allow. Learn more in our Cookie Policy, Privacy Policy and Terms of Use.