nsCStrings1("This is a reasonable length string with some text in it and it is good.");
nsCStrings2("This is another string that I will use in the concatenation test.");
nsCStrings3("This is yet a third string that I will use in the concatenation test.");
nsCStrings4(s1+s2+s3+s1+s2+s3);
if(TotalLength(s4)!=(71+65+69+71+65+69))
{
cout<<"|test_concat()| FAILED"<<endl;
returnkTestFailed;
}
{
TestTimertimer;
for(inti=0;i<N;++i)
s4=s1+s2+s3+s1+s2+s3;
}
cout<<"s4 = s1 + s2 + s3 + s1 + s2 + s3"<<endl;
{
TestTimertimer;
for(inti=0;i<N;++i)
s4=s1+s2;
}
cout<<"s4 = s1 + s2"<<endl;
returnkTestSucceeded;
}
static
int
test_compare()
{
nsCStrings1("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThis is a reasonable length string with some text in it and it is good.");
nsCStrings2("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThis is a reasonable length string with some text in it and it is bad.");
intcount=0;
{
TestTimertimer;
for(inti=0;i<N;++i)
if(s1>s2)
++count;
}
cout<<"s1 > s2"<<endl;
{
TestTimertimer;
for(inti=0;i<N;++i)
if(s1==s1)
++count;
}
cout<<"s1 == s1"<<endl;
returnkTestSucceeded;
}
static
int
test_countchar()
{
nsCStrings1("This is a reasonable length string with some text in it and it is good.");
if(s1.CountChar('e')!=5)
{
cout<<"|test_countchar()| FAILED: found a count of "<<s1.CountChar('e')<<endl;
returnkTestFailed;
}
PRUint32total=0;
{
TestTimertimer;
for(inti=0;i<N;++i)
total+=s1.CountChar('e');
}
cout<<"s1.CountChar('e')"<<endl;
returnkTestSucceeded;
}
static
int
test_append_string()
{
nsCStrings1("This is a reasonable length string with some text in it and it is good.");
nsCStrings2("This is another string that I will use in the concatenation test.");
PRUint32len=0;
{
TestTimertimer;
for(inti=0;i<N;++i)
{
nsCStrings3;
s3.Append(s1);
s3.Append(s2);
len+=TotalLength(s3);
}
}
cout<<"s3.Append(s1); s3.Append(s2)"<<endl;
returnkTestSucceeded;
}
static
int
test_repeated_append_string()
{
nsCStrings1("This is a reasonable length string with some text in it and it is good.");
nsCStrings2("This is another string that I will use in the concatenation test.");