Skip to content
Snippets Groups Projects
Commit e1a71c01 authored by Nina Džugasová's avatar Nina Džugasová
Browse files

Added tests(GetSize, GetAllocatedSize, GetString) and modified tests...

Added tests(GetSize, GetAllocatedSize, GetString) and modified tests (SetString, replace) in StringTest.
parent c47bdc17
No related branches found
No related tags found
1 merge request!15Nina
......@@ -62,6 +62,34 @@ TEST( StringTest, ConstructorWithNumber )
EXPECT_EQ( strcmp( string4.getString(), "false" ), 0 );
}
TEST( StringTest, GetSize )
{
String str1( "string" );
String str2( "12345" );
String str3( "string3" );
String str4( "String_4" );
String str5( "Last String" );
EXPECT_EQ( str1.getSize(), 6 );
EXPECT_EQ( str2.getSize(), 5 );
EXPECT_EQ( str3.getSize(), 7 );
EXPECT_EQ( str4.getSize(), 8 );
EXPECT_EQ( str5.getSize(), 11 );
EXPECT_EQ( str1.getLength(), 6 );
EXPECT_EQ( str2.getLength(), 5 );
EXPECT_EQ( str3.getLength(), 7 );
EXPECT_EQ( str4.getLength(), 8 );
EXPECT_EQ( str5.getLength(), 11 );
}
TEST( StringTest, GetAllocatedSize )
{
String str( "MeineKleine" );
EXPECT_EQ( str.getAllocatedSize(), 256 );
}
TEST( StringTest, SetSize )
{
String str;
......@@ -85,6 +113,15 @@ TEST( StringTest, SetString )
EXPECT_EQ( strcmp( str2.getString(), "string2" ), 0 );
EXPECT_EQ( strcmp( str3.getString(), "string3" ), 0 );
EXPECT_EQ( strcmp( str4.getString(), "string4" ), 0 );
str4.setString( "string4_2", 0, 2 );
EXPECT_EQ( strcmp( str4.getString(), "string4" ), 0 );
}
TEST( StringTest, GetString )
{
String str( "MyString" );
EXPECT_EQ( strcmp( str.getString(), "MyString" ), 0 );
}
TEST( StringTest, IndexingOperator )
......@@ -229,6 +266,9 @@ TEST( StringTest, replace )
EXPECT_EQ( String( "string" ).replace( "ing", "bc" ), "strbc" );
EXPECT_EQ( String( "abracadabra" ).replace( "ab", "CAT" ), "CATracadCATra" );
EXPECT_EQ( String( "abracadabra" ).replace( "ab", "CAT", 1 ), "CATracadabra" );
EXPECT_NE( String( "abracadabra" ).replace( "ab", "CAT", 2 ), "abracadCATra" );
EXPECT_NE( String( "abracadabra" ).replace( "ab", "CAT", 2 ), "abracadabra" );
EXPECT_EQ( String( "abracadabra" ).replace( "ab", "CAT", 2 ), "CATracadCATra" );
}
TEST( StringTest, strip )
......
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