Skip to content

Commit

Permalink
Adding test-case fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Mar 15, 2022
1 parent 0f6f58a commit 3f6fde0
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/test_xfixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,41 @@ namespace xt
{
using fixed_tensor = xtensor_fixed<double, xshape<2>, layout_type::row_major, true>;
using tiny_tensor = xtensor_fixed<double, xshape<2>, layout_type::row_major, false>;
EXPECT_GT(sizeof(fixed_tensor), sizeof(tiny_tensor));
EXPECT_GT(sizeof(fixed_tensor), sizeof(tiny_tensor));
}

class FixedMember
{
public:
FixedMember(size_t bar, double foo)
{
m_bar = bar;
m_foo = foo;
m_I = xt::xtensor_fixed<double, xt::xshape<2, 2>>({{1.0, 0.0},
{0.0, 1.0}});
}

xt::xtensor_fixed<double, xt::xshape<2, 2>> get() const
{
xt::xtensor_fixed<double, xt::xshape<2, 2>> ret = 2.0 * m_I;
return ret;
}

private:
size_t m_bar;
double m_foo;
xt::xtensor_fixed<double, xt::xshape<2, 2>> m_I;
};

TEST(xtensor_fixed, member)
{
FixedMember c(20, 1.2);
auto m = c.get();
auto r = xt::xtensor_fixed<double, xt::xshape<2, 2>>({{2.0, 0.0},
{0.0, 2.0}});
EXPECT_TRUE(xt::all(xt::equal(m, r)));
}

}

#endif
Expand Down

0 comments on commit 3f6fde0

Please sign in to comment.