Skip to content

Commit e37b90e

Browse files
Extra testing for xoptional casting
1 parent 6bd8351 commit e37b90e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/test_xoptional.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,17 @@ namespace xt
474474
flag_functor_type m_flag_functor;
475475
};
476476

477+
TEST(xoptional, cast)
478+
{
479+
xarray_optional<double> a = {{1.2, 2.3, 3.4},
480+
{4.5, 5.6, 6.7}};
481+
a(1, 2).has_value() = false;
482+
auto b = cast<xtl::xoptional<int>>(a);
483+
EXPECT_TRUE(b(0,2).has_value());
484+
EXPECT_EQ(b(0,2), 3);
485+
EXPECT_FALSE(b(1,2).has_value());
486+
}
487+
477488
TEST(xoptional, generator)
478489
{
479490
using gen_type = xgenerator<opt_func_tester, xtl::xoptional<int, bool>, dynamic_shape<std::size_t>>;

0 commit comments

Comments
 (0)