#![feature(test)]
extern crate test;
use std::process::Termination;

use mossfets_game_of_life::reader;
use mossfets_game_of_life::writer;
use test::Bencher;

#[test]
fn test_file_read() {
    assert!(reader::read_game_at_path("tests/cells/gospel.cells").is_ok());
}

#[bench]
fn test_spacefiller_perf (b: &mut Bencher) -> impl Termination{
    let game = reader::read_game_at_path("tests/cells/spacefiller.cells").unwrap();
    for _ in game.take(100) {
    }
    assert!(true);
}

#[bench]
fn test_rpentomino_perf (b: &mut Bencher) -> impl Termination{
    let game = reader::read_game_at_path("tests/cells/rpentomino.cells").unwrap();
    for _ in game.take(300) {
    }
    assert!(true);
}

#[test]
fn test_file_write() {
    let game = reader::read_game_at_path("tests/cells/spacefiller.cells".into()).unwrap();
    assert!(writer::write_game_at_path("/tmp/e".into(), &game).is_ok());
}
