From c2be52afe67162b78580fd0fa11c3b8ed0810740 Mon Sep 17 00:00:00 2001 From: Ethan Lew Date: Tue, 20 Jun 2023 23:07:32 -0700 Subject: [PATCH] test cases for empty string, no backslashes, only backslashes, and mixed --- tests/test_replace_last_backslash.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_replace_last_backslash.py b/tests/test_replace_last_backslash.py index 29e733c..88fb06a 100644 --- a/tests/test_replace_last_backslash.py +++ b/tests/test_replace_last_backslash.py @@ -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" @@ -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" +