Added doctest to string_switch_case.py (#11136)

* Added doctest to string_switch_case.py

* Update string_switch_case.py
This commit is contained in:
Suyash Dongre 2023-11-06 17:48:41 +05:30 committed by GitHub
parent fa508d7b8b
commit 12e401650c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,12 @@ def to_simple_case(str_: str) -> str:
""" """
>>> to_simple_case("one two 31235three4four") >>> to_simple_case("one two 31235three4four")
'OneTwo31235three4four' 'OneTwo31235three4four'
>>> to_simple_case("This should be combined")
'ThisShouldBeCombined'
>>> to_simple_case("The first letters are capitalized, then string is merged")
'TheFirstLettersAreCapitalizedThenStringIsMerged'
>>> to_simple_case("special characters :, ', %, ^, $, are ignored")
'SpecialCharactersAreIgnored'
""" """
string_split = split_input(str_) string_split = split_input(str_)
return "".join( return "".join(
@ -37,6 +43,14 @@ def to_simple_case(str_: str) -> str:
def to_complex_case(text: str, upper: bool, separator: str) -> str: def to_complex_case(text: str, upper: bool, separator: str) -> str:
""" """
Returns the string concatenated with the delimiter we provide.
Parameters:
@text: The string on which we want to perform operation
@upper: Boolean value to determine whether we want capitalized result or not
@separator: The delimiter with which we want to concatenate words
Examples:
>>> to_complex_case("one two 31235three4four", True, "_") >>> to_complex_case("one two 31235three4four", True, "_")
'ONE_TWO_31235THREE4FOUR' 'ONE_TWO_31235THREE4FOUR'
>>> to_complex_case("one two 31235three4four", False, "-") >>> to_complex_case("one two 31235three4four", False, "-")