feat: add stringutils module with word_count function and tests
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
34
tests/test_stringutils.py
Normal file
34
tests/test_stringutils.py
Normal file
@ -0,0 +1,34 @@
|
||||
import pytest
|
||||
from stringutils import word_count
|
||||
|
||||
|
||||
def test_word_count_empty_string():
|
||||
assert word_count("") == 0
|
||||
|
||||
|
||||
def test_word_count_whitespace_only():
|
||||
assert word_count(" ") == 0
|
||||
|
||||
|
||||
def test_word_count_single_word():
|
||||
assert word_count("hello") == 1
|
||||
|
||||
|
||||
def test_word_count_multiple_words():
|
||||
assert word_count("hello world") == 2
|
||||
|
||||
|
||||
def test_word_count_multiple_spaces():
|
||||
assert word_count("hello world") == 2
|
||||
|
||||
|
||||
def test_word_count_leading_trailing_spaces():
|
||||
assert word_count(" hello world ") == 2
|
||||
|
||||
|
||||
def test_word_count_newlines_and_tabs():
|
||||
assert word_count("hello\nworld\t!") == 3
|
||||
|
||||
|
||||
def test_word_count_mixed_whitespace():
|
||||
assert word_count(" hello \t\n world ") == 2
|
||||
Reference in New Issue
Block a user