Skip to content

Commit

Permalink
Merge pull request #1 from EthanJamesLew/enhancement/test-cases
Browse files Browse the repository at this point in the history
Add new tests for replace_last_backslash function
  • Loading branch information
philiporlando authored Jun 29, 2023
2 parents 73ebb23 + c2be52a commit 4f98bef
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_replace_last_backslash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def test_replace_last_backslash():
assert replace_last_backslash("no_backslash") == "no_backslash"
assert replace_last_backslash("") == ""

# Testing a string where all characters are backslashes
assert replace_last_backslash("\\\\\\\\") == "\\\\\\/"
# Testing a string with mixed slashes ("/" and "\\")
assert replace_last_backslash("C:/Users\\John\\Desktop") == "C:/Users\\John/Desktop"


def test_replace_last_backslash_with_multiple_backslashes():
assert replace_last_backslash("A\\B\\C\\D\\E\\F") == "A\\B\\C\\D\\E/F"
Expand All @@ -35,3 +40,14 @@ def test_replace_last_backslash_with_special_characters():
replace_last_backslash("D:\\path\\with\\parentheses\\(file).txt")
== "D:\\path\\with\\parentheses/(file).txt"
)


def test_replace_last_backslash_with_empty_string():
assert replace_last_backslash("") == ""


def test_replace_last_backslash_with_strings_without_backslashes():
assert replace_last_backslash("no_backslash") == "no_backslash"
assert replace_last_backslash("forward/slash/only") == "forward/slash/only"
assert replace_last_backslash("normal string without slashes") == "normal string without slashes"

0 comments on commit 4f98bef

Please sign in to comment.