2017-02-17 18:10:03 +01:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "multi_array_header.h"
|
|
|
|
|
|
|
|
namespace MAT = MultiArrayTools;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class OneDimTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
|
|
|
typedef MAT::MultiArray<int,Range1dAny> MultiArray1dAny;
|
|
|
|
|
|
|
|
OneDimTest() : r({'a','b','c','d','e'}), ma(r, {-5,6,2,1,9}) {}
|
|
|
|
|
|
|
|
//virtual void SetUp();
|
|
|
|
|
|
|
|
Range1dAny r;
|
|
|
|
MultiArray1dAny ma;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-02-20 17:18:53 +01:00
|
|
|
class TwoDimTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny> Range2dAny;
|
|
|
|
typedef MAT::MultiArray<int,Range2dAny> MultiArray2dAny;
|
|
|
|
|
|
|
|
TwoDimTest() : r1({'a','b','c'}),
|
|
|
|
r2({'a','b','c','d'}),
|
|
|
|
r(r1,r2),
|
|
|
|
ma(r, {-5,6,2,1,9,54,27,-7,-13,32,90,-67}) {}
|
|
|
|
|
|
|
|
//virtual void SetUp();
|
|
|
|
|
|
|
|
Range1dAny r1;
|
|
|
|
Range1dAny r2;
|
|
|
|
Range2dAny r;
|
|
|
|
MultiArray2dAny ma;
|
|
|
|
|
|
|
|
};
|
2017-02-21 21:47:40 +01:00
|
|
|
|
|
|
|
class ReorderTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny> Range2dAny;
|
2017-02-22 14:10:16 +01:00
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny,Range1dAny> Range3dAny;
|
2017-02-21 21:47:40 +01:00
|
|
|
typedef MAT::MultiArray<int,Range2dAny> MultiArray2dAny;
|
2017-02-22 14:10:16 +01:00
|
|
|
typedef MAT::MultiArray<int,Range3dAny> MultiArray3dAny;
|
2017-02-21 21:47:40 +01:00
|
|
|
|
2017-02-22 14:10:16 +01:00
|
|
|
ReorderTest() : r1({'a','b','c'}), r2({'a','b','c','d'}), r3({'a','b'}),
|
2017-02-21 21:47:40 +01:00
|
|
|
ra(r1,r2), rb(r2,r1),
|
2017-02-22 14:10:16 +01:00
|
|
|
r3da(r1,r2,r3), r3db(r1,r3,r2), r3dc(r3,r1,r2),
|
|
|
|
ma(ra, {-5,6,2,1,9,54,27,-7,-13,32,90,-67}),
|
|
|
|
ma3d(r3da, {-5,6,2,1,9,54,27,-7,-13,32,90,-67,
|
|
|
|
-10,16,-2,101,39,-64,81,-22,14,34,95,-62}) {}
|
2017-02-21 21:47:40 +01:00
|
|
|
|
|
|
|
Range1dAny r1;
|
|
|
|
Range1dAny r2;
|
2017-02-22 14:10:16 +01:00
|
|
|
Range1dAny r3;
|
2017-02-21 21:47:40 +01:00
|
|
|
Range2dAny ra;
|
|
|
|
Range2dAny rb;
|
2017-02-22 14:10:16 +01:00
|
|
|
Range3dAny r3da;
|
|
|
|
Range3dAny r3db;
|
|
|
|
Range3dAny r3dc;
|
2017-02-21 21:47:40 +01:00
|
|
|
MultiArray2dAny ma;
|
2017-02-22 14:10:16 +01:00
|
|
|
MultiArray3dAny ma3d;
|
2017-02-21 21:47:40 +01:00
|
|
|
};
|
|
|
|
|
2017-02-22 19:06:23 +01:00
|
|
|
class OperationTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
2017-02-24 15:08:42 +01:00
|
|
|
typedef MAT::MultiRange<Range1dAny> RangeAny;
|
2017-02-22 19:06:23 +01:00
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny> Range2dAny;
|
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny,Range1dAny> Range3dAny;
|
2017-02-24 15:08:42 +01:00
|
|
|
typedef MAT::MultiArray<int,RangeAny> MultiArray1dAny;
|
2017-02-22 19:06:23 +01:00
|
|
|
typedef MAT::MultiArray<int,Range2dAny> MultiArray2dAny;
|
|
|
|
typedef MAT::MultiArray<int,Range3dAny> MultiArray3dAny;
|
|
|
|
|
|
|
|
OperationTest() : r1({'a','b','c'}), r2({'a','b','c','d'}), r3({'a','b'}),
|
2017-02-24 15:08:42 +01:00
|
|
|
r11(r1),
|
2017-02-22 19:06:23 +01:00
|
|
|
ra(r1,r2),
|
|
|
|
r3d(r1,r2,r3),
|
2017-02-24 15:08:42 +01:00
|
|
|
ma1d(r11, {-5,6,2}),
|
2017-02-22 19:06:23 +01:00
|
|
|
ma(ra, {-5,6,2,1,9,54,27,-7,-13,32,90,-67}),
|
|
|
|
ma3d(r3d, {-5,6,2,1,9,54,27,-7,-13,32,90,-67,
|
|
|
|
-10,16,-2,101,39,-64,81,-22,14,34,95,-62}) {}
|
|
|
|
|
|
|
|
Range1dAny r1;
|
|
|
|
Range1dAny r2;
|
|
|
|
Range1dAny r3;
|
2017-02-24 15:08:42 +01:00
|
|
|
RangeAny r11;
|
2017-02-22 19:06:23 +01:00
|
|
|
Range2dAny ra;
|
|
|
|
Range3dAny r3d;
|
2017-02-24 15:08:42 +01:00
|
|
|
MultiArray1dAny ma1d;
|
2017-02-22 19:06:23 +01:00
|
|
|
MultiArray2dAny ma;
|
|
|
|
MultiArray3dAny ma3d;
|
|
|
|
};
|
2017-02-28 11:27:23 +01:00
|
|
|
|
|
|
|
class SliceTest : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny> Range2dAny;
|
|
|
|
typedef MAT::MultiRange<Range1dAny,Range1dAny,Range1dAny> Range3dAny;
|
|
|
|
typedef MAT::MultiArray<int,Range3dAny> MultiArray3dAny;
|
|
|
|
typedef MAT::Slice<int,Range2dAny,Range3dAny> Slice2d3dAny;
|
|
|
|
|
|
|
|
SliceTest() : r1({'a','b','c'}), r2({'a','b','c','d'}), r3({'a','b'}),
|
|
|
|
ra(r1,r3),
|
|
|
|
rb(r1,r2),
|
|
|
|
r3d(r1,r2,r3),
|
|
|
|
ma(r3d, {-5,6,2,1,9,54,27,-7,-13,32,90,-67,
|
|
|
|
-10,16,-2,101,39,-64,81,-22,14,34,95,-62}) {}
|
|
|
|
|
|
|
|
Range1dAny r1;
|
|
|
|
Range1dAny r2;
|
|
|
|
Range1dAny r3;
|
|
|
|
Range2dAny ra;
|
|
|
|
Range2dAny rb;
|
|
|
|
Range3dAny r3d;
|
|
|
|
MultiArray3dAny ma;
|
|
|
|
//Slice2d3dAny sl;
|
|
|
|
};
|
|
|
|
|
2017-02-17 18:10:03 +01:00
|
|
|
TEST_F(OneDimTest, CorrectExtensions)
|
|
|
|
{
|
|
|
|
EXPECT_EQ(ma.size(), 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(OneDimTest, CorrectAssigned)
|
|
|
|
{
|
2017-02-21 17:41:48 +01:00
|
|
|
auto i = ma.begin();
|
|
|
|
EXPECT_EQ(ma[i = 0], -5);
|
|
|
|
EXPECT_EQ(ma[i = 1], 6);
|
|
|
|
EXPECT_EQ(ma[i = 2], 2);
|
|
|
|
EXPECT_EQ(ma[i = 3], 1);
|
|
|
|
EXPECT_EQ(ma[i = 4], 9);
|
2017-02-17 18:10:03 +01:00
|
|
|
}
|
2017-02-20 17:18:53 +01:00
|
|
|
|
|
|
|
TEST_F(TwoDimTest, CorrectExtensions)
|
|
|
|
{
|
|
|
|
EXPECT_EQ(ma.size(), 12);
|
|
|
|
}
|
2017-02-21 17:41:48 +01:00
|
|
|
|
2017-02-20 17:18:53 +01:00
|
|
|
TEST_F(TwoDimTest, CorrectAssigned)
|
2017-02-21 17:41:48 +01:00
|
|
|
{
|
2017-02-20 17:18:53 +01:00
|
|
|
auto i = ma.begin();
|
2017-02-21 17:41:48 +01:00
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
|
|
|
|
EXPECT_EQ(ma[i(i1 = 0, i2 = 0)], -5);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 0, i2 = 1)], 6);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 0, i2 = 2)], 2);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 0, i2 = 3)], 1);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 1, i2 = 0)], 9);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 1, i2 = 1)], 54);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 1, i2 = 2)], 27);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 1, i2 = 3)], -7);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 2, i2 = 0)], -13);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 2, i2 = 1)], 32);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 2, i2 = 2)], 90);
|
|
|
|
EXPECT_EQ(ma[i(i1 = 2, i2 = 3)], -67);
|
2017-02-20 17:18:53 +01:00
|
|
|
}
|
2017-02-21 21:47:40 +01:00
|
|
|
|
2017-02-22 14:10:16 +01:00
|
|
|
TEST_F(ReorderTest, ReorderingWorks2d)
|
2017-02-21 21:47:40 +01:00
|
|
|
{
|
|
|
|
MultiArray2dAny ma2(rb);
|
|
|
|
auto i = ma2.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
ma2("alpha","beta") = ma("beta","alpha");
|
2017-02-22 13:34:32 +01:00
|
|
|
|
2017-02-21 21:47:40 +01:00
|
|
|
EXPECT_EQ(ma2[i(i1 = 0,i2 = 0)],-5);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 1,i2 = 0)],6);
|
2017-02-22 13:34:32 +01:00
|
|
|
EXPECT_EQ(ma2[i(i1 = 2,i2 = 0)],2);
|
2017-02-22 14:10:16 +01:00
|
|
|
EXPECT_EQ(ma2[i(i1 = 3,i2 = 0)],1);
|
2017-02-22 00:43:38 +01:00
|
|
|
|
2017-02-22 13:34:32 +01:00
|
|
|
EXPECT_EQ(ma2[i(i1 = 0,i2 = 1)],9);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 1,i2 = 1)],54);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 2,i2 = 1)],27);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 3,i2 = 1)],-7);
|
2017-02-22 00:43:38 +01:00
|
|
|
|
2017-02-22 13:34:32 +01:00
|
|
|
EXPECT_EQ(ma2[i(i1 = 0,i2 = 2)],-13);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 1,i2 = 2)],32);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 2,i2 = 2)],90);
|
|
|
|
EXPECT_EQ(ma2[i(i1 = 3,i2 = 2)],-67);
|
2017-02-21 21:47:40 +01:00
|
|
|
}
|
2017-02-22 14:10:16 +01:00
|
|
|
|
|
|
|
TEST_F(ReorderTest, ReorderingWorks3d_Test1)
|
|
|
|
{
|
|
|
|
MultiArray3dAny ma3d2(r3db);
|
|
|
|
auto i = ma3d2.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
|
|
|
ma3d2("alpha","beta","gamma") = ma3d("alpha","gamma","beta");
|
|
|
|
|
|
|
|
EXPECT_EQ(ma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|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 2)],14);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 2)],34);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 3)],95);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 3)],-62);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ReorderTest, ReorderingWorks3d_Test2)
|
|
|
|
{
|
|
|
|
MultiArray3dAny ma3d2(r3dc);
|
|
|
|
auto i = ma3d2.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
2017-02-22 19:06:23 +01:00
|
|
|
|
2017-02-22 14:10:16 +01:00
|
|
|
ma3d2("gamma","alpha","beta") = ma3d("alpha","beta","gamma");
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 0)],-5);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 0)],6);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 1)],2);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 1)],1);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 2)],9);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 2)],54);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 3)],27);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 3)],-7);
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 0)],-13);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 0)],32);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 1)],90);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 1)],-67);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 2)],-10);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 2)],16);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 3)],-2);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 3)],101);
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 0)],39);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 0)],-64);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 1)],81);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 1)],-22);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 2)],14);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 2)],34);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 3)],95);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 3)],-62);
|
|
|
|
}
|
2017-02-22 19:06:23 +01:00
|
|
|
|
|
|
|
TEST_F(OperationTest, CorrectlyAdded)
|
|
|
|
{
|
|
|
|
MultiArray3dAny ma3d2(r3d);
|
|
|
|
auto i = ma3d2.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
|
|
|
|
|
|
|
ma3d2("alpha","beta","gamma") = ma3d("alpha","beta","gamma") + ma("alpha","beta");
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 =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);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 2, i3 = 0)], 104);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 2, i3 = 1)], 124);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 3, i3 = 0)], 28);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 3, i3 = 1)], -129);
|
|
|
|
}
|
2017-02-24 15:08:42 +01:00
|
|
|
|
|
|
|
TEST_F(OperationTest, CorrectlyAdded_3args)
|
|
|
|
{
|
|
|
|
MultiArray3dAny ma3d2(r3d);
|
|
|
|
//MultiArray2dAny ma2(ra);
|
|
|
|
auto i = ma3d2.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
|
|
|
|
|
|
|
//ma2("alpha","beta") = ma("alpha","beta") + ma1d("alpha");
|
2017-02-26 14:00:47 +01:00
|
|
|
ma3d2("alpha","beta","gamma") = ma3d("alpha","beta","gamma") + ma("alpha","beta") + ma1d("alpha");
|
2017-02-24 15:08:42 +01:00
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 0, i3 = 0)], -15);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 0, i3 = 1)], -4);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 1, i3 = 0)], 3);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 1, i3 = 1)], 2);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 2, i3 = 0)], 6);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 2, i3 = 1)], 51);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 3, i3 = 0)], 23);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 0, i2 = 3, i3 = 1)], -11);
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 0, i3 = 0)], 2);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 0, i3 = 1)], 47);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 1, i3 = 0)], 150);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 1, i3 = 1)], -7);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 2, i3 = 0)], 23);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 2, i3 = 1)], 49);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 3, i3 = 0)], -3);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 1, i2 = 3, i3 = 1)], 100);
|
|
|
|
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 0, i3 = 0)], 28);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 0, i3 = 1)], -75);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 1, i3 = 0)], 115);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 1, i3 = 1)], 12);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 2, i3 = 0)], 106);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 2, i3 = 1)], 126);
|
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 3, i3 = 0)], 30);
|
2017-02-28 11:27:23 +01:00
|
|
|
EXPECT_EQ(ma3d2[i(i1 = 2, i2 = 3, i3 = 1)], -127);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SliceTest, CorrectSize)
|
|
|
|
{
|
|
|
|
auto i = ma.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
2017-02-28 19:29:52 +01:00
|
|
|
CHECK;
|
2017-02-28 11:27:23 +01:00
|
|
|
Slice2d3dAny sl(ra);
|
2017-02-28 19:29:52 +01:00
|
|
|
CHECK;
|
2017-02-28 11:27:23 +01:00
|
|
|
sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
|
|
|
EXPECT_EQ(sl.size(), 6);
|
|
|
|
Slice2d3dAny sl2(rb);
|
2017-02-28 19:29:52 +01:00
|
|
|
sl2("alpha","beta") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 0, i3 = 1)];
|
|
|
|
EXPECT_EQ(sl2.size(), 12);
|
2017-02-28 11:27:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SliceTest, CorrectContent)
|
|
|
|
{
|
|
|
|
auto i = ma.begin();
|
|
|
|
auto i1 = i.template getIndex<0>();
|
|
|
|
auto i2 = i.template getIndex<1>();
|
|
|
|
auto i3 = i.template getIndex<2>();
|
|
|
|
Slice2d3dAny sl(ra);
|
|
|
|
sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
2017-02-28 19:29:52 +01:00
|
|
|
CHECK;
|
2017-02-28 11:27:23 +01:00
|
|
|
auto j = sl.begin();
|
|
|
|
auto j1 = j.template getIndex<0>();
|
|
|
|
auto j2 = j.template getIndex<1>();
|
2017-02-28 19:29:52 +01:00
|
|
|
CHECK;
|
2017-02-28 11:27:23 +01:00
|
|
|
EXPECT_EQ(sl[j(j1 = 0, j2 = 0)], 9);
|
2017-02-28 19:29:52 +01:00
|
|
|
CHECK;
|
2017-02-28 11:27:23 +01:00
|
|
|
EXPECT_EQ(sl[j(j1 = 0, j2 = 1)], 54);
|
|
|
|
|
|
|
|
EXPECT_EQ(sl[j(j1 = 1, j2 = 0)], -10);
|
|
|
|
EXPECT_EQ(sl[j(j1 = 1, j2 = 1)], 16);
|
|
|
|
|
|
|
|
EXPECT_EQ(sl[j(j1 = 2, j2 = 0)], 14);
|
|
|
|
EXPECT_EQ(sl[j(j1 = 2, j2 = 1)], 34);
|
|
|
|
}
|
2017-02-22 19:06:23 +01:00
|
|
|
|
2017-02-17 18:10:03 +01:00
|
|
|
} // end namespace
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|