+ // let a = Dimension::from(("a".to_string(), "b".to_string())).area(); // this doesn't work, because area() is not implemented for String
+ }
+
+ #[test]
+ fn intersection_of_lines() {
+ let p1 = point!(0.0, 0.0);
+ let p2 = point!(2.0, 2.0);
+ let p3 = point!(0.0, 2.0);
+ let p4 = point!(2.0, 0.0);
+ let r = Intersection::lines(p1, p2, p3, p4);
+ if let Intersection::Point(p) = r {
+ assert_eq!(p, point!(1.0, 1.0));
+ } else {
+ panic!();
+ }
+ }
+
+ #[test]
+ fn some_coordinates_on_line() {
+ // horizontally up
+ let coords = supercover_line(point!(0.0, 0.0), point!(3.3, 2.2));
+ assert_eq!(coords.as_slice(), &[point!(0, 0), point!(1, 0), point!(1, 1), point!(2, 1), point!(2, 2), point!(3, 2)]);
+
+ // horizontally down
+ let coords = supercover_line(point!(0.0, 5.0), point!(3.3, 2.2));
+ assert_eq!(coords.as_slice(), &[point!(0, 5), point!(0, 4), point!(1, 4), point!(1, 3), point!(2, 3), point!(2, 2), point!(3, 2)]);
+
+ // vertically right
+ let coords = supercover_line(point!(0.0, 0.0), point!(2.2, 3.3));
+ assert_eq!(coords.as_slice(), &[point!(0, 0), point!(0, 1), point!(1, 1), point!(1, 2), point!(2, 2), point!(2, 3)]);
+
+ // vertically left
+ let coords = supercover_line(point!(5.0, 0.0), point!(3.0, 3.0));
+ assert_eq!(coords.as_slice(), &[point!(5, 0), point!(4, 0), point!(4, 1), point!(3, 1), point!(3, 2), point!(3, 3)]);
+
+ // negative
+ let coords = supercover_line(point!(0.0, 0.0), point!(-3.0, -2.0));
+ assert_eq!(coords.as_slice(), &[point!(-3, -2), point!(-2, -2), point!(-2, -1), point!(-1, -1), point!(-1, 0), point!(0, 0)]);
+
+ //
+ let coords = supercover_line(point!(0.0, 0.0), point!(2.3, 1.1));
+ assert_eq!(coords.as_slice(), &[point!(0, 0), point!(1, 0), point!(2, 0), point!(2, 1)]);