newton 0.5.1

A Newtonian physics simulator written in Rust.
Documentation
// Newton - A Newtonian physics simulator written in Rust.
// Copyright (C) 2017 Cooper Paul EdenDay
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Electronic mail: cedenday@protonmail.com

use units::{self, Eval};
use vector::Vector;

#[test]
fn simple_vector() {
    let _ = Vector::new([units::Length::new(0.0); 3]);
}

#[test]
fn partial_eq_vector() {
    let vector = Vector::new([units::Length::new(10.0); 3]);
    assert_eq!(vector, vector);
}

#[test]
fn vector_get() {
    let v0 = units::Length::new(1.0);
    let v1 = units::Length::new(5.0);
    let v2 = units::Length::new(10.0);
    let vector = Vector::new([v0, v1, v2]);
    assert_eq!(vector.get()[0].eval(), v0.eval());
    assert_eq!(vector.get()[1].eval(), v1.eval());
    assert_eq!(vector.get()[2].eval(), v2.eval());
}

#[test]
fn vector_add() {
    let target = Vector::new([units::Length::new(1.0); 3]);
    let base = Vector::new([units::Length::new(0.5); 3]);
    assert_eq!(base + base, target);
}

#[test]
fn vector_magnitude() {
    let vector = Vector::new([units::Length::new(1.0); 3]);
    assert_eq!(vector.magnitude().eval().powi(2).round() as usize, 3);
}