Skip to content

Commit

Permalink
add test for ref #147 + #147
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed May 1, 2017
1 parent e01b7bf commit 6247207
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions test/t/recursive_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "catch.hpp"

#include <mapbox/variant.hpp>
#include <mapbox/recursive_wrapper.hpp>

#include <type_traits>
Expand Down Expand Up @@ -153,6 +153,33 @@ TEST_CASE("recursive wrapper of pair<int, int>")
b = std::move(c);
REQUIRE(b.get().first == 5);
REQUIRE(b.get().second == 6);
// REQUIRE(c.get_pointer() == nullptr);
//REQUIRE(c.get_pointer() == nullptr);
}

SECTION("Multiple recurssive wrappers of polymorphic types")
{
// https://github.com/mapbox/variant/issues/146
// (Visual Studio 2015 update 3)
using namespace mapbox::util;
struct Base;
struct Derived;
using Variant = variant<recursive_wrapper<Base>, recursive_wrapper<Derived>>;
struct Base { };
struct Derived : public Base { };
{
Base base;
Derived derived;
Variant v;
v = base;
v = derived; // compile error prior https://github.com/mapbox/variant/pull/147
CHECK(v.is<Derived>());
}
{
Derived derived;
Variant v(derived); // compile error prior https://github.com/mapbox/variant/pull/147
CHECK(v.is<Derived>());
}


}
}

0 comments on commit 6247207

Please sign in to comment.