From 7dc6081d2341e5e574bd98c9efb833255f47d244 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 3 Mar 2014 09:57:16 +0100 Subject: [PATCH] [MathLib] Vector3: Tests for operator*=. --- MathLib/Vector3.h | 5 +++-- Tests/MathLib/TestVector3.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index e86056f2030..30bb7f3ea88 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -120,9 +120,10 @@ public: double s, TemplateVector3<T1> const& v); - TemplateVector3& operator*=(double pR) + TemplateVector3& operator*=(double s) { - for (std::size_t i(0); i < 3; i++) this->_x[i] *= pR; + for (std::size_t i(0); i < 3; i++) + this->_x[i] *= s; return *this; } diff --git a/Tests/MathLib/TestVector3.cpp b/Tests/MathLib/TestVector3.cpp index 95fb6b3aa81..ee62f012b6e 100644 --- a/Tests/MathLib/TestVector3.cpp +++ b/Tests/MathLib/TestVector3.cpp @@ -83,6 +83,13 @@ TEST(MathLib, TestVector3Operators) ASSERT_NEAR(-4.0, res[0], std::numeric_limits<double>::min()); ASSERT_NEAR( 0.0, res[1], std::numeric_limits<double>::min()); ASSERT_NEAR( 4.0, res[2], std::numeric_limits<double>::min()); + + // test operator*= + v *= 2.0; + ASSERT_NEAR(2.0, v[0], std::numeric_limits<double>::min()); + ASSERT_NEAR(6.0, v[1], std::numeric_limits<double>::min()); + ASSERT_NEAR(10.0, v[2], std::numeric_limits<double>::min()); + } TEST(MathLib, TestVector3Multiplications) -- GitLab