From 31bdafac67268ace9c4eeda4a225379609ce8b99 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 29 Oct 2015 17:56:48 -0700 Subject: Added a few tests to cover rank-0 tensors --- unsupported/test/cxx11_tensor_map.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'unsupported/test/cxx11_tensor_map.cpp') diff --git a/unsupported/test/cxx11_tensor_map.cpp b/unsupported/test/cxx11_tensor_map.cpp index 4c4e10df2..9e79209bb 100644 --- a/unsupported/test/cxx11_tensor_map.cpp +++ b/unsupported/test/cxx11_tensor_map.cpp @@ -14,6 +14,24 @@ using Eigen::Tensor; using Eigen::RowMajor; +static void test_0d() +{ + Tensor scalar1; + Tensor scalar2; + + TensorMap> scalar3(scalar1.data()); + TensorMap> scalar4(scalar2.data()); + + scalar1() = 7; + scalar2() = 13; + + VERIFY_IS_EQUAL(scalar1.rank(), 0); + VERIFY_IS_EQUAL(scalar1.size(), 1); + + VERIFY_IS_EQUAL(scalar3(), 7); + VERIFY_IS_EQUAL(scalar4(), 13); +} + static void test_1d() { Tensor vec1(6); @@ -242,6 +260,7 @@ static void test_casting() void test_cxx11_tensor_map() { + CALL_SUBTEST(test_0d()); CALL_SUBTEST(test_1d()); CALL_SUBTEST(test_2d()); CALL_SUBTEST(test_3d()); -- cgit v1.2.3