use points::Point; #[test] fn test_point_expressions() { // the origin point let p1: Point = Point::default(); let p2 = Point::new(1.0, 3.0); let p3 = Point::new(1.5, 2.5); // distance from origin let distance = p2.euclidean_norm(); assert_eq!(3.1622776601683795, distance); // execute a + b * 3 - c let result = p1 + p2 * 3.0 - p3; assert_eq!(Point::new(1.5, 6.5), result); // execute (a + b) - c let p1: Point = Point::default(); let p2 = Point::new(1.0, 3.0); let p3 = Point::new(1.5, 2.5); let result = (p1 + p2) - p3; assert_eq!(Point::new(-0.5, 0.5), result); // execute (a + b) * 3 + (a - c) let p1: Point = Point::default(); let p2 = Point::new(1.0, 3.0); let p3 = Point::new(1.5, 2.5); let result = (p1 + p2) * 3.0 + (p1 - p3); assert_eq!(Point::new(1.5, 6.5), result); }