use std::assert_matches;

use super::Version;
use crate::{cdr, json, test, Versioned as _};

#[test]
fn should_guess_cdr_version_v211() {
    const JSON: &str = include_str!("../../test_data/v211/every_field_set/cdr.json");

    test::setup();

    let cdr = json::parse_object(JSON).unwrap();
    let version = cdr::infer_version(cdr);

    let Version::Certain(cdr) = version else {
        panic!("expected a certain version, got {version:?}");
    };
    assert_matches!(cdr.version(), crate::Version::V211);
}

#[test]
fn should_guess_cdr_version_v221() {
    const JSON: &str = include_str!("../../test_data/v221/every_field_set/cdr.json");

    test::setup();

    let cdr = json::parse_object(JSON).unwrap();
    let version = cdr::infer_version(cdr);

    let Version::Certain(cdr) = version else {
        panic!("expected a certain version, got {version:?}");
    };
    assert_matches!(cdr.version(), crate::Version::V221);
}
