Skip to content
Snippets Groups Projects
Commit c58b3432 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added missing operator! to String

parent 2f2f4664
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
......
......@@ -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;
......
......@@ -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" ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment