written some tests based on a non-working feature (operator[] =

operator[])
This commit is contained in:
Kjistóf 2016-11-02 10:59:41 +01:00
parent bdfc14357a
commit da378efaaa
2 changed files with 14 additions and 1 deletions

View File

@ -86,6 +86,11 @@ int main()
if (str[1] == 'i')
std::cout << "String::operator[] works" << std::endl;
String sajtok = "sajtok";
sajtok[5] = sajtok[0];
if (!std::strcmp(sajtok.c_str(), "sajtos"))
std::cout << "String::operator[]'s operator= works with other String::operator[]s" << std::endl;
try { str[8]; }
catch (std::out_of_range)
{ std::cout << "String::operator[] throws when index is out of range" << std::endl; }

View File

@ -173,7 +173,15 @@ TEST(StringTest, indexOperatorWorks)
EXPECT_EQ(i, str[1]);
}
TEST(StringTest, indexoperatorBoundCheckWorks)
TEST(StringTest, indexOperatorWorksWhenUsedWithOtherIndexOperators)
{
String sajtok = "sajtok";
sajtok[5] = sajtok[0];
EXPECT_STREQ("sajtos", sajtok.c_str());
}
TEST(StringTest, indexOperatorBoundCheckWorks)
{
String str("sajt");