def test_correct_e301(): h = simple_init('E301', 'APP') assert [ DiffOperation.delete(1, 1), DiffOperation.delete(1, 2), DiffOperation.delete(1, 3), DiffOperation.insert(INT_MAX, INT_MAX, val='App'), ] == h.diffs
def test_simple(): executor = load_and_check('correction_simple.md') assert [ DiffOperation.replace(1, 3, val=','), DiffOperation.delete(1, 4), DiffOperation.replace(1, 7, val='。'), ] == executor.diffs assert '中文,标点。\n' == executor.apply_diff_operations()
def test_correct_e103(): h = simple_init('E103', '42μ') assert [DiffOperation.insert(1, 3, val=' ')] == h.diffs h = simple_init('E103', '42 μ') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.insert(1, 5, val=' '), ] == h.diffs
def test_correct_e203(): h = simple_init('E203', '中文, 测试') assert [ DiffOperation.delete(1, 4), ] == h.diffs h = simple_init('E203', '中文 ,测试') assert [ DiffOperation.delete(1, 3), ] == h.diffs
def test_correct_e104(): h = simple_init('E104', '(42)') assert [ DiffOperation.replace(1, 4, val=')'), ] == h.diffs h = simple_init('E104', '(42)') assert [ DiffOperation.replace(1, 1, val='('), DiffOperation.replace(1, 4, val=')'), ] == h.diffs h = simple_init('E104', '42(42)') assert [ DiffOperation.insert(1, 3, val=' '), ] == h.diffs h = simple_init('E104', '42 (42)') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.insert(1, 5, val=' '), ] == h.diffs h = simple_init('E104', ' (42)') assert [ DiffOperation.delete(1, 1), DiffOperation.delete(1, 2), ] == h.diffs
def test_correct_e204(): h = simple_init('E204', '中文“测试”') assert [ DiffOperation.replace(1, 3, '「'), DiffOperation.replace(1, 6, '」'), ] == h.diffs h = simple_init('E204', '中文‘测试’') assert [ DiffOperation.replace(1, 3, '「'), DiffOperation.replace(1, 6, '」'), ] == h.diffs
def test_correct_e207(): h = simple_init('E207', '讨厌啦~') assert [ DiffOperation.delete(1, 4), ] == h.diffs h = simple_init('E207', '讨厌啦~~~~') assert [ DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.delete(1, 6), DiffOperation.delete(1, 7), ] == h.diffs
def test_latex(): executor = load_and_check('correction_latex.md') assert [ DiffOperation.replace(1, 40, val='。'), ] == executor.diffs assert ('第 (5) 步的重定向 transitions $ChildrenTrans$。\n' == executor.apply_diff_operations())
def test_correct_e206(): h = simple_init('E206', 'this is sparta!!!') assert [ DiffOperation.delete(1, 15), DiffOperation.delete(1, 16), DiffOperation.delete(1, 17), DiffOperation.insert(INT_MAX, INT_MAX, '!'), ] == h.diffs h = simple_init('E206', 'this is sparta???') assert [ DiffOperation.delete(1, 15), DiffOperation.delete(1, 16), DiffOperation.delete(1, 17), DiffOperation.insert(INT_MAX, INT_MAX, '?'), ] == h.diffs
def test_correct_e205(): h = simple_init('E205', '中文...') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.insert(INT_MAX, INT_MAX, '......'), ] == h.diffs h = simple_init('E205', '中文.......') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.delete(1, 6), DiffOperation.delete(1, 7), DiffOperation.delete(1, 8), DiffOperation.delete(1, 9), DiffOperation.insert(INT_MAX, INT_MAX, '......'), ] == h.diffs h = simple_init('E205', '中文。。') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.insert(INT_MAX, INT_MAX, '......'), ] == h.diffs
def test_correct_e202(): h = simple_init('E202', 'english,test。') assert [ DiffOperation.replace(1, 8, val=', '), DiffOperation.replace(1, 13, val='. '), ] == h.diffs
def test_correct_e201(): h = simple_init('E201', '有中文,错误.') assert [ DiffOperation.replace(1, 4, val=','), DiffOperation.replace(1, 7, val='。'), ] == h.diffs h = simple_init('E201', '有中文, 错误.') assert [ DiffOperation.replace(1, 4, val=','), DiffOperation.delete(1, 5), DiffOperation.replace(1, 8, val='。'), ] == h.diffs h = simple_init('E201', '有中文"错误"') assert [ DiffOperation.replace(1, 4, val='「'), DiffOperation.replace(1, 7, val='」'), ] == h.diffs h = simple_init('E201', '有中文,"错误",') assert [ DiffOperation.replace(1, 5, val='「'), DiffOperation.replace(1, 8, val='」'), DiffOperation.replace(1, 9, val=','), ] == h.diffs h = simple_init('E201', '有中文(错误)') assert [ DiffOperation.replace(1, 4, val='('), DiffOperation.replace(1, 7, val=')'), ] == h.diffs h = simple_init('E201', ' 步的重定向 transitions $$.') assert [ DiffOperation.replace(1, 22, val='。'), ] == h.diffs
def test_correct_e102(): h = simple_init('E102', '中文42') assert [DiffOperation.insert(1, 3, val=' ')] == h.diffs h = simple_init('E102', '42中文') assert [DiffOperation.insert(1, 3, val=' ')] == h.diffs h = simple_init('E102', '中文 42') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.insert(1, 6, val=' '), ] == h.diffs h = simple_init('E102', '42 中文') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.insert(1, 6, val=' '), ] == h.diffs h = simple_init('E102', '中文\t42') assert [ DiffOperation.delete(1, 3), DiffOperation.insert(1, 4, val=' '), ] == h.diffs h = simple_init('E102', '42\t中文') assert [ DiffOperation.delete(1, 3), DiffOperation.insert(1, 4, val=' '), ] == h.diffs
def test_correct_e101(): h = simple_init('E101', '中文english') assert [DiffOperation.insert(1, 3, val=' ')] == h.diffs h = simple_init('E101', 'english中文') assert [DiffOperation.insert(1, 8, val=' ')] == h.diffs h = simple_init('E101', '中文 english') assert [ DiffOperation.delete(1, 3), DiffOperation.delete(1, 4), DiffOperation.delete(1, 5), DiffOperation.insert(1, 6, val=' '), ] == h.diffs h = simple_init('E101', 'english 中文') assert [ DiffOperation.delete(1, 8), DiffOperation.delete(1, 9), DiffOperation.delete(1, 10), DiffOperation.insert(1, 11, val=' '), ] == h.diffs h = simple_init('E101', '中文\tenglish') assert [ DiffOperation.delete(1, 3), DiffOperation.insert(1, 4, val=' '), ] == h.diffs h = simple_init('E101', 'english\t中文') assert [ DiffOperation.delete(1, 8), DiffOperation.insert(1, 9, val=' '), ] == h.diffs