diff --git a/src/TNL/String.cpp b/src/TNL/String.cpp index 40e36bbde0c0416c7102c76925251cee39ee679b..292d90c0a5a60c5e15546ba207e3efd271c4a208 100644 --- a/src/TNL/String.cpp +++ b/src/TNL/String.cpp @@ -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" ); diff --git a/src/TNL/String.h b/src/TNL/String.h index 96f625b0065df3f3ad9e1851083e66a0c0cd401f..f5657a20ff089a5219d931083e3b7b1fd05bfab1 100644 --- a/src/TNL/String.h +++ b/src/TNL/String.h @@ -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(); diff --git a/src/UnitTests/Containers/ListTest.cpp b/src/UnitTests/Containers/ListTest.cpp index 8ff4713f88823c697accfc5d80f66fa45dc0662a..3b5fdaecf385dab8da032a020ef6b6511ccf0c18 100644 --- a/src/UnitTests/Containers/ListTest.cpp +++ b/src/UnitTests/Containers/ListTest.cpp @@ -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 ] );