mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Removed String and StringBuilder
This commit is contained in:
parent
ece64c3b3a
commit
3772f69f0f
@ -76,8 +76,6 @@ set(TEST_SOURCES
|
|||||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||||
${SELF_TEST_DIR}/MatchersTests.cpp
|
${SELF_TEST_DIR}/MatchersTests.cpp
|
||||||
${SELF_TEST_DIR}/String.tests.cpp
|
|
||||||
${SELF_TEST_DIR}/StringBuilder.tests.cpp
|
|
||||||
${SELF_TEST_DIR}/StringRef.tests.cpp
|
${SELF_TEST_DIR}/StringRef.tests.cpp
|
||||||
)
|
)
|
||||||
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
||||||
@ -172,8 +170,6 @@ set(INTERNAL_HEADERS
|
|||||||
${HEADER_DIR}/internal/catch_startup_exception_registry.h
|
${HEADER_DIR}/internal/catch_startup_exception_registry.h
|
||||||
${HEADER_DIR}/internal/catch_stream.h
|
${HEADER_DIR}/internal/catch_stream.h
|
||||||
${HEADER_DIR}/internal/catch_streambuf.h
|
${HEADER_DIR}/internal/catch_streambuf.h
|
||||||
${HEADER_DIR}/internal/catch_string.h
|
|
||||||
${HEADER_DIR}/internal/catch_stringbuilder.h
|
|
||||||
${HEADER_DIR}/internal/catch_stringdata.h
|
${HEADER_DIR}/internal/catch_stringdata.h
|
||||||
${HEADER_DIR}/internal/catch_stringref.h
|
${HEADER_DIR}/internal/catch_stringref.h
|
||||||
${HEADER_DIR}/internal/catch_string_manip.h
|
${HEADER_DIR}/internal/catch_string_manip.h
|
||||||
@ -226,8 +222,6 @@ set(IMPL_SOURCES
|
|||||||
${HEADER_DIR}/internal/catch_section_info.cpp
|
${HEADER_DIR}/internal/catch_section_info.cpp
|
||||||
${HEADER_DIR}/internal/catch_startup_exception_registry.cpp
|
${HEADER_DIR}/internal/catch_startup_exception_registry.cpp
|
||||||
${HEADER_DIR}/internal/catch_stream.cpp
|
${HEADER_DIR}/internal/catch_stream.cpp
|
||||||
${HEADER_DIR}/internal/catch_string.cpp
|
|
||||||
${HEADER_DIR}/internal/catch_stringbuilder.cpp
|
|
||||||
${HEADER_DIR}/internal/catch_stringdata.cpp
|
${HEADER_DIR}/internal/catch_stringdata.cpp
|
||||||
${HEADER_DIR}/internal/catch_stringref.cpp
|
${HEADER_DIR}/internal/catch_stringref.cpp
|
||||||
${HEADER_DIR}/internal/catch_string_manip.cpp
|
${HEADER_DIR}/internal/catch_string_manip.cpp
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "catch_string.h"
|
|
||||||
#include "catch_stringref.h"
|
|
||||||
#include "catch_stringbuilder.h"
|
|
||||||
|
|
||||||
#include "catch_stringdata.h"
|
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
String::String()
|
|
||||||
: m_data( StringData::getEmpty() )
|
|
||||||
{}
|
|
||||||
|
|
||||||
String::String( StringRef const& stringRef )
|
|
||||||
: m_data( StringData::create( stringRef ) )
|
|
||||||
{}
|
|
||||||
|
|
||||||
String::String( char const* rawString )
|
|
||||||
: String( StringRef( rawString ) )
|
|
||||||
{}
|
|
||||||
|
|
||||||
String::String( String const& other )
|
|
||||||
: m_data( other.m_data )
|
|
||||||
{
|
|
||||||
m_data->addRef();
|
|
||||||
}
|
|
||||||
String::String( String&& other ) noexcept
|
|
||||||
: m_data( other.m_data )
|
|
||||||
{
|
|
||||||
other.m_data = StringData::getEmpty();
|
|
||||||
}
|
|
||||||
String::String( StringBuilder&& stringBuf )
|
|
||||||
: m_data( stringBuf.m_data )
|
|
||||||
{
|
|
||||||
// const_cast is ok here because we are taking ownership
|
|
||||||
const_cast<StringData*>( m_data )->size = stringBuf.size();
|
|
||||||
stringBuf.m_data = StringData::getEmpty();
|
|
||||||
stringBuf.m_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String::~String() noexcept {
|
|
||||||
m_data->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto String::operator = ( String const& other ) -> String& {
|
|
||||||
m_data = other.m_data;
|
|
||||||
m_data->addRef();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
auto String::empty() const noexcept -> bool {
|
|
||||||
return m_data->size == 0;
|
|
||||||
}
|
|
||||||
auto String::size() const noexcept -> size_type {
|
|
||||||
return m_data->size;
|
|
||||||
}
|
|
||||||
auto String::numberOfCharacters() const noexcept -> size_type {
|
|
||||||
return StringRef( *this ).numberOfCharacters();
|
|
||||||
}
|
|
||||||
auto String::c_str() const noexcept -> char const* {
|
|
||||||
return m_data->chars;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto String::operator == ( StringRef const& other ) const noexcept -> bool {
|
|
||||||
return other == StringRef( *this );
|
|
||||||
}
|
|
||||||
auto String::operator == ( char const* other ) const noexcept -> bool {
|
|
||||||
return StringRef( other ) == StringRef( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& os, String const& str ) {
|
|
||||||
os << str.c_str();
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef CATCH_STRING_H_INCLUDED
|
|
||||||
#define CATCH_STRING_H_INCLUDED
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class StringData;
|
|
||||||
class StringRef;
|
|
||||||
class StringBuilder;
|
|
||||||
|
|
||||||
/// An owning, ref-counted, immutable string type.
|
|
||||||
/// The ref count (not visible here as it is defined in StringData) is atomic
|
|
||||||
/// so instances should be safe to share across threads
|
|
||||||
class String {
|
|
||||||
friend class StringRef;
|
|
||||||
friend class StringBuilder;
|
|
||||||
|
|
||||||
StringData const* m_data = nullptr;
|
|
||||||
public:
|
|
||||||
using size_type = size_t;
|
|
||||||
|
|
||||||
String();
|
|
||||||
String( StringRef const& stringRef );
|
|
||||||
String( char const* rawString );
|
|
||||||
String( String const& other );
|
|
||||||
String( String&& other ) noexcept;
|
|
||||||
String( StringBuilder&& stringBuf );
|
|
||||||
|
|
||||||
~String() noexcept;
|
|
||||||
|
|
||||||
auto operator = ( String const& other ) -> String&;
|
|
||||||
|
|
||||||
auto operator == ( StringRef const& other ) const noexcept -> bool;
|
|
||||||
auto operator == ( char const* other ) const noexcept -> bool;
|
|
||||||
|
|
||||||
auto empty() const noexcept -> bool;
|
|
||||||
auto size() const noexcept -> size_type;
|
|
||||||
auto numberOfCharacters() const noexcept -> size_type;
|
|
||||||
|
|
||||||
auto c_str() const noexcept -> char const*;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
||||||
|
|
||||||
#endif // CATCH_STRING_H_INCLUDED
|
|
@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "catch_stringbuilder.h"
|
|
||||||
#include "catch_stringref.h"
|
|
||||||
#include "catch_stringdata.h"
|
|
||||||
#include "catch_string.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cassert>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
static const StringBuilder::size_type s_minimumCapacity = 32;
|
|
||||||
|
|
||||||
StringBuilder::StringBuilder()
|
|
||||||
: m_data( StringData::getEmpty() )
|
|
||||||
{}
|
|
||||||
|
|
||||||
StringBuilder::StringBuilder( size_type initialCapacity )
|
|
||||||
: m_size( 0 ),
|
|
||||||
m_data( StringData::create( StringRef(), initialCapacity ) )
|
|
||||||
{}
|
|
||||||
StringBuilder::StringBuilder( StringRef const& str, size_type initialCapacity )
|
|
||||||
: m_size( str.size() ),
|
|
||||||
m_data( StringData::create( str, initialCapacity ) )
|
|
||||||
{}
|
|
||||||
StringBuilder::StringBuilder( StringBuilder const& other, size_type initialCapacity )
|
|
||||||
: StringBuilder( StringRef( other.m_data->chars, other.m_size ), initialCapacity )
|
|
||||||
{}
|
|
||||||
StringBuilder::StringBuilder( StringBuilder&& other ) noexcept
|
|
||||||
: StringBuilder()
|
|
||||||
{
|
|
||||||
swap( other );
|
|
||||||
}
|
|
||||||
StringBuilder::StringBuilder( String&& str )
|
|
||||||
: m_size( str.size() ),
|
|
||||||
m_data( StringData::getEmpty() )
|
|
||||||
{
|
|
||||||
if( str.m_data->isUniquelyOwned() )
|
|
||||||
{
|
|
||||||
std::swap( m_data, const_cast<StringData*&>( str.m_data ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size_type initialCapacity = std::min( s_minimumCapacity, m_size );
|
|
||||||
m_data = StringData::create( str, initialCapacity );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StringBuilder::StringBuilder( String const& other )
|
|
||||||
: StringBuilder( StringRef( other ), std::min( s_minimumCapacity, other.size() ) )
|
|
||||||
{}
|
|
||||||
|
|
||||||
StringBuilder::~StringBuilder() noexcept {
|
|
||||||
m_data->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto StringBuilder::size() const noexcept -> size_type {
|
|
||||||
return m_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringBuilder::swap( StringBuilder& other ) noexcept {
|
|
||||||
std::swap( m_size, other.m_size );
|
|
||||||
std::swap( m_data, other.m_data );
|
|
||||||
}
|
|
||||||
void StringBuilder::reserve( size_type minimumCapacity ) {
|
|
||||||
if( minimumCapacity > capacity() ) {
|
|
||||||
StringBuilder temp( *this, minimumCapacity );
|
|
||||||
swap( temp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void StringBuilder::reserveExponential( size_type minimumCapacity ) {
|
|
||||||
if( minimumCapacity > capacity() ) {
|
|
||||||
size_type candidateCapacity = capacity() < s_minimumCapacity ? s_minimumCapacity : capacity()*2;
|
|
||||||
while( candidateCapacity < minimumCapacity )
|
|
||||||
candidateCapacity = candidateCapacity * 3/2; // grow factor of 1.5
|
|
||||||
StringBuilder temp( *this, candidateCapacity );
|
|
||||||
swap( temp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto StringBuilder::capacity() const noexcept -> size_type {
|
|
||||||
return m_data->size;
|
|
||||||
}
|
|
||||||
void StringBuilder::writeTo( size_type index, StringRef const& str ) {
|
|
||||||
assert( index + str.size() < capacity() );
|
|
||||||
if( str.size() > 0 )
|
|
||||||
std::memcpy( m_data->chars+index, str.data(), str.size() );
|
|
||||||
}
|
|
||||||
void StringBuilder::append( StringRef const& str ) {
|
|
||||||
reserveExponential( m_size + str.size() + 1 );
|
|
||||||
writeTo( m_size, str );
|
|
||||||
m_size += str.size();
|
|
||||||
m_data->chars[m_size] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
auto operator << ( StringBuilder& sb, StringRef sr ) -> StringBuilder& {
|
|
||||||
sb.append( sr );
|
|
||||||
return sb;
|
|
||||||
}
|
|
||||||
auto operator << ( StringBuilder&& sb, StringRef sr ) -> StringBuilder&& {
|
|
||||||
sb.append( sr );
|
|
||||||
return std::move( sb );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef CATCH_STRINGBUILDER_H_INCLUDED
|
|
||||||
#define CATCH_STRINGBUILDER_H_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_stringref.h"
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class String;
|
|
||||||
class StringData;
|
|
||||||
|
|
||||||
/// A mutable container for string data
|
|
||||||
/// Use to build up strings before transferring to an immutable String.
|
|
||||||
/// Construct the String using the rvalue reference constructor (which
|
|
||||||
/// will usually involve std::move-ing the StringBuilder). This will transfer
|
|
||||||
/// The underlying buffer without any extra allocations or ref counts.
|
|
||||||
class StringBuilder {
|
|
||||||
friend class String;
|
|
||||||
public:
|
|
||||||
using size_type = size_t;
|
|
||||||
|
|
||||||
StringBuilder();
|
|
||||||
StringBuilder( size_type initialCapacity );
|
|
||||||
StringBuilder( StringRef const& str, size_type initialCapacity );
|
|
||||||
StringBuilder( StringBuilder const& other, size_type initialCapacity );
|
|
||||||
StringBuilder( StringBuilder&& other ) noexcept;
|
|
||||||
StringBuilder( String&& other );
|
|
||||||
StringBuilder( String const& other );
|
|
||||||
~StringBuilder() noexcept;
|
|
||||||
|
|
||||||
void swap( StringBuilder& other ) noexcept;
|
|
||||||
|
|
||||||
auto size() const noexcept -> size_type;
|
|
||||||
auto capacity() const noexcept -> size_type;
|
|
||||||
|
|
||||||
/// Grows the buffer to exactly the capacity requested, or
|
|
||||||
/// does nothing if it is already at least as big
|
|
||||||
void reserve(size_type capacity);
|
|
||||||
|
|
||||||
/// Grows the buffer exponentially (from a baseline of 32 bytes)
|
|
||||||
/// until it is at least as large as the requested capacity -
|
|
||||||
/// or does nothing if already large enough
|
|
||||||
void reserveExponential(size_type capacity);
|
|
||||||
|
|
||||||
/// Writes the string at the current insertion point then moves
|
|
||||||
/// the insertion point forward by the string length.
|
|
||||||
/// If the buffer needs to grow to accomodate the string it does so
|
|
||||||
/// using the exponential strategy
|
|
||||||
void append( StringRef const& str );
|
|
||||||
|
|
||||||
friend auto operator << ( StringBuilder& sb, StringRef sr ) -> StringBuilder&;
|
|
||||||
friend auto operator << ( StringBuilder&& sb, StringRef sr ) -> StringBuilder&&;
|
|
||||||
|
|
||||||
/// Writes the contents of the string ref into the buffer at
|
|
||||||
/// the indexed location.
|
|
||||||
/// The bounds are not checked! Use append() to just add to the
|
|
||||||
/// end of the buffer, extending it if the capacity is not enough.
|
|
||||||
void writeTo( size_type index, StringRef const& str );
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_type m_size = 0;
|
|
||||||
StringData* m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
||||||
|
|
||||||
#endif // CATCH_STRINGBUILDER_H_INCLUDED
|
|
@ -6,8 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "catch_stringref.h"
|
#include "catch_stringref.h"
|
||||||
#include "catch_stringbuilder.h"
|
|
||||||
#include "catch_string.h"
|
|
||||||
#include "catch_stringdata.h"
|
#include "catch_stringdata.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -58,18 +56,6 @@ namespace Catch {
|
|||||||
m_size = rawSize;
|
m_size = rawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef::StringRef( String const& other ) noexcept
|
|
||||||
: m_start( other.c_str() ),
|
|
||||||
m_size( other.size() )
|
|
||||||
{}
|
|
||||||
|
|
||||||
StringRef::StringRef( String&& str ) noexcept
|
|
||||||
: m_start( str.c_str() ),
|
|
||||||
m_size( str.size() ),
|
|
||||||
m_data( str.m_data )
|
|
||||||
{
|
|
||||||
str.m_data = StringData::getEmpty();
|
|
||||||
}
|
|
||||||
StringRef::StringRef( std::string const& stdString ) noexcept
|
StringRef::StringRef( std::string const& stdString ) noexcept
|
||||||
: m_start( stdString.c_str() ),
|
: m_start( stdString.c_str() ),
|
||||||
m_size( stdString.size() )
|
m_size( stdString.size() )
|
||||||
@ -112,8 +98,8 @@ namespace Catch {
|
|||||||
|
|
||||||
void StringRef::takeOwnership() {
|
void StringRef::takeOwnership() {
|
||||||
if( !isOwned() ) {
|
if( !isOwned() ) {
|
||||||
StringRef temp = String( *this );
|
m_data = StringData::create( *this );
|
||||||
swap( temp );
|
m_start = m_data->chars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {
|
auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {
|
||||||
@ -159,18 +145,18 @@ namespace Catch {
|
|||||||
return noChars;
|
return noChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> String {
|
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string {
|
||||||
StringBuilder buf;
|
std::string str;
|
||||||
buf.reserve( lhs.size() + rhs.size() );
|
str.reserve( lhs.size() + rhs.size() );
|
||||||
buf.append( lhs );
|
str += lhs;
|
||||||
buf.append( rhs );
|
str += rhs;
|
||||||
return String( std::move( buf ) );
|
return str;
|
||||||
}
|
}
|
||||||
auto operator + ( StringRef const& lhs, const char* rhs ) -> String {
|
auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string {
|
||||||
return lhs + StringRef( rhs );
|
return std::string( lhs ) + std::string( rhs );
|
||||||
}
|
}
|
||||||
auto operator + ( char const* lhs, StringRef const& rhs ) -> String {
|
auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string {
|
||||||
return StringRef( lhs ) + rhs;
|
return std::string( lhs ) + std::string( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class String;
|
|
||||||
class StringData;
|
class StringData;
|
||||||
|
|
||||||
/// A non-owning string class (similar to the forthcoming std::string_view)
|
/// A non-owning string class (similar to the forthcoming std::string_view)
|
||||||
@ -26,7 +25,6 @@ namespace Catch {
|
|||||||
class StringRef {
|
class StringRef {
|
||||||
friend struct StringRefTestAccess;
|
friend struct StringRefTestAccess;
|
||||||
friend class StringData;
|
friend class StringData;
|
||||||
friend class StringBuilder;
|
|
||||||
|
|
||||||
using size_type = size_t;
|
using size_type = size_t;
|
||||||
|
|
||||||
@ -43,8 +41,6 @@ namespace Catch {
|
|||||||
StringRef( StringRef&& other ) noexcept;
|
StringRef( StringRef&& other ) noexcept;
|
||||||
StringRef( char const* rawChars ) noexcept;
|
StringRef( char const* rawChars ) noexcept;
|
||||||
StringRef( char const* rawChars, size_type size ) noexcept;
|
StringRef( char const* rawChars, size_type size ) noexcept;
|
||||||
StringRef( String const& other ) noexcept;
|
|
||||||
StringRef( String&& other ) noexcept;
|
|
||||||
StringRef( std::string const& stdString ) noexcept;
|
StringRef( std::string const& stdString ) noexcept;
|
||||||
~StringRef() noexcept;
|
~StringRef() noexcept;
|
||||||
|
|
||||||
@ -74,9 +70,9 @@ namespace Catch {
|
|||||||
auto data() const noexcept -> char const*;
|
auto data() const noexcept -> char const*;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> String;
|
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string;
|
||||||
auto operator + ( StringRef const& lhs, char const* rhs ) -> String;
|
auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string;
|
||||||
auto operator + ( char const* lhs, StringRef const& rhs ) -> String;
|
auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string;
|
||||||
|
|
||||||
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
|
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
|
||||||
|
|
||||||
|
@ -1020,6 +1020,6 @@ with expansion:
|
|||||||
"{?}" == "1"
|
"{?}" == "1"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 183 | 132 passed | 47 failed | 4 failed as expected
|
test cases: 181 | 130 passed | 47 failed | 4 failed as expected
|
||||||
assertions: 908 | 791 passed | 96 failed | 21 failed as expected
|
assertions: 876 | 759 passed | 96 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@ -4257,50 +4257,6 @@ MatchersTests.cpp:<line number>: FAILED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "string"
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
String
|
|
||||||
empty string
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
String.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
String.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( empty.empty() )
|
|
||||||
with expansion:
|
|
||||||
true
|
|
||||||
|
|
||||||
String.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( empty.size() == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
String.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
String
|
|
||||||
from literal
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
String.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
String.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s.empty() == false )
|
|
||||||
with expansion:
|
|
||||||
false == false
|
|
||||||
|
|
||||||
String.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s.size() == 5 )
|
|
||||||
with expansion:
|
|
||||||
5 == 5
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
String matchers
|
String matchers
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -4331,172 +4287,6 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ends with: "substring"
|
"this string contains 'abc' as a substring" ends with: "substring"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
basic
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.capacity() == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.size() == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.capacity() == 32 )
|
|
||||||
with expansion:
|
|
||||||
32 == 32
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.size() == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.capacity() == 32 )
|
|
||||||
with expansion:
|
|
||||||
32 == 32
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb.size() == 5 )
|
|
||||||
with expansion:
|
|
||||||
5 == 5
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s == "hello" )
|
|
||||||
with expansion:
|
|
||||||
hello == "hello"
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s.size() == 5 )
|
|
||||||
with expansion:
|
|
||||||
5 == 5
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
concatenation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s == "hello world" )
|
|
||||||
with expansion:
|
|
||||||
hello world == "hello world"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
concat & move
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s == "hello world" )
|
|
||||||
with expansion:
|
|
||||||
hello world == "hello world"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
reserved
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb16.capacity() == 16 )
|
|
||||||
with expansion:
|
|
||||||
16 == 16
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( sb16.capacity() == 16 )
|
|
||||||
with expansion:
|
|
||||||
16 == 16
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s == "hello world" )
|
|
||||||
with expansion:
|
|
||||||
hello world == "hello world"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
from String
|
|
||||||
copy
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2 == s )
|
|
||||||
with expansion:
|
|
||||||
hello == hello
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2.c_str() != s.c_str() )
|
|
||||||
with expansion:
|
|
||||||
"hello" != "hello"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
from String
|
|
||||||
move from uniquely owned string
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2 == "hello" )
|
|
||||||
with expansion:
|
|
||||||
hello == "hello"
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2.c_str() == originalPointer )
|
|
||||||
with expansion:
|
|
||||||
"hello" == "hello"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder
|
|
||||||
from String
|
|
||||||
move from shared string (copies)
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringBuilder.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2 == "hello" )
|
|
||||||
with expansion:
|
|
||||||
hello == "hello"
|
|
||||||
|
|
||||||
StringBuilder.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( s2.c_str() != originalPointer )
|
|
||||||
with expansion:
|
|
||||||
"hello" != "hello"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
StringRef
|
StringRef
|
||||||
Empty string
|
Empty string
|
||||||
@ -4744,70 +4534,6 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
hello != cello
|
hello != cello
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringRef
|
|
||||||
From string
|
|
||||||
Copied
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringRef.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( copied == "hot potato" )
|
|
||||||
with expansion:
|
|
||||||
hot potato == "hot potato"
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( str == "hot potato" )
|
|
||||||
with expansion:
|
|
||||||
hot potato == "hot potato"
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( isOwned( copied ) == false )
|
|
||||||
with expansion:
|
|
||||||
false == false
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( data( copied ) == originalPointer )
|
|
||||||
with expansion:
|
|
||||||
"hot potato" == "hot potato"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringRef
|
|
||||||
From string
|
|
||||||
Moved
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
StringRef.tests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( copied == "hot potato" )
|
|
||||||
with expansion:
|
|
||||||
hot potato == "hot potato"
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( isOwned( copied ) )
|
|
||||||
with expansion:
|
|
||||||
true
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( str.empty() )
|
|
||||||
with expansion:
|
|
||||||
true
|
|
||||||
|
|
||||||
StringRef.tests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( data( copied ) == originalPointer )
|
|
||||||
with expansion:
|
|
||||||
"hot potato" == "hot potato"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
StringRef
|
StringRef
|
||||||
from std::string
|
from std::string
|
||||||
@ -7737,6 +7463,6 @@ MiscTests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 183 | 129 passed | 50 failed | 4 failed as expected
|
test cases: 181 | 127 passed | 50 failed | 4 failed as expected
|
||||||
assertions: 910 | 787 passed | 102 failed | 21 failed as expected
|
assertions: 878 | 755 passed | 102 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuitesloose text artifact
|
<testsuitesloose text artifact
|
||||||
>
|
>
|
||||||
<testsuite name="<exe-name>" errors="15" failures="88" tests="911" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
<testsuite name="<exe-name>" errors="15" failures="88" tests="879" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
|
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
|
||||||
<error type="TEST_CASE">
|
<error type="TEST_CASE">
|
||||||
@ -505,16 +505,7 @@ Message from section two
|
|||||||
MatchersTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="<exe-name>.global" name="String/empty string" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="String/from literal" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="String matchers" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="String matchers" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/basic" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/concatenation" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/concat & move" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/reserved" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/from String/copy" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/from String/move from uniquely owned string" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringBuilder/from String/move from shared string (copies)" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/>
|
||||||
@ -529,8 +520,6 @@ StringRef.tests.cpp:<line number>
|
|||||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of substring refs should not match" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of substring refs should not match" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string/Copied" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string/Moved" time="{duration}"/>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/from std::string/implicitly constructed" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/from std::string/implicitly constructed" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/from std::string/explicitly constructed" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/from std::string/explicitly constructed" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/from std::string/assigned" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/from std::string/assigned" time="{duration}"/>
|
||||||
|
@ -4860,55 +4860,6 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="String" tags="[Strings]" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Section name="empty string" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
empty.empty()
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
true
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
empty.size() == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
std::strcmp( empty.c_str(), "" ) == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="from literal" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s.empty() == false
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
false == false
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/String.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s.size() == 5
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
5 == 5
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResult success="true"/>
|
|
||||||
</TestCase>
|
|
||||||
<TestCase name="String matchers" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
<TestCase name="String matchers" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
@ -4944,191 +4895,6 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="StringBuilder" tags="[Strings]" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Section name="basic" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.capacity() == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.size() == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.capacity() == 32
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
32 == 32
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.size() == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.capacity() == 32
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
32 == 32
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb.size() == 5
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
5 == 5
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s == "hello"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello == "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s.size() == 5
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
5 == 5
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="8" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="concatenation" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s == "hello world"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello world == "hello world"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="concat & move" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s == "hello world"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello world == "hello world"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="reserved" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb16.capacity() == 16
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
16 == 16
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
sb16.capacity() == 16
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
16 == 16
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s == "hello world"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello world == "hello world"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="from String" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Section name="copy" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2 == s
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello == hello
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2.c_str() != s.c_str()
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"hello" != "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="from String" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Section name="move from uniquely owned string" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2 == "hello"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello == "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2.c_str() == originalPointer
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"hello" == "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="from String" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Section name="move from shared string (copies)" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2 == "hello"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hello == "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
s2.c_str() != originalPointer
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"hello" != "hello"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResult success="true"/>
|
|
||||||
</TestCase>
|
|
||||||
<TestCase name="StringRef" tags="[Strings]" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<TestCase name="StringRef" tags="[Strings]" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
<Section name="Empty string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<Section name="Empty string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
@ -5407,82 +5173,6 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="From string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Section name="Copied" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
copied == "hot potato"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hot potato == "hot potato"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
str == "hot potato"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hot potato == "hot potato"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
isOwned( copied ) == false
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
false == false
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
data( copied ) == originalPointer
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"hot potato" == "hot potato"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="From string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Section name="Moved" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
copied == "hot potato"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
hot potato == "hot potato"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
isOwned( copied )
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
true
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
str.empty()
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
true
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
|
||||||
<Original>
|
|
||||||
data( copied ) == originalPointer
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"hot potato" == "hot potato"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="from std::string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<Section name="from std::string" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
<Section name="implicitly constructed" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<Section name="implicitly constructed" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||||
@ -8568,7 +8258,7 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="787" failures="103" expectedFailures="21"/>
|
<OverallResults successes="755" failures="103" expectedFailures="21"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="787" failures="102" expectedFailures="21"/>
|
<OverallResults successes="755" failures="102" expectedFailures="21"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include "../include/internal/catch_string.h"
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
TEST_CASE( "String", "[Strings]" ) {
|
|
||||||
using Catch::String;
|
|
||||||
|
|
||||||
SECTION( "empty string" ) {
|
|
||||||
String empty;
|
|
||||||
REQUIRE( empty.empty() );
|
|
||||||
REQUIRE( empty.size() == 0 );
|
|
||||||
REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 );
|
|
||||||
}
|
|
||||||
SECTION( "from literal" ) {
|
|
||||||
String s = "hello";
|
|
||||||
REQUIRE( s.empty() == false );
|
|
||||||
REQUIRE( s.size() == 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
#include "internal/catch_stringbuilder.h"
|
|
||||||
#include "../include/internal/catch_stringref.h"
|
|
||||||
#include "../include/internal/catch_string.h"
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
TEST_CASE( "StringBuilder", "[Strings]" ) {
|
|
||||||
|
|
||||||
using Catch::StringBuilder;
|
|
||||||
using Catch::String;
|
|
||||||
|
|
||||||
StringBuilder sb;
|
|
||||||
|
|
||||||
SECTION( "basic" ) {
|
|
||||||
REQUIRE( sb.capacity() == 0 );
|
|
||||||
REQUIRE( sb.size() == 0 );
|
|
||||||
|
|
||||||
sb.reserve( 32 );
|
|
||||||
REQUIRE( sb.capacity() == 32 );
|
|
||||||
REQUIRE( sb.size() == 0 );
|
|
||||||
|
|
||||||
sb.append( "hello" );
|
|
||||||
REQUIRE( sb.capacity() == 32 );
|
|
||||||
REQUIRE( sb.size() == 5 );
|
|
||||||
|
|
||||||
String s = std::move( sb );
|
|
||||||
REQUIRE( s == "hello" );
|
|
||||||
REQUIRE( s.size() == 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "concatenation" ) {
|
|
||||||
sb << "hello" << " " << "world";
|
|
||||||
String s = std::move( sb );
|
|
||||||
REQUIRE( s == "hello world" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "concat & move" ) {
|
|
||||||
String s = StringBuilder() << "hello" << " " << "world";
|
|
||||||
REQUIRE( s == "hello world" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "reserved" ) {
|
|
||||||
StringBuilder sb16( 16 );
|
|
||||||
REQUIRE( sb16.capacity() == 16 );
|
|
||||||
sb16 << "hello" << " " << "world";
|
|
||||||
REQUIRE( sb16.capacity() == 16 );
|
|
||||||
String s = std::move( sb16 );
|
|
||||||
REQUIRE( s == "hello world" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "from String" ) {
|
|
||||||
String s = "hello";
|
|
||||||
|
|
||||||
SECTION( "copy" ) {
|
|
||||||
StringBuilder sb2 = s;
|
|
||||||
String s2( std::move(sb2) );
|
|
||||||
REQUIRE( s2 == s );
|
|
||||||
REQUIRE( s2.c_str() != s.c_str() );
|
|
||||||
}
|
|
||||||
SECTION( "move from uniquely owned string" ) {
|
|
||||||
auto originalPointer = s.c_str();
|
|
||||||
StringBuilder sb2( std::move( s ) );
|
|
||||||
String s2( std::move(sb2) );
|
|
||||||
REQUIRE( s2 == "hello" );
|
|
||||||
REQUIRE( s2.c_str() == originalPointer );
|
|
||||||
}
|
|
||||||
SECTION( "move from shared string (copies)" ) {
|
|
||||||
auto originalPointer = s.c_str();
|
|
||||||
String keepAlive = s;
|
|
||||||
StringBuilder sb2( std::move( s ) );
|
|
||||||
String s2( std::move(sb2) );
|
|
||||||
REQUIRE( s2 == "hello" );
|
|
||||||
REQUIRE( s2.c_str() != originalPointer );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
#include "../include/internal/catch_stringref.h"
|
#include "../include/internal/catch_stringref.h"
|
||||||
#include "../include/internal/catch_string.h"
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
@ -40,7 +39,6 @@ namespace Catch {
|
|||||||
TEST_CASE( "StringRef", "[Strings]" ) {
|
TEST_CASE( "StringRef", "[Strings]" ) {
|
||||||
|
|
||||||
using Catch::StringRef;
|
using Catch::StringRef;
|
||||||
using Catch::String;
|
|
||||||
|
|
||||||
SECTION( "Empty string" ) {
|
SECTION( "Empty string" ) {
|
||||||
StringRef empty;
|
StringRef empty;
|
||||||
@ -125,32 +123,6 @@ TEST_CASE( "StringRef", "[Strings]" ) {
|
|||||||
REQUIRE( StringRef("hello") != StringRef("cello") );
|
REQUIRE( StringRef("hello") != StringRef("cello") );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "From string" ) {
|
|
||||||
String str = "hot potato";
|
|
||||||
auto originalPointer = str.c_str();
|
|
||||||
|
|
||||||
SECTION( "Copied" ) {
|
|
||||||
// After a String is "copied" to a StringRef
|
|
||||||
// It has only copied the pointer and size
|
|
||||||
// - it does not take ownership
|
|
||||||
StringRef copied = str;
|
|
||||||
REQUIRE( copied == "hot potato" );
|
|
||||||
REQUIRE( str == "hot potato" );
|
|
||||||
REQUIRE( isOwned( copied ) == false );
|
|
||||||
REQUIRE( data( copied ) == originalPointer );
|
|
||||||
}
|
|
||||||
SECTION( "Moved" ) {
|
|
||||||
// After a String is *moved* to a StringRef
|
|
||||||
// The StringRef takes ownership of the underlying data
|
|
||||||
// and the String is left in an empty state
|
|
||||||
StringRef copied = std::move( str );
|
|
||||||
REQUIRE( copied == "hot potato" );
|
|
||||||
REQUIRE( isOwned( copied ) );
|
|
||||||
REQUIRE( str.empty() );
|
|
||||||
REQUIRE( data( copied ) == originalPointer );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "from std::string" ) {
|
SECTION( "from std::string" ) {
|
||||||
std::string stdStr = "a standard string";
|
std::string stdStr = "a standard string";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user