Skip to content

Commit

Permalink
Added the following tests:
Browse files Browse the repository at this point in the history
1. fill
2. fill_n
3. move
4. move_backward
  • Loading branch information
Tomerkm committed Nov 18, 2023
1 parent 0012f86 commit 903cfa7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/src/unit-algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'}));
}
}


}

0 comments on commit 903cfa7

Please sign in to comment.