mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Merge pull request #198 from PureAbstract/vector_to_string
Add allocator support to StringMaker<vector>
This commit is contained in:
commit
22ded1f2bb
@ -99,18 +99,15 @@ struct StringMaker<T*> {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct StringMaker<std::vector<T> > {
|
||||
static std::string convert( std::vector<T> const& v ) {
|
||||
std::ostringstream oss;
|
||||
oss << "{ ";
|
||||
for( std::size_t i = 0; i < v.size(); ++ i ) {
|
||||
oss << toString( v[i] );
|
||||
if( i < v.size() - 1 )
|
||||
oss << ", ";
|
||||
namespace Detail {
|
||||
template<typename InputIterator>
|
||||
std::string rangeToString( InputIterator first, InputIterator last );
|
||||
}
|
||||
oss << " }";
|
||||
return oss.str();
|
||||
|
||||
template<typename T, typename Allocator>
|
||||
struct StringMaker<std::vector<T, Allocator> > {
|
||||
static std::string convert( std::vector<T,Allocator> const& v ) {
|
||||
return Detail::rangeToString( v.begin(), v.end() );
|
||||
}
|
||||
};
|
||||
|
||||
@ -230,6 +227,22 @@ inline std::string toString( std::nullptr_t ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Detail {
|
||||
template<typename InputIterator>
|
||||
std::string rangeToString( InputIterator first, InputIterator last ) {
|
||||
std::ostringstream oss;
|
||||
oss << "{ ";
|
||||
if( first != last ) {
|
||||
oss << toString( *first );
|
||||
for( ++first ; first != last ; ++first ) {
|
||||
oss << ", " << toString( *first );
|
||||
}
|
||||
}
|
||||
oss << " }";
|
||||
return oss.str();
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* CATCH v1.0 build 10 (master branch)
|
||||
* Generated: 2013-09-14 19:56:34.776409
|
||||
* Generated: 2013-09-21 19:07:52.759646
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
@ -722,18 +722,15 @@ struct StringMaker<T*> {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct StringMaker<std::vector<T> > {
|
||||
static std::string convert( std::vector<T> const& v ) {
|
||||
std::ostringstream oss;
|
||||
oss << "{ ";
|
||||
for( std::size_t i = 0; i < v.size(); ++ i ) {
|
||||
oss << toString( v[i] );
|
||||
if( i < v.size() - 1 )
|
||||
oss << ", ";
|
||||
namespace Detail {
|
||||
template<typename InputIterator>
|
||||
std::string rangeToString( InputIterator first, InputIterator last );
|
||||
}
|
||||
oss << " }";
|
||||
return oss.str();
|
||||
|
||||
template<typename T, typename Allocator>
|
||||
struct StringMaker<std::vector<T, Allocator> > {
|
||||
static std::string convert( std::vector<T,Allocator> const& v ) {
|
||||
return Detail::rangeToString( v.begin(), v.end() );
|
||||
}
|
||||
};
|
||||
|
||||
@ -853,6 +850,22 @@ inline std::string toString( std::nullptr_t ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Detail {
|
||||
template<typename InputIterator>
|
||||
std::string rangeToString( InputIterator first, InputIterator last ) {
|
||||
std::ostringstream oss;
|
||||
oss << "{ ";
|
||||
if( first != last ) {
|
||||
oss << toString( *first );
|
||||
for( ++first ; first != last ; ++first ) {
|
||||
oss << ", " << toString( *first );
|
||||
}
|
||||
}
|
||||
oss << " }";
|
||||
return oss.str();
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
// #included from: catch_assertionresult.h
|
||||
|
Loading…
Reference in New Issue
Block a user