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