Skip to content

Sink::skip_one doesn't modify the sink's length accordingly #497

@daniellga

Description

@daniellga

I am creating a new issue since I wasn't able to reopen #488 . I have this problem even after #494 .

#[cfg(test)]
mod tests {
    use rodio::{source::SineWave, OutputStream, Sink, Source};
    use std::time::Duration;

    #[test]
    fn skip_one_test() {
        let (_stream, stream_handle) = OutputStream::try_default().unwrap();
        let sink = Sink::try_new(&stream_handle).unwrap();
        let source = SineWave::new(440.0)
            .take_duration(Duration::from_secs_f32(5.))
            .amplify(0.20);
        let source2 = SineWave::new(440.0)
            .take_duration(Duration::from_secs_f32(5.))
            .amplify(0.20);

        sink.append(source);
        sink.append(source2);

        assert_eq!(sink.len(), 2); // OK as expected

        sink.skip_one();

        assert_eq!(sink.len(), 1); // shouln't this be true? I am getting sink.len() == 2 instead
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions