Skip to content

Commit

Permalink
Add test case for issue #25.
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Jun 26, 2014
1 parent fd470a6 commit 74f1c5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ TEST_CASE( "implicit conversion to first type in variant type list", "[variant][
REQUIRE_THROWS(var.get<double>());
}

// test case to help debugging https://github.com/mapbox/variant/issues/25
TEST_CASE( "implicit conversion to unsigned char", "[variant][implicit conversion]" ) {
typedef util::variant<unsigned char> variant_type;
variant_type var = 500.0; // converted to unsigned char, even if it doesn't fit
CHECK(var.get<unsigned char>() == static_cast<unsigned char>(500.0));
CHECK(var.get<unsigned char>() == static_cast<unsigned char>(static_cast<unsigned int>(500.0)));
}

struct dummy {};

TEST_CASE( "implicit conversion to first type it can convert to even if it doesn't fit", "[variant][implicit conversion]" ) {
Expand Down

0 comments on commit 74f1c5d

Please sign in to comment.