Added the following tests:

1. fill
2. fill_n
3. move
4. move_backward
pull/4210/head
Tomerkm 2023-11-18 11:42:51 +02:00
parent 0012f860e7
commit 903cfa7f67
1 changed files with 40 additions and 0 deletions

View File

@ -362,4 +362,44 @@ TEST_CASE("algorithms")
}
}
SECTION("fill")
{
SECTION("fill zeros")
{
json dest_arr = {1, 1, 1, 1, 1, 1, 1, 1, 1};
std::fill(dest_arr.begin(), dest_arr.end(), 0);
CHECK(dest_arr == json({0, 0, 0, 0, 0, 0, 0, 0, 0}));
}
SECTION("fill char value")
{
json dest_arr = {1, 1, 1, 1, 1, 1, 1, 1, 1};
const char val = '1';
std::fill(dest_arr.begin(), dest_arr.end(), val);
CHECK(dest_arr == json({val, val, val, val, val, val, val, val, val}));
}
SECTION("fill n zeros")
{
json dest_arr = {1, 1, 1, 1, 1, 1, 1, 1, 1};
const size_t n = 5;
std::fill_n(dest_arr.begin(), n, 0);
CHECK(dest_arr == json({0, 0, 0, 0, 0, 1, 1, 1, 1}));
}
SECTION("fill n chars")
{
json dest_arr = {1, 2, 3, 4, 5, 6, 7, '8', '9'};
const size_t n = 2;
std::fill_n(dest_arr.begin(), n, '1');
CHECK(dest_arr == json({'1', '1', 3, 4, 5, 6, 7, '8', '9'}));
}
}
}