Spaces:
Running
Running
| from counter.word_counter import WordCounter | |
| def test_increment(): | |
| counter = WordCounter() | |
| assert counter.get_count() == 0 | |
| counter.increment() | |
| assert counter.get_count() == 1 | |
| counter.increment() | |
| assert counter.get_count() == 2 | |
| print("β increment test passed") | |
| def test_reset(): | |
| counter = WordCounter() | |
| counter.increment() | |
| counter.increment() | |
| counter.reset() | |
| assert counter.get_count() == 0 | |
| print("β reset test passed") | |
| def test_detect_word_case_insensitive(): | |
| counter = WordCounter() | |
| assert counter.detect_word("Hello World", "hello") == True | |
| assert counter.detect_word("Hello World", "WORLD") == True | |
| assert counter.detect_word("hello world", "Hello") == True | |
| print("β case-insensitive test passed") | |
| def test_detect_word_boundaries(): | |
| counter = WordCounter() | |
| assert counter.detect_word("testing is fun", "test") == False | |
| assert counter.detect_word("test is fun", "test") == True | |
| assert counter.detect_word("this is a test", "test") == True | |
| print("β word boundaries test passed") | |
| def test_detect_word_with_punctuation(): | |
| counter = WordCounter() | |
| assert counter.detect_word("Hello!", "hello") == True | |
| assert counter.detect_word("Hello, world!", "hello") == True | |
| assert counter.detect_word("Test. Another test.", "test") == True | |
| print("β punctuation test passed") | |
| def test_detect_word_empty(): | |
| counter = WordCounter() | |
| assert counter.detect_word("", "test") == False | |
| assert counter.detect_word("test", "") == False | |
| assert counter.detect_word("", "") == False | |
| print("β empty input test passed") | |
| if __name__ == "__main__": | |
| test_increment() | |
| test_reset() | |
| test_detect_word_case_insensitive() | |
| test_detect_word_boundaries() | |
| test_detect_word_with_punctuation() | |
| test_detect_word_empty() | |
| print("\nβ All tests passed!") | |