Skip to content

Commit

Permalink
Merge pull request #1368 from martinRenou/add_test_optional_ternary
Browse files Browse the repository at this point in the history
Add test for ternary operator on xoptionals
  • Loading branch information
JohanMabille committed Jan 24, 2019
2 parents 7917869 + 34eabba commit ed23449
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_xoperation.cpp
Expand Up @@ -9,8 +9,10 @@
#include "gtest/gtest.h"

#include <cstddef>

#include "xtensor/xarray.hpp"
#include "xtensor/xtensor.hpp"
#include "xtensor/xoptional_assembly.hpp"

namespace xt
{
Expand Down Expand Up @@ -490,6 +492,17 @@ namespace xt
#endif
}

TYPED_TEST(operation, where_optional)
{
using opt_type = xoptional_assembly<TypeParam, xtensor<bool, 2>>;
auto missing = xtl::missing<double>();
opt_type a = { { 1, missing, 3 },{ 0, 1, 0 },{ missing, 4, 1 } };
xtl::xoptional<double, bool> b = 1.0;
opt_type res = where(a > b, b, a);
opt_type expected = { { 1, missing, 1 },{ 0, 1, 0 },{ missing, 1, 1 } };
EXPECT_EQ(expected, res);
}

TYPED_TEST(operation, where_cast)
{
using int_container_2d = xop_test::rebind_container_t<TypeParam, int>;
Expand Down

0 comments on commit ed23449

Please sign in to comment.