From bd00adc437305bf4e99e66b4351fa661b606f3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 3 Aug 2013 19:30:20 +0200 Subject: [PATCH] Math: test copy construction from base classes. Copy construction from the same class should just work. --- src/Math/DualComplex.h | 6 +++--- src/Math/DualQuaternion.h | 7 +++---- src/Math/Test/DualComplexTest.cpp | 2 +- src/Math/Test/DualQuaternionTest.cpp | 2 +- src/Math/Test/Matrix3Test.cpp | 6 +++--- src/Math/Test/Matrix4Test.cpp | 8 ++++---- src/Math/Test/MatrixTest.cpp | 8 ++++---- src/Math/Test/Vector2Test.cpp | 2 +- src/Math/Test/Vector3Test.cpp | 2 +- src/Math/Test/Vector4Test.cpp | 2 +- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Math/DualComplex.h b/src/Math/DualComplex.h index 9ee19f2e9..5cde5f0ad 100644 --- a/src/Math/DualComplex.h +++ b/src/Math/DualComplex.h @@ -126,6 +126,9 @@ template class DualComplex: public Dual> { constexpr explicit DualComplex(const Vector2& vector): Dual>({}, Complex(vector)) {} #endif + /** @brief Copy constructor */ + constexpr DualComplex(const Dual>& other): Dual>(other) {} + /** * @brief Whether the dual complex number is normalized * @@ -320,9 +323,6 @@ template class DualComplex: public Dual> { #endif private: - /* Used by Dual operators and dualConjugated() */ - constexpr DualComplex(const Dual>& other): Dual>(other) {} - /* Just to be sure nobody uses this, as it wouldn't probably work with our operator*() */ using Dual>::operator*; diff --git a/src/Math/DualQuaternion.h b/src/Math/DualQuaternion.h index cead7637a..a1fd0526b 100644 --- a/src/Math/DualQuaternion.h +++ b/src/Math/DualQuaternion.h @@ -132,6 +132,9 @@ template class DualQuaternion: public Dual> { constexpr explicit DualQuaternion(const Vector3& vector): Dual>({}, {vector, T(0)}) {} #endif + /** @brief Copy constructor */ + constexpr DualQuaternion(const Dual>& other): Dual>(other) {} + /** * @brief Whether the dual quaternion is normalized * @@ -309,10 +312,6 @@ template class DualQuaternion: public Dual> { } MAGNUM_DUAL_SUBCLASS_IMPLEMENTATION(DualQuaternion, Quaternion) - - private: - /* Used by Dual operators and dualConjugated() */ - constexpr DualQuaternion(const Dual>& other): Dual>(other) {} }; /** @debugoperator{Magnum::Math::DualQuaternion} */ diff --git a/src/Math/Test/DualComplexTest.cpp b/src/Math/Test/DualComplexTest.cpp index bd34f77b4..6e6c5d554 100644 --- a/src/Math/Test/DualComplexTest.cpp +++ b/src/Math/Test/DualComplexTest.cpp @@ -127,7 +127,7 @@ void DualComplexTest::constructFromVector() { } void DualComplexTest::constructCopy() { - constexpr DualComplex a({-1.0f, 2.5f}, {3.0f, -7.5f}); + constexpr Math::Dual a({-1.0f, 2.5f}, {3.0f, -7.5f}); constexpr DualComplex b(a); CORRADE_COMPARE(b, DualComplex({-1.0f, 2.5f}, {3.0f, -7.5f})); } diff --git a/src/Math/Test/DualQuaternionTest.cpp b/src/Math/Test/DualQuaternionTest.cpp index 93e364e94..db7a7e653 100644 --- a/src/Math/Test/DualQuaternionTest.cpp +++ b/src/Math/Test/DualQuaternionTest.cpp @@ -125,7 +125,7 @@ void DualQuaternionTest::constructFromVector() { } void DualQuaternionTest::constructCopy() { - constexpr DualQuaternion a({{1.0f, 2.0f, -3.0f}, -3.5f}, {{4.5f, -7.0f, 2.0f}, 1.0f}); + constexpr Math::Dual a({{1.0f, 2.0f, -3.0f}, -3.5f}, {{4.5f, -7.0f, 2.0f}, 1.0f}); constexpr DualQuaternion b(a); CORRADE_COMPARE(b, DualQuaternion({{1.0f, 2.0f, -3.0f}, -3.5f}, {{4.5f, -7.0f, 2.0f}, 1.0f})); } diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 1a9921392..efadb60af 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -173,9 +173,9 @@ void Matrix3Test::constructConversion() { } void Matrix3Test::constructCopy() { - constexpr Matrix3 a({3.0f, 5.0f, 8.0f}, - {4.5f, 4.0f, 7.0f}, - {7.9f, -1.0f, 8.0f}); + constexpr RectangularMatrix<3, 3, Float> a(Vector<3, Float>(3.0f, 5.0f, 8.0f), + Vector<3, Float>(4.5f, 4.0f, 7.0f), + Vector<3, Float>(7.9f, -1.0f, 8.0f)); constexpr Matrix3 b(a); CORRADE_COMPARE(b, Matrix3({3.0f, 5.0f, 8.0f}, {4.5f, 4.0f, 7.0f}, diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index 4e87dcbf4..31659580a 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -193,10 +193,10 @@ void Matrix4Test::constructConversion() { } void Matrix4Test::constructCopy() { - constexpr Matrix4 a({3.0f, 5.0f, 8.0f, -3.0f}, - {4.5f, 4.0f, 7.0f, 2.0f}, - {1.0f, 2.0f, 3.0f, -1.0f}, - {7.9f, -1.0f, 8.0f, -1.5f}); + constexpr Matrix<4, Float> a(Vector<4, Float>(3.0f, 5.0f, 8.0f, -3.0f), + Vector<4, Float>(4.5f, 4.0f, 7.0f, 2.0f), + Vector<4, Float>(1.0f, 2.0f, 3.0f, -1.0f), + Vector<4, Float>(7.9f, -1.0f, 8.0f, -1.5f)); constexpr Matrix4 b(a); CORRADE_COMPARE(b, Matrix4({3.0f, 5.0f, 8.0f, -3.0f}, {4.5f, 4.0f, 7.0f, 2.0f}, diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 7d51cf0c3..9ba7c95b5 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -166,10 +166,10 @@ void MatrixTest::constructConversion() { } void MatrixTest::constructCopy() { - constexpr Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f), - Vector4(4.5f, 4.0f, 7.0f, 2.0f), - Vector4(1.0f, 2.0f, 3.0f, -1.0f), - Vector4(7.9f, -1.0f, 8.0f, -1.5f)); + constexpr RectangularMatrix<4, 4, Float> a(Vector4(3.0f, 5.0f, 8.0f, -3.0f), + Vector4(4.5f, 4.0f, 7.0f, 2.0f), + Vector4(1.0f, 2.0f, 3.0f, -1.0f), + Vector4(7.9f, -1.0f, 8.0f, -1.5f)); constexpr Matrix4 b(a); CORRADE_COMPARE(b, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f), Vector4(4.5f, 4.0f, 7.0f, 2.0f), diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index af7629461..1ef3f77ba 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -131,7 +131,7 @@ void Vector2Test::constructConversion() { } void Vector2Test::constructCopy() { - constexpr Vector2 a(1.5f, 2.5f); + constexpr Vector<2, Float> a(1.5f, 2.5f); constexpr Vector2 b(a); CORRADE_COMPARE(b, Vector2(1.5f, 2.5f)); } diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index 992d96de2..4a5e46405 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -139,7 +139,7 @@ void Vector3Test::constructConversion() { } void Vector3Test::constructCopy() { - constexpr Vector3 a(1.0f, 2.5f, -3.0f); + constexpr Vector<3, Float> a(1.0f, 2.5f, -3.0f); constexpr Vector3 b(a); CORRADE_COMPARE(b, Vector3(1.0f, 2.5f, -3.0f)); } diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index 24e89a9b8..5028a82a5 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -136,7 +136,7 @@ void Vector4Test::constructConversion() { } void Vector4Test::constructCopy() { - constexpr Vector4 a(1.0f, -2.5f, 3.0f, 4.1f); + constexpr Vector<4, Float> a(1.0f, -2.5f, 3.0f, 4.1f); constexpr Vector4 b(a); CORRADE_COMPARE(b, Vector4(1.0f, -2.5f, 3.0f, 4.1f)); }