use crate::json::parse;

#[test_each::blob(glob = "ocpi-tariffs/test_data/json/y_*.json", name(segments = 1))]
fn should_accept_json(bytes: &[u8]) {
    let Ok(json) = std::str::from_utf8(bytes) else {
        // The parser can't accept non-UTF-8 input.
        return;
    };

    parse(json.into()).unwrap();
}

#[test_each::blob(glob = "ocpi-tariffs/test_data/json/i_*.json", name(segments = 1))]
fn should_accept_contentious_json(bytes: &[u8]) {
    let Ok(json) = std::str::from_utf8(bytes) else {
        // The parser can't accept non-UTF-8 input.
        return;
    };
    parse(json.into()).unwrap();
}

#[test_each::blob(glob = "ocpi-tariffs/test_data/json/n_*.json", name(segments = 1))]
fn should_reject_json(bytes: &[u8]) {
    let Ok(json) = std::str::from_utf8(bytes) else {
        // The parser can't accept non-UTF-8 input.
        return;
    };
    parse(json.into()).unwrap_err();
}
