diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 114223a36..8d6502210 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -172,10 +172,15 @@ AngleTest::AngleTest() { } void AngleTest::construct() { - constexpr Deg b(25.0); - CORRADE_COMPARE(Float(b), 25.0f); - constexpr Radd n(3.14); - CORRADE_COMPARE(Double(n), 3.14); + Deg a{25.0f}; + Radd b{3.14}; + CORRADE_COMPARE(Float(a), 25.0f); + CORRADE_COMPARE(Double(b), 3.14); + + constexpr Deg ca{25.0f}; + constexpr Radd cb(3.14); + CORRADE_COMPARE(Float(ca), 25.0f); + CORRADE_COMPARE(Double(cb), 3.14); /* Implicit conversion is not allowed */ CORRADE_VERIFY(!std::is_convertible::value); @@ -186,14 +191,23 @@ void AngleTest::construct() { } void AngleTest::constructDefault() { - constexpr Deg m1; - constexpr Deg m2{ZeroInit}; - CORRADE_COMPARE(Float(m1), 0.0f); - CORRADE_COMPARE(Float(m2), 0.0f); - constexpr Radd a1; - constexpr Radd a2{ZeroInit}; - CORRADE_COMPARE(Double(a1), 0.0); - CORRADE_COMPARE(Double(a2), 0.0); + Deg a1; + Deg a2{ZeroInit}; + Radd b1; + Radd b2{ZeroInit}; + CORRADE_COMPARE(Float(a1), 0.0f); + CORRADE_COMPARE(Float(a2), 0.0f); + CORRADE_COMPARE(Double(b1), 0.0); + CORRADE_COMPARE(Double(b2), 0.0); + + constexpr Deg ca1; + constexpr Deg ca2{ZeroInit}; + constexpr Radd cb1; + constexpr Radd cb2{ZeroInit}; + CORRADE_COMPARE(Float(ca1), 0.0f); + CORRADE_COMPARE(Float(ca2), 0.0f); + CORRADE_COMPARE(Double(cb1), 0.0); + CORRADE_COMPARE(Double(cb2), 0.0); CORRADE_VERIFY(std::is_nothrow_default_constructible::value); CORRADE_VERIFY(std::is_nothrow_default_constructible::value); @@ -243,14 +257,20 @@ void AngleTest::constructNoInit() { } void AngleTest::constructConversion() { - constexpr Deg a(25.0); - constexpr Radd b(3.14); - - constexpr Rad c(b); + Deg a{25.0f}; + Radd b{3.14}; + Rad c{b}; + Degd d{a}; CORRADE_COMPARE(Float(c), 3.14f); - constexpr Degd d(a); CORRADE_COMPARE(Double(d), 25.0); + constexpr Deg ca{25.0f}; + constexpr Radd cb{3.14}; + constexpr Rad cc{cb}; + constexpr Degd cd{ca}; + CORRADE_COMPARE(Float(cc), 3.14f); + CORRADE_COMPARE(Double(cd), 25.0); + /* Implicit conversion is not allowed */ CORRADE_VERIFY(!std::is_convertible::value); CORRADE_VERIFY(!std::is_convertible::value); diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index b16cce944..cc37f36c3 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/src/Magnum/Math/Test/UnitTest.cpp @@ -76,9 +76,12 @@ inline Debug& operator<<(Debug& debug, Sec value) { } void UnitTest::construct() { - constexpr Sec a(25.0f); + Sec a{25.0f}; CORRADE_COMPARE(Float(a), 25.0f); + constexpr Sec ca(25.0f); + CORRADE_COMPARE(Float(ca), 25.0f); + /* Implicit conversion is not allowed */ CORRADE_VERIFY(!std::is_convertible::value); CORRADE_VERIFY(!std::is_convertible::value); @@ -89,8 +92,13 @@ void UnitTest::construct() { void UnitTest::constructDefault() { constexpr Sec a; constexpr Sec b{ZeroInit}; - CORRADE_COMPARE(a, Sec(0.0f)); - CORRADE_COMPARE(b, Sec(0.0f)); + CORRADE_COMPARE(a, Sec{0.0f}); + CORRADE_COMPARE(b, Sec{0.0f}); + + Sec ca; + Sec cb{ZeroInit}; + CORRADE_COMPARE(ca, Sec{0.0f}); + CORRADE_COMPARE(cb, Sec{0.0f}); CORRADE_VERIFY(std::is_nothrow_default_constructible::value); CORRADE_VERIFY(std::is_nothrow_constructible::value); @@ -119,9 +127,13 @@ void UnitTest::constructNoInit() { } void UnitTest::constructConversion() { - constexpr Seci a(25); - constexpr Sec b(a); - CORRADE_COMPARE(b, Sec(25.0f)); + Seci a{25}; + Sec b{a}; + CORRADE_COMPARE(b, Sec{25.0f}); + + constexpr Seci ca{25}; + constexpr Sec cb{ca}; + CORRADE_COMPARE(cb, Sec{25.0f}); /* Implicit conversion is not allowed */ CORRADE_VERIFY(!std::is_convertible::value); @@ -130,11 +142,14 @@ void UnitTest::constructConversion() { } void UnitTest::constructCopy() { - constexpr Sec a{25.0f}; - - constexpr Sec b{a}; + Sec a{25.0f}; + Sec b{a}; CORRADE_COMPARE(b, a); + constexpr Sec ca{25.0f}; + constexpr Sec cb{ca}; + CORRADE_COMPARE(cb, ca); + #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS CORRADE_VERIFY(std::is_trivially_copy_constructible::value); CORRADE_VERIFY(std::is_trivially_copy_assignable::value); @@ -147,32 +162,47 @@ void UnitTest::compare() { CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()/2.0f) == Sec(25.0f)); CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()*75.0f) != Sec(25.0f)); - constexpr bool c = Sec(3.0f) < Sec(3.0f); - constexpr bool d = Sec(3.0f) <= Sec(3.0f); - constexpr bool e = Sec(3.0f) >= Sec(3.0f); - constexpr bool f = Sec(3.0f) > Sec(3.0f); - CORRADE_VERIFY(!c); - CORRADE_VERIFY(d); - CORRADE_VERIFY(e); - CORRADE_VERIFY(!f); - - constexpr bool h = Sec(2.0f) < Sec(3.0f); - constexpr bool i = Sec(2.0f) <= Sec(3.0f); - constexpr bool j = Sec(3.0f) >= Sec(2.0f); - constexpr bool k = Sec(3.0f) > Sec(2.0f); - CORRADE_VERIFY(h); - CORRADE_VERIFY(i); - CORRADE_VERIFY(j); - CORRADE_VERIFY(k); - - constexpr bool l = Sec(3.0f) < Sec(2.0f); - constexpr bool m = Sec(3.0f) <= Sec(2.0f); - constexpr bool n = Sec(2.0f) >= Sec(3.0f); - constexpr bool o = Sec(2.0f) > Sec(3.0f); - CORRADE_VERIFY(!l); - CORRADE_VERIFY(!m); - CORRADE_VERIFY(!n); - CORRADE_VERIFY(!o); + CORRADE_VERIFY(!(Sec{3.0f} < Sec{3.0f})); + CORRADE_VERIFY(Sec{3.0f} <= Sec{3.0f}); + CORRADE_VERIFY(Sec{3.0f} >= Sec{3.0f}); + CORRADE_VERIFY(!(Sec{3.0f} > Sec{3.0f})); + + CORRADE_VERIFY(Sec{2.0f} < Sec{3.0f}); + CORRADE_VERIFY(Sec{2.0f} <= Sec{3.0f}); + CORRADE_VERIFY(Sec{3.0f} >= Sec{2.0f}); + CORRADE_VERIFY(Sec{3.0f} > Sec{2.0f}); + + CORRADE_VERIFY(!(Sec{3.0f} < Sec{2.0f})); + CORRADE_VERIFY(!(Sec{3.0f} <= Sec{2.0f})); + CORRADE_VERIFY(!(Sec{2.0f} >= Sec{3.0f})); + CORRADE_VERIFY(!(Sec{2.0f} > Sec{3.0f})); + + constexpr bool cc = Sec{3.0f} < Sec{3.0f}; + constexpr bool cd = Sec{3.0f} <= Sec{3.0f}; + constexpr bool ce = Sec{3.0f} >= Sec{3.0f}; + constexpr bool cf = Sec{3.0f} > Sec{3.0f}; + CORRADE_VERIFY(!cc); + CORRADE_VERIFY(cd); + CORRADE_VERIFY(ce); + CORRADE_VERIFY(!cf); + + constexpr bool ch = Sec{2.0f} < Sec{3.0f}; + constexpr bool ci = Sec{2.0f} <= Sec{3.0f}; + constexpr bool cj = Sec{3.0f} >= Sec{2.0f}; + constexpr bool ck = Sec{3.0f} > Sec{2.0f}; + CORRADE_VERIFY(ch); + CORRADE_VERIFY(ci); + CORRADE_VERIFY(cj); + CORRADE_VERIFY(ck); + + constexpr bool cl = Sec{3.0f} < Sec{2.0f}; + constexpr bool cm = Sec{3.0f} <= Sec{2.0f}; + constexpr bool cn = Sec{2.0f} >= Sec{3.0f}; + constexpr bool co = Sec{2.0f} > Sec{3.0f}; + CORRADE_VERIFY(!cl); + CORRADE_VERIFY(!cm); + CORRADE_VERIFY(!cn); + CORRADE_VERIFY(!co); } void UnitTest::compareNaN() { @@ -181,22 +211,23 @@ void UnitTest::compareNaN() { } void UnitTest::promotedNegated() { - constexpr Sec a(25.0f); - constexpr Sec b(+a); - constexpr Sec c(-a); - CORRADE_COMPARE(b, Sec(+25.0f)); - CORRADE_COMPARE(c, Sec(-25.0f)); + Sec a{25.0f}; + CORRADE_COMPARE(+a, Sec{+25.0f}); + CORRADE_COMPARE(-a, Sec{-25.0f}); + + constexpr Sec ca{25.0f}; + constexpr Sec cb{+ca}; + constexpr Sec cc{-ca}; + CORRADE_COMPARE(cb, Sec{+25.0f}); + CORRADE_COMPARE(cc, Sec{-25.0f}); } void UnitTest::addSubtract() { - constexpr Sec a(3.0f); - constexpr Sec b(-4.0f); - constexpr Sec c(-1.0f); - - constexpr Sec d = a + b; - constexpr Sec e = c - a; - CORRADE_COMPARE(d, c); - CORRADE_COMPARE(e, b); + Sec a{3.0f}; + Sec b{-4.0f}; + Sec c{-1.0f}; + CORRADE_COMPARE(a + b, c); + CORRADE_COMPARE(c - a, b); Sec f = a; f += b; @@ -204,21 +235,24 @@ void UnitTest::addSubtract() { g -= a; CORRADE_COMPARE(f, c); CORRADE_COMPARE(g, b); -} -void UnitTest::multiplyDivide() { - constexpr Sec a(3.0f); - constexpr Sec b(-4.5f); + constexpr Sec ca{3.0f}; + constexpr Sec cb{-4.0f}; + constexpr Sec cc{-1.0f}; - constexpr Sec c = a*-1.5f; - constexpr Sec d = -1.5f*a; - constexpr Sec e = b/-1.5f; - CORRADE_COMPARE(c, b); - CORRADE_COMPARE(d, b); - CORRADE_COMPARE(e, a); + constexpr Sec cd = ca + cb; + constexpr Sec ce = cc - ca; + CORRADE_COMPARE(cd, cc); + CORRADE_COMPARE(ce, cb); +} - constexpr Float f = b/a; - CORRADE_COMPARE(f, -1.5f); +void UnitTest::multiplyDivide() { + Sec a{3.0f}; + Sec b{-4.5f}; + CORRADE_COMPARE(a*-1.5f, b); + CORRADE_COMPARE(-1.5f*a, b); + CORRADE_COMPARE(b/-1.5f, a); + CORRADE_COMPARE(b/a, -1.5f); Sec g = a; g *= -1.5f; @@ -226,6 +260,18 @@ void UnitTest::multiplyDivide() { h /= -1.5f; CORRADE_COMPARE(g, b); CORRADE_COMPARE(h, a); + + constexpr Sec ca{3.0f}; + constexpr Sec cb{-4.5f}; + constexpr Sec cc = ca*-1.5f; + constexpr Sec cd = -1.5f*ca; + constexpr Sec ce = cb/-1.5f; + CORRADE_COMPARE(cc, cb); + CORRADE_COMPARE(cd, cb); + CORRADE_COMPARE(ce, ca); + + constexpr Float cf = cb/ca; + CORRADE_COMPARE(cf, -1.5f); } }}}}