aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/cxx11_tensor_simple.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-29 17:56:48 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-29 17:56:48 -0700
commit31bdafac67268ace9c4eeda4a225379609ce8b99 (patch)
tree4319272836a27e6f126b84876596205e112df143 /unsupported/test/cxx11_tensor_simple.cpp
parentce19e38c1f1f31f7b7588504b3ce93c34bbd7a12 (diff)
Added a few tests to cover rank-0 tensors
Diffstat (limited to 'unsupported/test/cxx11_tensor_simple.cpp')
-rw-r--r--unsupported/test/cxx11_tensor_simple.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/unsupported/test/cxx11_tensor_simple.cpp b/unsupported/test/cxx11_tensor_simple.cpp
index 0ce92eed9..47d4d8636 100644
--- a/unsupported/test/cxx11_tensor_simple.cpp
+++ b/unsupported/test/cxx11_tensor_simple.cpp
@@ -14,6 +14,35 @@
using Eigen::Tensor;
using Eigen::RowMajor;
+static void test_0d()
+{
+ Tensor<int, 0> scalar1;
+ Tensor<int, 0, RowMajor> scalar2;
+ Tensor<int, 0> scalar3;
+ Tensor<int, 0, RowMajor> scalar4;
+
+ scalar3.resize();
+ scalar4.resize();
+
+ scalar1() = 7;
+ scalar2() = 13;
+ scalar3.setValues(17);
+ scalar4.setZero();
+
+ VERIFY_IS_EQUAL(scalar1.rank(), 0);
+ VERIFY_IS_EQUAL(scalar1.size(), 1);
+
+ VERIFY_IS_EQUAL(scalar1(), 7);
+ VERIFY_IS_EQUAL(scalar2(), 13);
+ VERIFY_IS_EQUAL(scalar3(), 17);
+ VERIFY_IS_EQUAL(scalar4(), 0);
+
+ Tensor<int, 0> scalar5(scalar1);
+
+ VERIFY_IS_EQUAL(scalar5(), 7);
+ VERIFY_IS_EQUAL(scalar5.data()[0], 7);
+}
+
static void test_1d()
{
Tensor<int, 1> vec1(6);
@@ -287,6 +316,7 @@ static void test_resize()
void test_cxx11_tensor_simple()
{
+ CALL_SUBTEST(test_0d());
CALL_SUBTEST(test_1d());
CALL_SUBTEST(test_2d());
CALL_SUBTEST(test_3d());