From e3d898865836d9d1b28e270e862277256d66df0c Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Fri, 30 Jul 2021 21:33:43 -0700 Subject: [PATCH] matrices: moving another doctest to unit --- rtchallenge/src/matrices.rs | 39 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/rtchallenge/src/matrices.rs b/rtchallenge/src/matrices.rs index ecd5492..b74ecc9 100644 --- a/rtchallenge/src/matrices.rs +++ b/rtchallenge/src/matrices.rs @@ -446,17 +446,6 @@ impl Mul for Matrix4x4 { type Output = Matrix4x4; /// Implement matrix multiplication for `Matrix4x4`. - /// - /// # Examples - /// ``` - /// use rtchallenge::matrices::Matrix4x4; - /// - /// let i = Matrix4x4::identity(); - /// let m1 = Matrix4x4::identity(); - /// let m2 = Matrix4x4::identity(); - /// - /// assert_eq!(m1 * m2, i); - /// ``` fn mul(self, m2: Matrix4x4) -> Matrix4x4 { let m1 = self; let mut r: Matrix4x4 = Default::default(); @@ -476,22 +465,6 @@ impl Mul for Matrix4x4 { type Output = Tuple; /// Implement matrix multiplication for `Matrix4x4` * `Tuple`. - /// - /// # Examples - /// ``` - /// use rtchallenge::matrices::Matrix4x4; - /// use rtchallenge::tuples::Tuple; - /// - /// let a = Matrix4x4::new( - /// [1., 2., 3., 4.], - /// [2., 4., 4., 2.], - /// [8., 6., 4., 1.], - /// [0., 0., 0., 1.], - /// ); - /// let b = Tuple::new(1., 2., 3., 1.); - /// - /// assert_eq!(a * b, Tuple::new(18., 24., 33., 1.)); - /// ``` fn mul(self, t: Tuple) -> Tuple { let m = self; Tuple { @@ -938,4 +911,16 @@ mod tests { ) ); } + #[test] + fn mul4x4_tuple() { + let a = Matrix4x4::new( + [1., 2., 3., 4.], + [2., 4., 4., 2.], + [8., 6., 4., 1.], + [0., 0., 0., 1.], + ); + let b = Tuple::new(1., 2., 3., 1.); + + assert_eq!(a * b, Tuple::new(18., 24., 33., 1.)); + } }