Files

28 lines
606 B
Python

#!/usr/bin/env python3
"""Check that word_counter.py correctly counts words."""
import sys
import os
# Add the wizard-outputs directory to path
sys.path.insert(0, '/root/.hermes/wizard-outputs/spark')
from word_counter import count_words
# Run tests
tests = [
("Hello world test", 3),
("", 0),
(" ", 0),
("one", 1),
("one two three four five", 5),
]
for text, expected in tests:
result = count_words(text)
if result != expected:
print(f"FAIL: '{text}' -> {result}, expected {expected}", file=sys.stderr)
sys.exit(1)
print("All tests passed!")
sys.exit(0)