diff --git a/src/op_unit_test.cc b/src/op_unit_test.cc index 4b83deb..18cb511 100644 --- a/src/op_unit_test.cc +++ b/src/op_unit_test.cc @@ -92,6 +92,7 @@ namespace { std::shared_ptr mr2ptr; std::vector v1 = { 2.917, 9.436, 0.373 }; std::vector v2 = { 8.870, 4.790 }; + std::vector v3 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 }; }; TEST_F(OpTest_1Dim, ExecOp) @@ -130,6 +131,35 @@ namespace { EXPECT_EQ( fabs( res.at(mkt('3','B')) - (0.373 + 4.790) ) < 0.0001, true ); } + + TEST_F(OpTest_MDim, ExecOp2) + { + MultiArray res(mr1ptr,sr4ptr); + MultiArray ma1(mr1ptr, v3); + MultiArray ma2(sr4ptr, v2); + + auto i1 = std::dynamic_pointer_cast( mr1ptr->index() ); + auto i2 = std::dynamic_pointer_cast( sr4ptr->index() ); + + res(i1,i2) = ma1(i1) + ma2(i2); + + EXPECT_EQ( fabs( res.at(mkt(mkt('1','a'),'A')) - (0.353 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('1','a'),'B')) - (0.353 + 4.790) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('1','b'),'A')) - (4.005 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('1','b'),'B')) - (4.005 + 4.790) ) < 0.0001, true ); + + EXPECT_EQ( fabs( res.at(mkt(mkt('2','a'),'A')) - (1.070 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('2','a'),'B')) - (1.070 + 4.790) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('2','b'),'A')) - (2.310 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('2','b'),'B')) - (2.310 + 4.790) ) < 0.0001, true ); + + EXPECT_EQ( fabs( res.at(mkt(mkt('3','a'),'A')) - (9.243 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('3','a'),'B')) - (9.243 + 4.790) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('3','b'),'A')) - (2.911 + 8.870) ) < 0.0001, true ); + EXPECT_EQ( fabs( res.at(mkt(mkt('3','b'),'B')) - (2.911 + 4.790) ) < 0.0001, true ); + + } + } // anonymous namspace