Loading src/TNL/String.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,11 @@ String :: operator bool () const return false; } bool String :: operator ! () const { return ! operator bool(); } bool String :: operator != ( const char* str ) const { return ! operator == ( str ); Loading src/TNL/String.h +4 −1 Original line number Diff line number Diff line Loading @@ -121,9 +121,12 @@ class String //! Comparison operator bool operator != ( const char* ) const; //! Retyping operator //! Cast to bool operator operator bool () const; //! Cast to bool with negation operator bool operator ! () const; //! Return length of the string int getLength() const; Loading src/UnitTests/StringTest.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,16 @@ TEST( StringTest, AdditionAssignmentOperator ) ASSERT_EQ( strcmp( string2. getString(), "stringstring2" ), 0 ); } TEST( StringTest, CastToBoolOperator ) { String string; EXPECT_TRUE( ! string ); EXPECT_FALSE( string ); string.setString( "foo" ); EXPECT_TRUE( string ); EXPECT_FALSE( ! string ); } TEST( StringTest, strip ) { EXPECT_EQ( String( "string" ).strip(), String( "string" ) ); Loading Loading
src/TNL/String.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,11 @@ String :: operator bool () const return false; } bool String :: operator ! () const { return ! operator bool(); } bool String :: operator != ( const char* str ) const { return ! operator == ( str ); Loading
src/TNL/String.h +4 −1 Original line number Diff line number Diff line Loading @@ -121,9 +121,12 @@ class String //! Comparison operator bool operator != ( const char* ) const; //! Retyping operator //! Cast to bool operator operator bool () const; //! Cast to bool with negation operator bool operator ! () const; //! Return length of the string int getLength() const; Loading
src/UnitTests/StringTest.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,16 @@ TEST( StringTest, AdditionAssignmentOperator ) ASSERT_EQ( strcmp( string2. getString(), "stringstring2" ), 0 ); } TEST( StringTest, CastToBoolOperator ) { String string; EXPECT_TRUE( ! string ); EXPECT_FALSE( string ); string.setString( "foo" ); EXPECT_TRUE( string ); EXPECT_FALSE( ! string ); } TEST( StringTest, strip ) { EXPECT_EQ( String( "string" ).strip(), String( "string" ) ); Loading