it: split into modules
This commit is contained in:
integration-testing
1
integration-testing/.gitignore
vendored
Normal file
1
integration-testing/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/test_files
|
28
integration-testing/src/error.rs
Normal file
28
integration-testing/src/error.rs
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,10 @@
|
|||||||
use std::io::Cursor;
|
mod error;
|
||||||
use std::path::Path;
|
mod util;
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use error::ReplayError;
|
||||||
|
use util::read_entire_file;
|
||||||
use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext};
|
use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext};
|
||||||
|
|
||||||
fn main(){
|
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>{
|
fn run_replay()->Result<(),ReplayError>{
|
||||||
println!("loading map file..");
|
println!("loading map file..");
|
||||||
let data=read_entire_file("../tools/bhop_maps/5692113331.snfm")?;
|
let data=read_entire_file("../tools/bhop_maps/5692113331.snfm")?;
|
||||||
|
7
integration-testing/src/util.rs
Normal file
7
integration-testing/src/util.rs
Normal file
@ -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))
|
||||||
|
}
|
Reference in New Issue
Block a user