예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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