Add copy tests

This commit is contained in:
Krystian Stasiowski
2020-02-21 13:21:59 -05:00
parent d0d13f4262
commit 7e1d985b5e
2 changed files with 24 additions and 7 deletions

View File

@ -3622,6 +3622,25 @@ testGeneral()
s1.resize(2),
std::length_error);
}
// copy
{
{
static_string<20> str = "helloworld";
char arr[20]{};
BOOST_TEST(str.copy(arr, str.size()) ==
str.size());
BOOST_TEST(str == arr);
BOOST_TEST_THROWS(
str.copy(arr, str.size(), str.size() + 1),
std::out_of_range);
}
{
static_string<20> str = "helloworld";
char arr[20]{};
BOOST_TEST(str.copy(arr, 2, 2) == 2);
BOOST_TEST(arr[0] == 'l' && arr[1] == 'l');
}
}
}
// done