use std::{error::Error, io};
use nwnrs_nwscript::prelude::NW_SCRIPT_SOURCE_RES_TYPE;
use nwnrs_types::test_support::{
read_resource_bytes, require_game_resource,
skip_if_game_resources_unavailable as skip_if_unavailable,
};
pub fn test_error(message: impl Into<String>) -> io::Error {
io::Error::other(message.into())
}
pub fn load_nss_bytes(path: &str) -> Result<Vec<u8>, Box<dyn Error>> {
let trimmed = path.trim();
let resref = trimmed.strip_suffix(".nss").unwrap_or(trimmed);
require_game_resource(read_resource_bytes(resref, NW_SCRIPT_SOURCE_RES_TYPE))
}
pub fn skip_if_game_resources_unavailable(error: Box<dyn Error>) -> Result<(), Box<dyn Error>> {
skip_if_unavailable(error)
}