tests: add tests for Angle::normalize

This commit is contained in:
Ben Boeckel 2018-02-01 14:46:16 -05:00
parent 2d2c501074
commit 1b57dc93a5

View file

@ -19,6 +19,18 @@ extern crate cgmath;
use cgmath::{Angle, Deg, Rad}; use cgmath::{Angle, Deg, Rad};
#[test]
fn test_normalize() {
let angle: Rad<f64> = Rad::full_turn().normalize();
assert_ulps_eq!(&angle, &Rad(0f64));
let angle: Rad<f64> = (Rad::full_turn() + Rad::turn_div_4()).normalize();
assert_ulps_eq!(&angle, &Rad::turn_div_4());
let angle: Rad<f64> = (-Rad::turn_div_4()).normalize();
assert_ulps_eq!(&angle, &(Rad::full_turn() - Rad::turn_div_4()));
}
#[test] #[test]
fn test_normalize_signed() { fn test_normalize_signed() {
let angle: Rad<f64> = Rad::full_turn().normalize_signed(); let angle: Rad<f64> = Rad::full_turn().normalize_signed();