Skip to content
Snippets Groups Projects
Commit 37ccaeec authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Fixed templated String constructor and added constructor from bool.

parent 4a3e590b
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,13 @@ String::String( const String& str )
setString( str.getString() );
}
String::String( const bool b )
: string( nullptr ), length( 0 )
{
if( b ) this->setString( "true" );
else this->setString( "false" );
}
String String::getType()
{
return String( "String" );
......
......@@ -59,7 +59,7 @@ public:
/// definition ( in operator << ). It leads to stack overflow and segmentation fault.
template< typename T >
explicit
String( T value )
String( const T& value )
: string( nullptr ), length( 0 )
{
std::stringstream str;
......@@ -67,6 +67,8 @@ public:
setString( str.str().data() );
}
String( const bool b );
//! Destructor
~String();
......
......@@ -41,16 +41,17 @@ TYPED_TEST_CASE( ListTest, ListTypes );
TYPED_TEST( ListTest, constructor )
{
using ListType = typename TestFixture::ListType;
using ValueType = typename ListType::ValueType;
ListType list;
EXPECT_TRUE( list.isEmpty() );
EXPECT_EQ( list.getSize(), 0 );
list.Append( 0 );
list.Append( ( ValueType ) 0 );
EXPECT_EQ( list.getSize(), 1 );
ListType copy( list );
list.Append( 0 );
list.Append( ( ValueType ) 0 );
EXPECT_EQ( list.getSize(), 2 );
EXPECT_EQ( copy.getSize(), 1 );
EXPECT_EQ( copy[ 0 ], list[ 0 ] );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment