use units::{self, Eval};
use vector::Vector;
use body::Body;
#[test]
fn simple_body() {
let _ = Body::new(units::Time::new(1.0),
units::Mass::new(1.0),
Vector::new([units::Length::new(0.0); 3]),
None);
}
#[test]
fn body_get_position() {
let position = Vector::new([units::Length::new(5.0); 3]);
let body = Body::new(units::Time::new(1.0), units::Mass::new(1.0), position, None);
assert_eq!(body.get_position(), position);
}
#[test]
fn body_get_velocity() {
let velocity = Vector::new([units::Velocity::new(5.0); 3]);
let body = Body::new(units::Time::new(1.0),
units::Mass::new(1.0),
Vector::new([units::Length::new(0.0); 3]),
Some(velocity));
assert_eq!(body.get_velocity(), velocity);
}
#[test]
fn body_force() {
let mut body = Body::new(units::Time::new(1.0),
units::Mass::new(2.0),
Vector::new([units::Length::new(0.0); 3]),
None);
let force = Vector::new([units::Force::new(1.0); 3]);
body.apply_force(force);
let acceleration = Vector::new([units::Acceleration::new(0.5); 3]);
assert_eq!(body.get_acceleration(), acceleration);
}
#[test]
fn body_direction() {
let b0 = Body::new(units::Time::new(1.0),
units::Mass::new(1.0),
Vector::new([units::Length::new(0.0); 3]),
None);
let b1 = Body::new(units::Time::new(1.0),
units::Mass::new(1.0),
Vector::new([units::Length::new(1.0); 3]),
None);
let expected = Vector::new([units::Length::new(1.0); 3]).normalize();
assert_eq!(b0.direction(&b1), expected);
}