From 8c7679c7b1ca8e045bc0cf51fcf31e884cf3b161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 23 Jan 2024 21:40:43 +0100 Subject: [PATCH] Math: use typedefs from Magnum.h in all tests. For some reason a lot of these got forgotten in b2c353bf21cb8da37e68431434b0841bf8ad3e30. Also adding a comment explaining the difference, because it's likely to stop being obvious few months from now. --- src/Magnum/Math/Test/BezierTest.cpp | 2 ++ src/Magnum/Math/Test/DualComplexTest.cpp | 2 ++ src/Magnum/Math/Test/DualQuaternionTest.cpp | 2 ++ src/Magnum/Math/Test/DualTest.cpp | 2 ++ src/Magnum/Math/Test/FunctionsBenchmark.cpp | 6 +++--- .../Math/Test/InterpolationBenchmark.cpp | 6 +++--- .../Math/Test/IntersectionBenchmark.cpp | 16 ++++++++-------- src/Magnum/Math/Test/Matrix3Test.cpp | 2 ++ src/Magnum/Math/Test/Matrix4Test.cpp | 2 ++ src/Magnum/Math/Test/MatrixBenchmark.cpp | 10 +++++----- src/Magnum/Math/Test/MatrixTest.cpp | 3 +++ .../Math/Test/RectangularMatrixTest.cpp | 19 +++++++++---------- src/Magnum/Math/Test/SwizzleTest.cpp | 1 + src/Magnum/Math/Test/UnitTest.cpp | 2 ++ src/Magnum/Math/Test/VectorBenchmark.cpp | 6 +++--- src/Magnum/Math/Test/VectorTest.cpp | 7 +++---- 16 files changed, 52 insertions(+), 36 deletions(-) diff --git a/src/Magnum/Math/Test/BezierTest.cpp b/src/Magnum/Math/Test/BezierTest.cpp index 93cb3b954..6ff7ceae2 100644 --- a/src/Magnum/Math/Test/BezierTest.cpp +++ b/src/Magnum/Math/Test/BezierTest.cpp @@ -56,6 +56,8 @@ template<> struct BezierConverter<2, 2, Float, QBezier2D> { namespace Test { namespace { +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Vector2; typedef Math::Bezier<1, 2, Float> LinearBezier2D; using Magnum::QuadraticBezier2D; diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index 237464651..59454c0a7 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/src/Magnum/Math/Test/DualComplexTest.cpp @@ -103,6 +103,8 @@ struct DualComplexTest: TestSuite::Tester { using namespace Math::Literals; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Deg; using Magnum::Rad; using Magnum::Complex; diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index e628de10e..9f3e2b093 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/src/Magnum/Math/Test/DualQuaternionTest.cpp @@ -110,6 +110,8 @@ struct DualQuaternionTest: TestSuite::Tester { void debug(); }; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Deg; using Magnum::Rad; typedef Math::Dual Dual; diff --git a/src/Magnum/Math/Test/DualTest.cpp b/src/Magnum/Math/Test/DualTest.cpp index a0df8e268..eb1cadd5d 100644 --- a/src/Magnum/Math/Test/DualTest.cpp +++ b/src/Magnum/Math/Test/DualTest.cpp @@ -68,6 +68,8 @@ struct DualTest: TestSuite::Tester { void debug(); }; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ typedef Math::Dual Dual; using Magnum::Vector2; typedef Math::Dual DualVector2; diff --git a/src/Magnum/Math/Test/FunctionsBenchmark.cpp b/src/Magnum/Math/Test/FunctionsBenchmark.cpp index 538c53e12..c6582106b 100644 --- a/src/Magnum/Math/Test/FunctionsBenchmark.cpp +++ b/src/Magnum/Math/Test/FunctionsBenchmark.cpp @@ -68,9 +68,9 @@ FunctionsBenchmark::FunctionsBenchmark() { &FunctionsBenchmark::sinCosCombined}, 100); } -typedef Math::Constants Constants; -typedef Math::Deg Deg; -typedef Math::Rad Rad; +using Magnum::Constants; +using Magnum::Deg; +using Magnum::Rad; enum: std::size_t { Repeats = 100000 }; diff --git a/src/Magnum/Math/Test/InterpolationBenchmark.cpp b/src/Magnum/Math/Test/InterpolationBenchmark.cpp index 4b5804d64..9a4fb5d6a 100644 --- a/src/Magnum/Math/Test/InterpolationBenchmark.cpp +++ b/src/Magnum/Math/Test/InterpolationBenchmark.cpp @@ -47,9 +47,9 @@ struct InterpolationBenchmark: TestSuite::Tester { using namespace Math::Literals; -typedef Math::Quaternion Quaternion; -typedef Math::DualQuaternion DualQuaternion; -typedef Math::Vector3 Vector3; +using Magnum::Quaternion; +using Magnum::DualQuaternion; +using Magnum::Vector3; InterpolationBenchmark::InterpolationBenchmark() { addBenchmarks({&InterpolationBenchmark::baseline, diff --git a/src/Magnum/Math/Test/IntersectionBenchmark.cpp b/src/Magnum/Math/Test/IntersectionBenchmark.cpp index 5e3e9cb8e..efcb2b735 100644 --- a/src/Magnum/Math/Test/IntersectionBenchmark.cpp +++ b/src/Magnum/Math/Test/IntersectionBenchmark.cpp @@ -87,14 +87,14 @@ Math::Matrix4 coneViewFromCone(const Math::Vector3& origin, const Math::Ve return Math::Matrix4::lookAt(origin, origin + normal, Math::Vector3::yAxis()).inverted(); } -typedef Math::Vector2 Vector2; -typedef Math::Vector3 Vector3; -typedef Math::Vector4 Vector4; -typedef Math::Matrix4 Matrix4; -typedef Math::Frustum Frustum; -typedef Math::Range3D Range3D; -typedef Math::Deg Deg; -typedef Math::Rad Rad; +using Magnum::Vector2; +using Magnum::Vector3; +using Magnum::Vector4; +using Magnum::Matrix4; +using Magnum::Frustum; +using Magnum::Range3D; +using Magnum::Deg; +using Magnum::Rad; struct IntersectionBenchmark: TestSuite::Tester { explicit IntersectionBenchmark(); diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index f46b8bbe0..5e686a2c2 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -104,6 +104,8 @@ struct Matrix3Test: TestSuite::Tester { void debug(); }; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Deg; using Magnum::Matrix2x2; using Magnum::Matrix2x4; diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 345efbe17..64b7af106 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -124,6 +124,8 @@ struct Matrix4Test: TestSuite::Tester { void debug(); }; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Deg; using Magnum::Rad; using Magnum::Matrix2x2; diff --git a/src/Magnum/Math/Test/MatrixBenchmark.cpp b/src/Magnum/Math/Test/MatrixBenchmark.cpp index ba01b1494..27a226c58 100644 --- a/src/Magnum/Math/Test/MatrixBenchmark.cpp +++ b/src/Magnum/Math/Test/MatrixBenchmark.cpp @@ -75,11 +75,11 @@ MatrixBenchmark::MatrixBenchmark() { &MatrixBenchmark::transformPoint4}, 1000); } -typedef Math::Vector2 Vector2; -typedef Math::Vector3 Vector3; -typedef Math::Vector4 Vector4; -typedef Math::Matrix4 Matrix4; -typedef Math::Matrix3 Matrix3; +using Magnum::Vector2; +using Magnum::Vector3; +using Magnum::Vector4; +using Magnum::Matrix4; +using Magnum::Matrix3; enum: std::size_t { Repeats = 10000 }; diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 3709622bf..986f215c4 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -89,6 +89,9 @@ struct MatrixTest: TestSuite::Tester { void debug(); }; + +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ using Magnum::Matrix2x2; using Magnum::Matrix2x3; using Magnum::Matrix3x3; diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index 96c53681e..7ff5dba98 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -99,18 +99,21 @@ struct RectangularMatrixTest: TestSuite::Tester { void debugPacked(); }; -typedef RectangularMatrix<4, 3, Float> Matrix4x3; -typedef RectangularMatrix<4, 2, Float> Matrix4x2; -typedef RectangularMatrix<3, 4, Float> Matrix3x4; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ +using Magnum::Matrix4x3; +using Magnum::Matrix4x2; +using Magnum::Matrix3x4; typedef RectangularMatrix<3, 3, Float> Matrix3x3; -typedef RectangularMatrix<3, 2, Float> Matrix3x2; +using Magnum::Matrix3x2; typedef RectangularMatrix<2, 2, Float> Matrix2x2; -typedef RectangularMatrix<2, 3, Float> Matrix2x3; -typedef RectangularMatrix<2, 4, Float> Matrix2x4; +using Magnum::Matrix2x3; +using Magnum::Matrix2x4; typedef RectangularMatrix<2, 2, Int> Matrix2x2i; typedef Vector<4, Float> Vector4; typedef Vector<3, Float> Vector3; typedef Vector<2, Float> Vector2; +using Magnum::BitVector3; typedef RectangularMatrix<4, 3, Int> Matrix4x3i; typedef RectangularMatrix<3, 4, Int> Matrix3x4i; @@ -380,7 +383,6 @@ void RectangularMatrixTest::constructCopy() { } void RectangularMatrixTest::convert() { - typedef RectangularMatrix<2, 3, Float> Matrix2x3; constexpr Mat2x3 a{{1.5f, 2.0f, -3.5f, 2.0f, -3.1f, 0.4f}}; constexpr Matrix2x3 b(Vector3(1.5f, 2.0f, -3.5f), @@ -474,7 +476,6 @@ void RectangularMatrixTest::compare() { } void RectangularMatrixTest::compareComponentWise() { - typedef BitVector<3> BitVector3; typedef RectangularMatrix<3, 1, Float> Matrix3x1; CORRADE_COMPARE(Matrix3x1(1.0f, -1.0f, 5.0f) < Matrix3x1(1.1f, -1.0f, 3.0f), BitVector3(0x1)); CORRADE_COMPARE(Matrix3x1(1.0f, -1.0f, 5.0f) <= Matrix3x1(1.1f, -1.0f, 3.0f), BitVector3(0x3)); @@ -637,8 +638,6 @@ void RectangularMatrixTest::diagonal() { } void RectangularMatrixTest::vector() { - typedef Vector<3, Int> Vector3i; - typedef RectangularMatrix<4, 3, Int> Matrix4x3i; typedef Vector<12, Int> Vector12i; Matrix4x3i a(Vector3i(0, 1, 2), diff --git a/src/Magnum/Math/Test/SwizzleTest.cpp b/src/Magnum/Math/Test/SwizzleTest.cpp index cb6236727..4093e088e 100644 --- a/src/Magnum/Math/Test/SwizzleTest.cpp +++ b/src/Magnum/Math/Test/SwizzleTest.cpp @@ -44,6 +44,7 @@ struct SwizzleTest: TestSuite::Tester { void scatterFarComponents(); }; +/* These differ from the typedefs in root Magnum namespace */ typedef Vector<2, Int> Vector2i; typedef Vector<3, Int> Vector3i; typedef Vector<4, Int> Vector4i; diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index 630abbed9..b16cce944 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/src/Magnum/Math/Test/UnitTest.cpp @@ -64,6 +64,8 @@ UnitTest::UnitTest() { &UnitTest::multiplyDivide}); } +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ template struct Sec_; typedef Unit Sec; typedef Unit Seci; diff --git a/src/Magnum/Math/Test/VectorBenchmark.cpp b/src/Magnum/Math/Test/VectorBenchmark.cpp index 2309567bc..20e1842a5 100644 --- a/src/Magnum/Math/Test/VectorBenchmark.cpp +++ b/src/Magnum/Math/Test/VectorBenchmark.cpp @@ -67,9 +67,9 @@ VectorBenchmark::VectorBenchmark() { }, 500); } -typedef Math::Constants Constants; -typedef Math::Vector2 Vector2; -typedef Math::Vector3 Vector3; +using Magnum::Constants; +using Magnum::Vector2; +using Magnum::Vector3; enum: std::size_t { Repeats = 100000 }; diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 8bac44676..0edfc5310 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -120,6 +120,8 @@ struct VectorTest: TestSuite::Tester { void debugPacked(); }; +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace */ using Magnum::Constants; using Magnum::Rad; typedef Vector<2, Float> Vector2; @@ -128,6 +130,7 @@ typedef Vector<3, Float> Vector3; typedef Vector<4, Float> Vector4; typedef Vector<4, Half> Vector4h; typedef Vector<4, Int> Vector4i; +typedef Vector<2, Int> Vector2i; using namespace Literals; @@ -459,8 +462,6 @@ void VectorTest::multiplyDivideComponentWiseIntegral() { } void VectorTest::modulo() { - typedef Math::Vector<2, Int> Vector2i; - const Vector2i a(4, 13); const Vector2i b(2, 5); CORRADE_COMPARE(a % 2, Vector2i(0, 1)); @@ -468,8 +469,6 @@ void VectorTest::modulo() { } void VectorTest::bitwise() { - typedef Math::Vector<2, Int> Vector2i; - const Vector2i a(85, 240); const Vector2i b(170, 85); CORRADE_COMPARE(~a, Vector2i(-86, -241));