<commit_before>use super::*;

use buffer::*;

#[test]
fn output_zero() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![0], output);
}

#[test]
fn inc_by_one() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(1), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![1], output);
}

#[test]
fn inc_by_two() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(2), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![2], output);
}

#[test]
fn inc_by_one_and_by_one() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(1), Inc(1), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![2], output);
}

#[test]
fn inc_wrapping() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(255), Inc(1), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![0], output);
}

#[test]
fn dec_by_one() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(2), Dec(1), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![1], output);
}

#[test]
fn dec_by_two() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(2), Dec(2), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![0], output);
}

#[test]
fn dec_by_one_and_by_one() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Inc(3), Dec(1), Dec(1), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![1], output);
}

#[test]
fn dec_wrapping() {
    let mut input = IBuffer::from_str("");
    let mut output = Vec::new();
    Program { instructions: vec![Dec(1), Inc(2), Output] }.interp(&mut input, &mut output);
    assert_eq!(vec![1], output);
}<commit_msg>simplified test<commit_after>use super::*;

use buffer::*;

fn execute_and_check(program: &[Instruction], input: &str, exp_output: &[u8]) {
    let mut input = IBuffer::from_str(input);
    let mut output = Vec::new();
    Program { instructions: program.to_vec() }.interp(&mut input, &mut output);
    assert_eq!(exp_output, output.as_slice());
}

#[test]
fn output_zero() {
    execute_and_check(&[Output], "", &[0]);
}

#[test]
fn inc_by_one() {
    execute_and_check(&[Inc(1), Output], "", &[1]);
}

#[test]
fn inc_by_two() {
    execute_and_check(&[Inc(2), Output], "", &[2]);
}

#[test]
fn inc_by_one_and_by_one() {
    execute_and_check(&[Inc(1), Inc(1), Output], "", &[2]);
}

#[test]
fn inc_wrapping() {
    execute_and_check(&[Inc(255), Inc(1), Output], "", &[0]);
}

#[test]
fn dec_by_one() {
    execute_and_check(&[Inc(2), Dec(1), Output], "", &[1]);
}

#[test]
fn dec_by_two() {
    execute_and_check(&[Inc(2), Dec(2), Output], "", &[0]);
}

#[test]
fn dec_by_one_and_by_one() {
    execute_and_check(&[Inc(3), Dec(1), Dec(1), Output], "", &[1]);
}

#[test]
fn dec_wrapping() {
    execute_and_check(&[Dec(1), Inc(2), Output], "", &[1]);
}

#[test]
fn move_right() {
    execute_and_check(&[Inc(2), MoveRight(1), Inc(1), Output], "", &[1]);
}
{'fraction_non_alphanumeric': 0.22084440507824032, 'fraction_numerical': 0.01682905225863596, 'mean_word_length': 4.563218390804598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5406405', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1291, 'n_words': 296}