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)]
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')]
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')]
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)]