'Verify that sustain control handles repeated notes correctly.
For example, a single pitch played before sustain:
x-- x-- x--
After sustain:
x---x---x--
Notes should be extended until either the end of the sustain control or the
beginning of another note of the same pitch.'

def testApplySustainControlChangesWithRepeatedNotes(self):

    sequence = copy.copy(self.note_sequence)
    testing_lib.add_control_changes_to_sequence(sequence, 0, [(1.0, 64, 127), (4.0, 64, 0)])
    expected_sequence = copy.copy(sequence)
    testing_lib.add_track_to_sequence(sequence, 0, [(60, 100, 0.25, 1.5), (60, 100, 1.25, 1.5), (72, 100, 2.0, 3.5), (60, 100, 2.0, 3.0), (60, 100, 3.5, 4.5)])
    testing_lib.add_track_to_sequence(expected_sequence, 0, [(60, 100, 0.25, 1.25), (60, 100, 1.25, 2.0), (72, 100, 2.0, 4.0), (60, 100, 2.0, 3.5), (60, 100, 3.5, 4.5)])
    sus_sequence = sequences_lib.apply_sustain_control_changes(sequence)
    self.assertProtoEquals(expected_sequence, sus_sequence)
