Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/ToStringVector.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-11-03 12:05:38 +0000
committerPhil Nash2017-11-03 12:05:38 +0000
commit46c7c9d3a0cb975dabf5970cc65fd8fc72d4c5b5 (patch)
treef07e8d45a6f21ac8249e43f17f6fc58749d6cc51 /projects/SelfTest/ToStringVector.cpp
parent2d91035404884089d1faf038300e437963e0c2a4 (diff)
parentb119ebdde15ae4b092f22766fcd652307b42cdf2 (diff)
downloadcatch3-46c7c9d3a0cb975dabf5970cc65fd8fc72d4c5b5.tar.gz
Merge branch 'catch2'
Diffstat (limited to 'projects/SelfTest/ToStringVector.cpp')
-rw-r--r--projects/SelfTest/ToStringVector.cpp55
1 files changed, 23 insertions, 32 deletions
diff --git a/projects/SelfTest/ToStringVector.cpp b/projects/SelfTest/ToStringVector.cpp
index cd071a9d..df9c55ab 100644
--- a/projects/SelfTest/ToStringVector.cpp
+++ b/projects/SelfTest/ToStringVector.cpp
@@ -6,39 +6,35 @@
TEST_CASE( "vector<int> -> toString", "[toString][vector]" )
{
std::vector<int> vv;
- REQUIRE( Catch::toString(vv) == "{ }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( 42 );
- REQUIRE( Catch::toString(vv) == "{ 42 }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" );
vv.push_back( 250 );
- REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" );
}
TEST_CASE( "vector<string> -> toString", "[toString][vector]" )
{
std::vector<std::string> vv;
- REQUIRE( Catch::toString(vv) == "{ }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( "hello" );
- REQUIRE( Catch::toString(vv) == "{ \"hello\" }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\" }" );
vv.push_back( "world" );
- REQUIRE( Catch::toString(vv) == "{ \"hello\", \"world\" }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" );
}
-#if defined(CATCH_CPP11_OR_GREATER)
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++98-compat"
-#endif
-
-/*
- Note: These tests *can* be made to work with C++ < 11, but the
- allocator is a lot more work...
-*/
namespace {
/* Minimal Allocator */
template<typename T>
struct minimal_allocator {
- typedef T value_type;
- typedef std::size_t size_type;
+ using value_type = T;
+ using size_type = std::size_t;
+
+ minimal_allocator() = default;
+ template <typename U>
+ minimal_allocator(const minimal_allocator<U>&) {}
+
+
T *allocate( size_type n ) {
return static_cast<T *>( ::operator new( n * sizeof(T) ) );
}
@@ -52,26 +48,21 @@ namespace {
};
}
-TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator][c++11][.]" ) {
+TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator]" ) {
std::vector<int,minimal_allocator<int> > vv;
- REQUIRE( Catch::toString(vv) == "{ }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( 42 );
- REQUIRE( Catch::toString(vv) == "{ 42 }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" );
vv.push_back( 250 );
- REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
+ REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" );
}
-TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator][c++11][.]" ) {
- typedef std::vector<std::string,minimal_allocator<std::string> > inner;
- typedef std::vector<inner> vector;
+TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" ) {
+ using inner = std::vector<std::string, minimal_allocator<std::string>>;
+ using vector = std::vector<inner>;
vector v;
- REQUIRE( Catch::toString(v) == "{ }" );
+ REQUIRE( ::Catch::Detail::stringify(v) == "{ }" );
v.push_back( inner { "hello" } );
v.push_back( inner { "world" } );
- REQUIRE( Catch::toString(v) == "{ { \"hello\" }, { \"world\" } }" );
+ REQUIRE( ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" );
}
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-#endif // CATCH_CPP11_OR_GREATER