From cc938a29dd204408c7947ed2251254044bf65ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 21 Mar 2013 17:44:52 +0100 Subject: [PATCH] Math: test that implicit conversion of T to Vector won't compile. "Won't compile" tests are another awesome feature of C++11. --- src/Math/Test/Vector2Test.cpp | 3 +++ src/Math/Test/Vector3Test.cpp | 3 +++ src/Math/Test/Vector4Test.cpp | 3 +++ src/Math/Test/VectorTest.cpp | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index b6a8772e4..622c303d4 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -107,6 +107,9 @@ void Vector2Test::constructOneValue() { Vector2 a(3.0f); /* Not constexpr under GCC < 4.7 */ #endif CORRADE_COMPARE(a, Vector2(3.0f, 3.0f)); + + /* Implicit conversion is not allowed */ + CORRADE_VERIFY(!(std::is_convertible::value)); } void Vector2Test::constructConversion() { diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index 8e3d6b1b9..1dc913f47 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -114,6 +114,9 @@ void Vector3Test::constructOneValue() { Vector3 a(-3.0f); /* Not constexpr under GCC < 4.7 */ #endif CORRADE_COMPARE(a, Vector3(-3.0f, -3.0f, -3.0f)); + + /* Implicit conversion is not allowed */ + CORRADE_VERIFY(!(std::is_convertible::value)); } void Vector3Test::constructParts() { diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index 581b5c597..3a18d019a 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -111,6 +111,9 @@ void Vector4Test::constructOneValue() { Vector4 a(4.3f); /* Not constexpr under GCC < 4.7 */ #endif CORRADE_COMPARE(a, Vector4(4.3f, 4.3f, 4.3f, 4.3f)); + + /* Implicit conversion is not allowed */ + CORRADE_VERIFY(!(std::is_convertible::value)); } void Vector4Test::constructParts() { diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index dd5d1c553..47d194992 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -165,6 +165,9 @@ void VectorTest::constructOneValue() { #endif CORRADE_COMPARE(a, Vector4(7.25f, 7.25f, 7.25f, 7.25f)); + + /* Implicit conversion is not allowed */ + CORRADE_VERIFY(!(std::is_convertible::value)); } void VectorTest::constructOneComponent() {