Skip to content

#9943 : adding some coverage for string #12301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions maths/average_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def mode(input_list: list) -> list[Any]:

The input list may contain any Datastructure or any Datatype.

>>> mode([])
[]
>>> mode([2, 3, 4, 5, 3, 4, 2, 5, 2, 2, 4, 2, 2, 2])
[2]
>>> mode([3, 4, 5, 3, 4, 2, 5, 2, 2, 4, 4, 2, 2, 2])
Expand Down
4 changes: 4 additions & 0 deletions strings/barcode_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def get_barcode(barcode: str) -> int:

>>> get_barcode("8718452538119")
8718452538119
>>> get_barcode("-367062129")
Traceback (most recent call last):
...
ValueError: The entered barcode has a negative value. Try again.
>>> get_barcode("dwefgiweuf")
Traceback (most recent call last):
...
Expand Down
2 changes: 2 additions & 0 deletions strings/can_string_be_rearranged_as_palindrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def can_string_be_rearranged_as_palindrome_counter(
"""
A Palindrome is a String that reads the same forward as it does backwards.
Examples of Palindromes mom, dad, malayalam
>>> can_string_be_rearranged_as_palindrome("")
True
>>> can_string_be_rearranged_as_palindrome_counter("Momo")
True
>>> can_string_be_rearranged_as_palindrome_counter("Mother")
Expand Down
2 changes: 2 additions & 0 deletions strings/check_anagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def check_anagrams(first_str: str, second_str: str) -> bool:
"""
Two strings are anagrams if they are made up of the same letters but are
arranged differently (ignoring the case).
>>> check_anagrams('This', 'These')
False
>>> check_anagrams('Silent', 'Listen')
True
>>> check_anagrams('This is a string', 'Is this a string')
Expand Down
8 changes: 8 additions & 0 deletions strings/count_vowels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ def count_vowels(s: str) -> int:
:return: Number of vowels in the input string.

Examples:
>>> count_vowels(10)
Traceback (most recent call last):
...
ValueError: Input must be a string
>>> count_vowels(True)
Traceback (most recent call last):
...
ValueError: Input must be a string
>>> count_vowels("hello world")
3
>>> count_vowels("HELLO WORLD")
Expand Down
2 changes: 2 additions & 0 deletions strings/credit_card_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def luhn_validation(credit_card_number: str) -> bool:
True
>>> luhn_validation('41111111111111')
False
>>> luhn_validation('4678001415')
True
"""
cc_number = credit_card_number
total = 0
Expand Down
7 changes: 6 additions & 1 deletion strings/is_valid_email_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
),
("i.like.underscores@but_its_not_allowed_in_this_part", False),
("", False),
(".startdot@example", False),
("enddot.@example", False),
("double..dot@example", False),
("example@-dashstart", False),
("example@dashend-", False),
)

# The maximum octets (one character as a standard unicode character is one byte)
Expand Down Expand Up @@ -97,7 +102,7 @@ def is_valid_email_address(email: str) -> bool:
return False

# (6.) Validate the placement of "-" characters
if domain.startswith("-") or domain.endswith("."):
if domain.startswith("-") or domain.endswith("-"):
return False

# (7.) Validate the placement of "." characters
Expand Down
8 changes: 8 additions & 0 deletions strings/min_cost_string_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
>>> y1 = len(ops1[0]) - 1
>>> assemble_transformation(ops1, x1, y1)
[]

>>> ops2 = [['0', 'Ic', 'Iu'],
... ['Da', 'Da', 'Rau'],
... ['Dt', 'Dt', 'Rtu']]
>>> x2 = len(ops2) - 1
>>> y2 = len(ops2[0]) - 1
>>> assemble_transformation(ops2, x2, y2)
['Ic', 'Da', 'Rtu']
"""
if i == 0 and j == 0:
return []
Expand Down
2 changes: 2 additions & 0 deletions strings/string_switch_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def to_pascal_case(text: str) -> str:

def to_camel_case(text: str) -> str:
"""
>>> to_camel_case("")
'not valid string'
>>> to_camel_case("one two 31235three4four")
'oneTwo31235three4four'
"""
Expand Down