Commit c58b3432 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added missing operator! to String

parent 2f2f4664
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 );
+4 −1
Original line number Diff line number Diff line
@@ -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;

+10 −0
Original line number Diff line number Diff line
@@ -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" ) );