<commit_before>extern crate circular_buffer;

#[allow(unused_must_use)]
mod tests {

    use circular_buffer::{CircularBuffer, Error};

    #[test]
    fn error_on_read_empty_buffer() {
        let mut buffer = CircularBuffer::<char>::new(1);
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    }

    #[test]
    #[ignore]
    fn write_and_read_back_item() {
        let mut buffer = CircularBuffer::new(1);
        buffer.write('1');
        assert_eq!(Ok('1'), buffer.read());
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    }

    #[test]
    #[ignore]
    fn write_and_read_back_multiple_items() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write('1');
        buffer.write('2');
        assert_eq!(Ok('1'), buffer.read());
        assert_eq!(Ok('2'), buffer.read());
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    }

    #[test]
    #[ignore]
    fn alternate_write_and_read() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write('1');
        assert_eq!(Ok('1'), buffer.read());
        buffer.write('2');
        assert_eq!(Ok('2'), buffer.read());
    }

    #[test]
    #[ignore]
    fn clear_buffer() {
        let mut buffer = CircularBuffer::new(3);
        buffer.write('1');
        buffer.write('2');
        buffer.write('3');
        buffer.clear();
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
        buffer.write('1');
        buffer.write('2');
        assert_eq!(Ok('1'), buffer.read());
        buffer.write('3');
        assert_eq!(Ok('2'), buffer.read());
    }

    #[test]
    #[ignore]
    fn full_buffer_error() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write('1');
        buffer.write('2');
        assert_eq!(Err(Error::FullBuffer), buffer.write('3'));
    }

    #[test]
    #[ignore]
    fn overwrite_item_in_non_full_buffer() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write('1');
        buffer.overwrite('2');
        assert_eq!(Ok('1'), buffer.read());
        assert_eq!(Ok('2'), buffer.read());
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    }

    #[test]
    #[ignore]
    fn overwrite_item_in_full_buffer() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write('1');
        buffer.write('2');
        buffer.overwrite('A');
        assert_eq!(Ok('2'), buffer.read());
        assert_eq!(Ok('A'), buffer.read());
    }

    #[test]
    #[ignore]
    fn integer_buffer() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write(1);
        buffer.write(2);
        assert_eq!(Ok(1), buffer.read());
        buffer.write(-1);
        assert_eq!(Ok(2), buffer.read());
        assert_eq!(Ok(-1), buffer.read());
        assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    }

    #[test]
    #[ignore]
    fn string_buffer() {
        let mut buffer = CircularBuffer::new(2);
        buffer.write("".to_string());
        buffer.write("Testing".to_string());
        assert_eq!(0, buffer.read().unwrap().len());
        assert_eq!(Ok("Testing".to_string()), buffer.read());
    }
}<commit_msg>circular buffer: remove allow(unused_must_use) (#490)<commit_after>extern crate circular_buffer;
use circular_buffer::{CircularBuffer, Error};

#[test]
fn error_on_read_empty_buffer() {
    let mut buffer = CircularBuffer::<char>::new(1);
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}

#[test]
#[ignore]
fn write_and_read_back_item() {
    let mut buffer = CircularBuffer::new(1);
    assert!(buffer.write('1').is_ok());
    assert_eq!(Ok('1'), buffer.read());
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}

#[test]
#[ignore]
fn write_and_read_back_multiple_items() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write('1').is_ok());
    assert!(buffer.write('2').is_ok());
    assert_eq!(Ok('1'), buffer.read());
    assert_eq!(Ok('2'), buffer.read());
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}

#[test]
#[ignore]
fn alternate_write_and_read() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write('1').is_ok());
    assert_eq!(Ok('1'), buffer.read());
    assert!(buffer.write('2').is_ok());
    assert_eq!(Ok('2'), buffer.read());
}

#[test]
#[ignore]
fn clear_buffer() {
    let mut buffer = CircularBuffer::new(3);
    assert!(buffer.write('1').is_ok());
    assert!(buffer.write('2').is_ok());
    assert!(buffer.write('3').is_ok());
    buffer.clear();
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
    assert!(buffer.write('1').is_ok());
    assert!(buffer.write('2').is_ok());
    assert_eq!(Ok('1'), buffer.read());
    assert!(buffer.write('3').is_ok());
    assert_eq!(Ok('2'), buffer.read());
}

#[test]
#[ignore]
fn full_buffer_error() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write('1').is_ok());
    assert!(buffer.write('2').is_ok());
    assert_eq!(Err(Error::FullBuffer), buffer.write('3'));
}

#[test]
#[ignore]
fn overwrite_item_in_non_full_buffer() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write('1').is_ok());
    buffer.overwrite('2');
    assert_eq!(Ok('1'), buffer.read());
    assert_eq!(Ok('2'), buffer.read());
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}

#[test]
#[ignore]
fn overwrite_item_in_full_buffer() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write('1').is_ok());
    assert!(buffer.write('2').is_ok());
    buffer.overwrite('A');
    assert_eq!(Ok('2'), buffer.read());
    assert_eq!(Ok('A'), buffer.read());
}

#[test]
#[ignore]
fn integer_buffer() {
    let mut buffer = CircularBuffer::new(2);
    assert!(buffer.write(1).is_ok());
    assert!(buffer.write(2).is_ok());
    assert_eq!(Ok(1), buffer.read());
    assert!(buffer.write(-1).is_ok());
    assert_eq!(Ok(2), buffer.read());
    assert_eq!(Ok(-1), buffer.read());
    assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}

#[test]
#[ignore]
fn string_buffer() {
    let mut buffer = CircularBuffer::new(2);
    buffer.write("".to_string()).unwrap();
    buffer.write("Testing".to_string()).unwrap();
    assert_eq!(0, buffer.read().unwrap().len());
    assert_eq!(Ok("Testing".to_string()), buffer.read());
}
{'fraction_non_alphanumeric': 0.21177038109020743, 'fraction_numerical': 0.014954172696575013, 'mean_word_length': 3.5302257829570283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1685709', 'n_tokens_mistral': 2069, 'n_tokens_neox': 2095, 'n_words': 317}