use std::path::PathBuf; use fomod_manager::fomod::{self, FOModError}; fn get_parent() -> PathBuf { PathBuf::from(file!()).parent().unwrap().to_owned() } fn get_xml(filename: &str) -> PathBuf { get_parent().join(format!("data/fomod/moduleconfig/{}", filename)) } fn err_to_string(e: FOModError) -> String { match e { FOModError::Io(error) => format!("IO: {:?}", error), FOModError::Parse(de_error) => match de_error { quick_xml::DeError::UnexpectedStart(items) => { format!("UnexpectedStart: {}", str::from_utf8(&items).unwrap()) } _ => format!("Other: {:?}", de_error), }, } } #[test] fn parse() { for xml in [ "ineed.xml", "trade_barter.xml", "starui.xml", "example_01.xml", "example_02.xml", "example_03.xml", "example_04.xml", "example_05.xml", "banana.xml", "po3tweaks.xml" ] { fomod::Config::load_from_file(get_xml(xml)) .unwrap_or_else(|e| panic!("Parse for {xml} with {}", err_to_string(e))); } }