Spaces:
Running
Running
File size: 3,849 Bytes
28d0c5f 85b7206 28d0c5f 42e76ea 4cafb0a 85b7206 42e76ea 28d0c5f 85b7206 28d0c5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import unittest
import WordMetrics
words_real = 'Ich habe sehr viel glück, am leben und gesund zu sein'
words_transcribed = 'Ic hab zeh viel guck am und gesund tu sein'
class TestWordMetrics(unittest.TestCase):
def test_edit_distance_python2(self):
self.assertEqual(WordMetrics.edit_distance_python2("kitten", "sitting"), 3)
self.assertEqual(WordMetrics.edit_distance_python2("flaw", "lawn"), 2)
self.assertEqual(WordMetrics.edit_distance_python2("intention", "execution"), 5)
self.assertEqual(WordMetrics.edit_distance_python2("", ""), 0)
self.assertEqual(WordMetrics.edit_distance_python2("a", ""), 1)
self.assertEqual(WordMetrics.edit_distance_python2("", "a"), 1)
def test_edit_distance_python(self):
output = WordMetrics.edit_distance_python(words_real, words_transcribed)
self.assertEqual(output, int(14))
def test_edit_distance_python_same(self):
output = WordMetrics.edit_distance_python(words_real, words_real)
self.assertEqual(output, int(0))
def test_edit_distance_python_empty(self):
output = WordMetrics.edit_distance_python("", "")
self.assertEqual(output, int(0))
output = WordMetrics.edit_distance_python(words_real, "")
self.assertEqual(output, int(53))
output = WordMetrics.edit_distance_python("", words_real)
self.assertEqual(output, int(53))
def test_edit_distance_python_not_printable_characters(self):
output = WordMetrics.edit_distance_python("Ich bin Alex\t a\0b! Hallo.", "Ich bi\tn Tom a\nc... Hallo")
self.assertEqual(output, int(12))
def test_edit_distance_python_survived(self):
# These tests are added based on the mutation test results to ensure the function is robust
# Test case where mutation survived for ReplaceBinaryOperator_Add_Mul
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr")
self.assertEqual(output, int(5))
# Test case where mutation survived for ReplaceBinaryOperator_Add_Div
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel")
self.assertEqual(output, int(10))
# Test case where mutation survived for ReplaceBinaryOperator_Add_FloorDiv
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück")
self.assertEqual(output, int(16))
# Test case where mutation survived for ReplaceBinaryOperator_Add_Pow
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am")
self.assertEqual(output, int(20))
# Test case where mutation survived for ReplaceBinaryOperator_Sub_Mod
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am leben")
self.assertEqual(output, int(26))
# Test case where mutation survived for ReplaceBinaryOperator_Sub_RShift
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am leben und")
self.assertEqual(output, int(30))
# Test case where mutation survived for ReplaceBinaryOperator_Sub_LShift
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am leben und gesund")
self.assertEqual(output, int(37))
# Test case where mutation survived for ReplaceBinaryOperator_Sub_BitAnd
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am leben und gesund zu")
self.assertEqual(output, int(40))
# Test case where mutation survived for ReplaceBinaryOperator_Sub_BitXor
output = WordMetrics.edit_distance_python("Ich habe", "Ich habe sehr viel glück, am leben und gesund zu sein")
self.assertEqual(output, int(45))
if __name__ == '__main__':
unittest.main()
|