我正在尝试为使用 SPECS 框架的 Rust 程序编写测试。我不确定如何对系统run
功能运行单元测试,因为它使用框架的存储类型来读取值。有没有人有解决这个问题的好方法?这是我的运动系统代码:
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;
}
}
}