def test_escape_LongString_UnEscapeSubStr_PartialMatch(self): # We should not be able to find the escaped string earlier than it # was inserted into an escaped sequence. messages = [ " x", " x"] escape_string = "xxxx" encoded = [ Escape.escape(message,escape_string) for message in messages ] decoded = [ Escape.unescape(message,escape_string) for message in encoded ] self.assertEqual(messages, decoded)
def test_unescape_nonEmptyStringNoEscapeNeeded(self): message = "XXXXXX" expectResult = message result = Escape.unescape(message) self.assertEqual(expectResult, result)
def test_unescape_emptyString(self): message = "" expectResult = message result = Escape.unescape(message) self.assertEqual(expectResult, result)
def test_unescape_LongString_UnEscapeSubStr_MixedPercents_ButtingUp(self): message = "X%25X%25%68%65%6c%6c%6fX%25X%68%65%6c%6c%6fX%25X%25X%25X" expectResult = "X%X%helloX%XhelloX%X%X%X" escape_string = "hello" result = Escape.unescape(message,escape_string) self.assertEqual(expectResult, result)
def test_unescape_LongString_UnEscapeSubStr(self): message = "XXXX%68%65%6c%6c%6fXXXX" expectResult = "XXXXhelloXXXX" escape_string = "hello" result = Escape.unescape(message,escape_string) self.assertEqual(expectResult, result)
def test_unescape_LongString_ManyUnEscapePercents(self): message = "XXX%25XXXXXXXXXXXXX%25XXXXXXXXXXXXXXXX%25XXXXXXXXXXXXXXXXXXX%25XXXXXXXXXXXXXXXXX%25XXXXXXXXXXXXXX" expectResult = "XXX%XXXXXXXXXXXXX%XXXXXXXXXXXXXXXX%XXXXXXXXXXXXXXXXXXX%XXXXXXXXXXXXXXXXX%XXXXXXXXXXXXXX" result = Escape.unescape(message) self.assertEqual(expectResult, result)
def test_unescape_nonEmptyString_UnEscapePercent(self): message = "XXX%25XXX" expectResult = "XXX%XXX" result = Escape.unescape(message) self.assertEqual(expectResult, result)