I'm trying to write tests for my Rust program that is using the SPECS framework. I'm not sure how to run unit tests on the system's run
function because it uses the framework's storage types to read values. Does anyone have a good method for getting around this? Here is my code for a movement system:
use specs::prelude::*;
use crate::components::{Position, Velocity, Antenna};
pub struct Movement;
impl<'a> System<'a> for Movement {
type SystemData = (
WriteStorage<'a, Position>,
WriteStorage<'a, Velocity>,
);
fn run(&mut self, (mut position, velocity): Self::SystemData) {
for(pos, vel) in (&mut position, &velocity).join() {
pos.x += vel.x;
pos.y += vel.y;
}
}
}