Skip to content

Commit

Permalink
Expand coverage (nonstd-lite project issue 29, thanks to OpenCppCover…
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmoene committed Mar 2, 2019
1 parent 7bc7b07 commit cded590
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ any: Allows to swap with other any (member)
any: Allows to inspect if any contains a value
any: Allows to obtain type_info of any's content
swap: Allows to swap with other any (non-member)
make_any: Allows to in-place copy-construct any from arguments via make_any() (C++11)
make_any: Allows to in-place move-construct any from arguments via make_any() (C++11)
make_any: Allows to in-place copy-construct any from initializer-list via make_any() (C++11)
make_any: Allows to in-place move-construct any from initializer-list via make_any() (C++11)
make_any: Allows to in-place copy-construct any from arguments (C++11)
make_any: Allows to in-place move-construct any from arguments (C++11)
make_any: Allows to in-place copy-construct any from initializer-list and arguments (C++11)
make_any: Allows to in-place move-construct any from initializer-list and arguments (C++11)
any_cast: Allows to obtain any's content by value (any const &)
any_cast: Allows to obtain any's content by value (any &)
any_cast: Allows to obtain any's content by value (any &&)
Expand All @@ -271,4 +271,5 @@ any_cast: Allows to obtain any's content by pointer (any *)
any_cast: Throws bad_any_cast if requested type differs from content type (any const &)
any_cast: Throws bad_any_cast if requested type differs from content type (any &)
any_cast: Throws bad_any_cast if requested type differs from content type (any &&)
any_cast: Throws bad_any_cast with non-empty what()
```
17 changes: 17 additions & 0 deletions test/any.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ CASE( "any_cast: Throws bad_any_cast if requested type differs from content type
any a = 7;

EXPECT_THROWS_AS( any_cast<double>( F::ident(a) ), bad_any_cast );
// EXPECT_THROWS_WITH( any_cast<double>( F::ident(a) ), "..." )

}

CASE( "any_cast: Throws bad_any_cast if requested type differs from content type (any &)" )
Expand All @@ -637,4 +639,19 @@ CASE( "any_cast: Throws bad_any_cast if requested type differs from content type
#endif
}

CASE( "any_cast: Throws bad_any_cast with non-empty what()" )
{
struct F { static any const & ident( any const & a ) { return a; } };
any a = 7;

try
{
double d = any_cast<double>( F::ident(a) );
}
catch( bad_any_cast const & e )
{
EXPECT( ! std::string( e.what() ).empty() );
}
}

// end of file

0 comments on commit cded590

Please sign in to comment.