aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2011-11-06 00:44:04 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2011-11-06 00:44:04 -0400
commitaa3e420df5b7bf55a3d4910fdc859e5242254b34 (patch)
tree2ec70d4d119d0761e833a1d137ed76575b4a7e24 /test
parentab3f138b2358aebcfa3d67edc8856cba2dcfc98e (diff)
Add test for Matrix(x, y) ctor static assert added in previous changeset
Diffstat (limited to 'test')
-rw-r--r--test/smallvectors.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/smallvectors.cpp b/test/smallvectors.cpp
index 144944162..4c09d4ec6 100644
--- a/test/smallvectors.cpp
+++ b/test/smallvectors.cpp
@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
+#define EIGEN_NO_STATIC_ASSERT
#include "main.h"
template<typename Scalar> void smallVectors()
@@ -29,6 +30,7 @@ template<typename Scalar> void smallVectors()
typedef Matrix<Scalar, 1, 2> V2;
typedef Matrix<Scalar, 3, 1> V3;
typedef Matrix<Scalar, 1, 4> V4;
+ typedef Matrix<Scalar, Dynamic, 1> VX;
Scalar x1 = internal::random<Scalar>(),
x2 = internal::random<Scalar>(),
x3 = internal::random<Scalar>(),
@@ -45,6 +47,29 @@ template<typename Scalar> void smallVectors()
VERIFY_IS_APPROX(x3, v3.z());
VERIFY_IS_APPROX(x3, v4.z());
VERIFY_IS_APPROX(x4, v4.w());
+
+ if (!NumTraits<Scalar>::IsInteger)
+ {
+ VERIFY_RAISES_ASSERT(V3(2, 1))
+ VERIFY_RAISES_ASSERT(V3(3, 2))
+ VERIFY_RAISES_ASSERT(V3(Scalar(3), 1))
+ VERIFY_RAISES_ASSERT(V3(3, Scalar(1)))
+ VERIFY_RAISES_ASSERT(V3(Scalar(3), Scalar(1)))
+ VERIFY_RAISES_ASSERT(V3(Scalar(123), Scalar(123)))
+
+ VERIFY_RAISES_ASSERT(V4(1, 3))
+ VERIFY_RAISES_ASSERT(V4(2, 4))
+ VERIFY_RAISES_ASSERT(V4(1, Scalar(4)))
+ VERIFY_RAISES_ASSERT(V4(Scalar(1), 4))
+ VERIFY_RAISES_ASSERT(V4(Scalar(1), Scalar(4)))
+ VERIFY_RAISES_ASSERT(V4(Scalar(123), Scalar(123)))
+
+ VERIFY_RAISES_ASSERT(VX(3, 2))
+ VERIFY_RAISES_ASSERT(VX(Scalar(3), 1))
+ VERIFY_RAISES_ASSERT(VX(3, Scalar(1)))
+ VERIFY_RAISES_ASSERT(VX(Scalar(3), Scalar(1)))
+ VERIFY_RAISES_ASSERT(VX(Scalar(123), Scalar(123)))
+ }
}
void test_smallvectors()