Skip to content

Commit

Permalink
Revert "Delete solutions/tests/test_word_frequency.py"
Browse files Browse the repository at this point in the history
This reverts commit 8512058.
  • Loading branch information
TibyanKhalid committed Jan 12, 2025
1 parent 124de56 commit 21ffdbb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions solutions/tests/test_word_frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# test_word_frequency.py
"""
This module contains unit tests for the word_frequency module.
The tests verify the functionality of the count_word_frequency function,
which counts the frequency of words in a given text.
"""

import unittest

from ..word_frequency import count_word_frequency


class TestWordFrequency(unittest.TestCase):
"""Test cases for the count_word_frequency function."""

def test_count_word_frequency(self):
"""Test counting word frequency in a simple text."""
text = "hello world hello"
expected_output = {"hello": 2, "world": 1}
self.assertEqual(count_word_frequency(text), expected_output)

def test_empty_text(self):
"""Test counting word frequency in an empty string."""
text = ""
expected_output = {}
self.assertEqual(count_word_frequency(text), expected_output)

def test_case_insensitive(self):
"""Test counting word frequency with case-insensitive matching."""
text = "Hello hello HeLLo"
expected_output = {"hello": 3}
self.assertEqual(count_word_frequency(text), expected_output)


if __name__ == "__main__":
unittest.main()

0 comments on commit 21ffdbb

Please sign in to comment.