forked from StrafesNET/strafe-client
fix worker tests
This commit is contained in:
parent
fa3972edfd
commit
915b05784e
@ -173,19 +173,24 @@ impl<'a,Task:Send+'a> INWorker<'a,Task>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test{
|
||||||
|
use super::{thread,QRWorker};
|
||||||
|
use crate::physics;
|
||||||
|
use strafesnet_common::{integer,instruction};
|
||||||
#[test]//How to run this test with printing: cargo test --release -- --nocapture
|
#[test]//How to run this test with printing: cargo test --release -- --nocapture
|
||||||
fn test_worker() {
|
fn test_worker() {
|
||||||
// Create the worker thread
|
// Create the worker thread
|
||||||
let test_body=crate::physics::Body::new(crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE,crate::integer::Time::ZERO);
|
let test_body=physics::Body::new(integer::Planar64Vec3::ONE,integer::Planar64Vec3::ONE,integer::Planar64Vec3::ONE,integer::Time::ZERO);
|
||||||
let worker=QRWorker::new(crate::physics::Body::default(),
|
let worker=QRWorker::new(physics::Body::default(),
|
||||||
|_|crate::physics::Body::new(crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE,crate::integer::Time::ZERO)
|
|_|physics::Body::new(integer::Planar64Vec3::ONE,integer::Planar64Vec3::ONE,integer::Planar64Vec3::ONE,integer::Time::ZERO)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send tasks to the worker
|
// Send tasks to the worker
|
||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
let task = strafesnet_common::instruction::TimedInstruction{
|
let task = instruction::TimedInstruction{
|
||||||
time:strafesnet_common::integer::Time::ZERO,
|
time:integer::Time::ZERO,
|
||||||
instruction:crate::physics::PhysicsInstruction::StrafeTick,
|
instruction:physics::PhysicsInstruction::StrafeTick,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
}
|
}
|
||||||
@ -197,9 +202,9 @@ fn test_worker() {
|
|||||||
thread::sleep(std::time::Duration::from_millis(10));
|
thread::sleep(std::time::Duration::from_millis(10));
|
||||||
|
|
||||||
// Send a new task
|
// Send a new task
|
||||||
let task = strafesnet_common::instruction::TimedInstruction{
|
let task = instruction::TimedInstruction{
|
||||||
time:strafesnet_common::integer::Time::ZERO,
|
time:integer::Time::ZERO,
|
||||||
instruction:crate::physics::PhysicsInstruction::StrafeTick,
|
instruction:physics::PhysicsInstruction::StrafeTick,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
|
|
||||||
@ -208,3 +213,4 @@ fn test_worker() {
|
|||||||
// wait long enough to see print from final task
|
// wait long enough to see print from final task
|
||||||
thread::sleep(std::time::Duration::from_millis(10));
|
thread::sleep(std::time::Duration::from_millis(10));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user