use std::str;

use interpreter::Interpretable;
use result::BfResult;

pub const FACTOR_SRC: &'static [u8] = include_bytes!("../bf/factor.bf");

pub const HELLO_WORLD_SRC: &'static [u8] =
    b"++++++[>++++++++++++<-]>.\
      >++++++++++[>++++++++++<-]>+.\
      +++++++..+++.>++++[>+++++++++++<-]>.\
      <+++[>----<-]>.<<<<<+++[>+++++<-]>.\
      >>.+++.------.--------.>>+.";

pub fn assert_interpret<I: Interpretable + ?Sized>(program: &I, input: &[u8], output: &[u8]) {
    let actual: BfResult<String> = program.interpret_memory(None, input)
        .map(|output| str::from_utf8(&output).unwrap().to_owned());
    let expected: BfResult<String> = Ok(str::from_utf8(output).unwrap().to_owned());

    assert_eq!(actual, expected);
}

use std::str;

use interpreter::Interpretable;

pub const FACTOR_SRC: &'static [u8] = include_bytes!("../bf/factor.bf");

pub const HELLO_WORLD_SRC: &'static [u8] =
    b"++++++[>++++++++++++<-]>.\
      >++++++++++[>++++++++++<-]>+.\
      +++++++..+++.>++++[>+++++++++++<-]>.\
      <+++[>----<-]>.<<<<<+++[>+++++<-]>.\
      >>.+++.------.--------.>>+.";

pub fn assert_interpret<I: Interpretable + ?Sized>(program: &I, input: &[u8], output: &[u8]) {
    let actual_bytes = program.interpret_memory(None, input).unwrap();
    let actual = str::from_utf8(&actual_bytes).unwrap();
    let expected = str::from_utf8(output).unwrap();

    assert_eq!(actual, expected);
}

Make assert_interpret a bit simpler.
Make assert_interpret a bit simpler.
