示例#1
0
def test_blank_between_second_argument_None_blanks_to_end():
    rl = RunLengthList([(0, 'foo'), (2, 'bar'), (4, 'baz')])
    rl.blank_between(1, None)
    assert rl.items() == [(0, 'foo')]
示例#2
0
def test_change_between_changes_to_end_if_second_argument_None():
    rl = RunLengthList([(0, 'foo'), (2, 'bar'), (4, 'baz')])
    rl.change_between(1, None, 'qux')
    assert rl.items() == [(0, 'foo'), (1, 'qux')]
示例#3
0
def test_RunLengthList_copy_copies_non_empty():
    r = RunLengthList([(0, 'foo')])
    assert r == r.copy()
    assert not r.items() is r.copy().items()
示例#4
0
def test_add_change_works_on_top_of_existing_colour_definition():
    rl = RunLengthList([(0, 'foo'), (2, +20)])
    rl.add_change(2, -20)  #deliberately try and get it to the left
    assert rl.items() == [(0, 'foo'), (2, -20)]
示例#5
0
def test_RunLengthList_insertion_normalisation():
    r1 = RunLengthList([(0, 'foo'), (1, 'bar')])
    r2 = RunLengthList([(0, 'foo'), (1, 'bar')])
    r1.insert_list_at(1, 2, r2)
    assert r1.items() == [(0, 'foo'), (2, 'bar')], r1.items()
示例#6
0
def test_inserted_list_gets_chopped_if_not_enough_length():
    r1 = RunLengthList([(0, 'foo'), (1, 'bar')])
    r2 = RunLengthList([(0, 'baz'), (2, 'qux')])
    r1.insert_list_at(1, 1, r2)
    assert r1.items() == [(0, 'foo'), (1, 'baz'), (2, 'bar')]
示例#7
0
def test_copy_returns_different_lists():
    r = RunLengthList([(0, 'foo')])
    assert r.items() is not r.copy().items()
示例#8
0
def test_RunLengthList_insertion():
    r1 = RunLengthList([(0, 'foo'), (2, 'qux')])
    r2 = RunLengthList([(0, 'bar'), (2, 'baz')])
    r1.insert_list_at(1, 3, r2)
    assert r1.items() == [(0, 'foo'), (1, 'bar'), (3, 'baz'), (4, 'foo'),
                          (5, 'qux')], r1.items()
示例#9
0
def test_RunLengthList_blank_between():
    c = RunLengthList([(0, 'FOO'), (2, 'BAR'), (3, 'BAZ'), (4, 'QUX')])
    c.blank_between(2, 3)
    assert c.items() == [(0, 'FOO'), (3, 'BAZ'), (4, 'QUX')], c.items()
示例#10
0
def test_RunLengthList_add_change_normalises_afterwards():
    r = RunLengthList([(0, 'foo')])
    r.add_change(2, 'foo')
    r.add_change(1, 'bar')
    assert r.items() == [(0, 'foo'), (1, 'bar')]
示例#11
0
def test_RunlengthList_index_adjust_negative_adjustment_normalises():
    c = RunLengthList([(0, 'f'), (2, 'o'), (3, 'b')])
    c.index_adjust(1, -2)
    assert c.items() == [(0, 'f'), (1, 'b')]
示例#12
0
def test_RunLengthList_index_adjust_index_collision():
    c = RunLengthList([(0, 1), (3, 2)])
    c.index_adjust(3, 2)
    assert c.items() == [(0, 1), (5, 2)], c.items()
示例#13
0
def test_RunLengthList_index_adjust():
    c = RunLengthList([(0, 1), (3, 2), (6, 3)])
    c.index_adjust(2, 2)
    assert c.items() == [(0, 1), (5, 2), (8, 3)], c.items()
示例#14
0
def test_RunLengthList_add_change_already_got_index():
    c = RunLengthList([(0, 'foo'), (3, 'bar')])
    c.add_change(3, 'baz')
    assert c.items() == [(0, 'foo'), (3, 'baz')]
示例#15
0
def test_RunLengthList_add_change():
    c = RunLengthList([(0, 1), (3, 2)])
    c.add_change(1, 3)
    assert c.items() == [(0, 1), (1, 3), (3, 2)]