upgrade variant dependency

This commit is contained in:
Dennis Luxen
2015-03-04 12:48:19 +01:00
4 changed files with 59 additions and 10 deletions
+12 -4
View File
@@ -212,11 +212,22 @@ TEST_CASE( "variant should correctly index types", "[variant]" ) {
REQUIRE(variant_type(float(0.0)).get_type_index() == 0);
}
// Test internal api
TEST_CASE( "variant::which() returns zero based index of stored type", "[variant]" ) {
typedef util::variant<bool,std::string,std::uint64_t,std::int64_t,double,float> variant_type;
// Index is in reverse order
REQUIRE(variant_type(true).which() == 0);
REQUIRE(variant_type(std::string("test")).which() == 1);
REQUIRE(variant_type(std::uint64_t(0)).which() == 2);
REQUIRE(variant_type(std::int64_t(0)).which() == 3);
REQUIRE(variant_type(double(0.0)).which() == 4);
REQUIRE(variant_type(float(0.0)).which() == 5);
}
TEST_CASE( "get with type not in variant type list should throw", "[variant]" ) {
typedef util::variant<int> variant_type;
variant_type var = 5;
REQUIRE(var.get<int>() == 5);
REQUIRE_THROWS(var.get<double>()); // XXX shouldn't this be a compile time error? See https://github.com/mapbox/variant/issues/24
}
TEST_CASE( "get with wrong type (here: double) should throw", "[variant]" ) {
@@ -237,7 +248,6 @@ TEST_CASE( "implicit conversion", "[variant][implicit conversion]" ) {
typedef util::variant<int> variant_type;
variant_type var(5.0); // converted to int
REQUIRE(var.get<int>() == 5);
REQUIRE_THROWS(var.get<double>());
var = 6.0; // works for operator=, too
REQUIRE(var.get<int>() == 6);
}
@@ -247,7 +257,6 @@ TEST_CASE( "implicit conversion to first type in variant type list", "[variant][
variant_type var = 5.0; // converted to long
REQUIRE(var.get<long>() == 5);
REQUIRE_THROWS(var.get<char>());
REQUIRE_THROWS(var.get<double>());
}
TEST_CASE( "implicit conversion to unsigned char", "[variant][implicit conversion]" ) {
@@ -297,7 +306,6 @@ TEST_CASE( "variant printer", "[visitor][unary visitor][printer]" ) {
REQUIRE(out.str() == "2.1,123,foo,456,foo");
}
int main (int argc, char* const argv[])
{
int result = Catch::Session().run(argc, argv);