programmieren-in-rust/aufgaben/sheet06/sol2/src/tests.rs

19 lines
467 B
Rust
Raw Normal View History

2016-12-05 17:57:47 +01:00
use Vector2;
#[test]
fn constructors() {
assert_eq!(Vector2::new(27, 42), Vector2 { x: 27, y: 42 });
assert_eq!(Vector2::origin(), Vector2 { x: 0, y: 0 });
assert_eq!(Vector2::unit_x(), Vector2 { x: 1, y: 0 });
assert_eq!(Vector2::unit_y(), Vector2 { x: 0, y: 1 });
}
#[test]
fn operators() {
let a = Vector2::new(3, 7);
let b = Vector2::new(-2, 5);
assert_eq!(a + b, Vector2::new(1, 12));
assert_eq!(a * 2, Vector2::new(6, 14));
}