use serde::Deserialize;
use rsstacker::engine::prng::generate_sequence;

#[derive(Deserialize)]
struct PrngCase {
    seed: i64,
    n: usize,
    no_szo: bool,
    pieces: String,
}

#[derive(Deserialize)]
struct PrngFixture {
    cases: Vec<PrngCase>,
}

#[test]
fn prng_matches_fixture_sequences() {
    let raw = std::fs::read_to_string("tests/fixtures/prng.json").unwrap();
    let fixture: PrngFixture = serde_json::from_str(&raw).unwrap();
    assert!(!fixture.cases.is_empty());
    for case in fixture.cases {
        let got: String = generate_sequence(case.seed, case.n, case.no_szo)
            .into_iter()
            .collect();
        assert_eq!(
            got, case.pieces,
            "seed={} n={} no_szo={}",
            case.seed, case.n, case.no_szo
        );
    }
}
