use assert_matches::assert_matches;

use crate::{test, ObjectType, Versioned as _};

use super::{cdr_version_and_report, Report, Version};

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

    test::setup();

    let Report {
        version,
        unexpected_fields,
    } = cdr_version_and_report(JSON.into()).unwrap();

    let cdr = assert_matches!(version, Version::Certain ( cdr ) => cdr );
    assert_matches!(cdr.version(), crate::Version::V211);

    test::assert_no_unexpected_fields(ObjectType::Cdr, &unexpected_fields);
}

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

    test::setup();

    let Report {
        version,
        unexpected_fields,
    } = cdr_version_and_report(JSON.into()).unwrap();

    let cdr = assert_matches!(version, Version::Certain ( cdr ) => cdr );
    assert_matches!(cdr.version(), crate::Version::V221);

    test::assert_no_unexpected_fields(ObjectType::Cdr, &unexpected_fields);
}
