diff --git a/integration-testing/.gitignore b/integration-testing/.gitignore new file mode 100644 index 0000000..14dc8af --- /dev/null +++ b/integration-testing/.gitignore @@ -0,0 +1 @@ +/test_files diff --git a/integration-testing/src/error.rs b/integration-testing/src/error.rs new file mode 100644 index 0000000..fbc77dc --- /dev/null +++ b/integration-testing/src/error.rs @@ -0,0 +1,28 @@ +#[allow(unused)] +#[derive(Debug)] +pub enum ReplayError{ + IO(std::io::Error), + SNF(strafesnet_snf::Error), + SNFM(strafesnet_snf::map::Error), + SNFB(strafesnet_snf::bot::Error), +} +impl From<std::io::Error> for ReplayError{ + fn from(value:std::io::Error)->Self{ + Self::IO(value) + } +} +impl From<strafesnet_snf::Error> for ReplayError{ + fn from(value:strafesnet_snf::Error)->Self{ + Self::SNF(value) + } +} +impl From<strafesnet_snf::map::Error> for ReplayError{ + fn from(value:strafesnet_snf::map::Error)->Self{ + Self::SNFM(value) + } +} +impl From<strafesnet_snf::bot::Error> for ReplayError{ + fn from(value:strafesnet_snf::bot::Error)->Self{ + Self::SNFB(value) + } +} diff --git a/integration-testing/src/main.rs b/integration-testing/src/main.rs index f93abae..551aeb1 100644 --- a/integration-testing/src/main.rs +++ b/integration-testing/src/main.rs @@ -1,7 +1,10 @@ -use std::io::Cursor; -use std::path::Path; +mod error; +mod util; + use std::time::Instant; +use error::ReplayError; +use util::read_entire_file; use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext}; fn main(){ @@ -13,40 +16,6 @@ fn main(){ } } -#[allow(unused)] -#[derive(Debug)] -enum ReplayError{ - IO(std::io::Error), - SNF(strafesnet_snf::Error), - SNFM(strafesnet_snf::map::Error), - SNFB(strafesnet_snf::bot::Error), -} -impl From<std::io::Error> for ReplayError{ - fn from(value:std::io::Error)->Self{ - Self::IO(value) - } -} -impl From<strafesnet_snf::Error> for ReplayError{ - fn from(value:strafesnet_snf::Error)->Self{ - Self::SNF(value) - } -} -impl From<strafesnet_snf::map::Error> for ReplayError{ - fn from(value:strafesnet_snf::map::Error)->Self{ - Self::SNFM(value) - } -} -impl From<strafesnet_snf::bot::Error> for ReplayError{ - fn from(value:strafesnet_snf::bot::Error)->Self{ - Self::SNFB(value) - } -} - -fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{ - let data=std::fs::read(path)?; - Ok(Cursor::new(data)) -} - fn run_replay()->Result<(),ReplayError>{ println!("loading map file.."); let data=read_entire_file("../tools/bhop_maps/5692113331.snfm")?; diff --git a/integration-testing/src/util.rs b/integration-testing/src/util.rs new file mode 100644 index 0000000..e1295a4 --- /dev/null +++ b/integration-testing/src/util.rs @@ -0,0 +1,7 @@ +use std::io::Cursor; +use std::path::Path; + +pub fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{ + let data=std::fs::read(path)?; + Ok(Cursor::new(data)) +}