From 74f1c5d9b02788fb9524ae674d43fdf07671d9cc Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 26 Jun 2014 16:29:36 +0200 Subject: [PATCH] Add test case for issue #25. --- test/unit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit.cpp b/test/unit.cpp index 9dc13ea..78b9bbb 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -250,6 +250,14 @@ TEST_CASE( "implicit conversion to first type in variant type list", "[variant][ REQUIRE_THROWS(var.get()); } +// 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 variant_type; + variant_type var = 500.0; // converted to unsigned char, even if it doesn't fit + CHECK(var.get() == static_cast(500.0)); + CHECK(var.get() == static_cast(static_cast(500.0))); +} + struct dummy {}; TEST_CASE( "implicit conversion to first type it can convert to even if it doesn't fit", "[variant][implicit conversion]" ) {