Fix operator+ for non-full arrays

This commit is contained in:
Krystian Stasiowski
2020-03-06 22:26:06 -05:00
parent 2584ab2400
commit 5934a28124
2 changed files with 27 additions and 11 deletions

View File

@ -7096,7 +7096,7 @@ testOperatorPlus()
{
auto res = s1 + "world";
BOOST_TEST(res == "helloworld");
BOOST_TEST(res.capacity() == 15);
BOOST_TEST(res.capacity() == 16);
BOOST_TEST(res.size() == 10);
}
@ -7104,7 +7104,25 @@ testOperatorPlus()
{
auto res = "hello" + s2;
BOOST_TEST(res == "helloworld");
BOOST_TEST(res.capacity() == 15);
BOOST_TEST(res.capacity() == 16);
BOOST_TEST(res.size() == 10);
}
// operator+(static_string, CharT(&)[N]), no null
{
char arr[10] = {'w', 'o', 'r', 'l', 'd'};
auto res = s1 + arr;
BOOST_TEST(res == "helloworld");
BOOST_TEST(res.capacity() == 20);
BOOST_TEST(res.size() == 10);
}
// operator+(CharT(&)[N], static_string), no null
{
char arr[10] = {'h', 'e', 'l', 'l', 'o'};
auto res = arr + s2;
BOOST_TEST(res == "helloworld");
BOOST_TEST(res.capacity() == 20);
BOOST_TEST(res.size() == 10);
}
}