Skip to content

Commit 1011350

Browse files
Add zip unit test with constant vector
1 parent 130a539 commit 1011350

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

unit/util/range.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,34 @@ SCENARIO("range tests", "[core][util][range]")
217217
}
218218
}
219219
}
220+
GIVEN("A constant vectors of int and a list of strings.")
221+
{
222+
const std::vector<int> int_vector{41, 27};
223+
const std::list<std::string> string_list{"boo", "far"};
224+
WHEN("We zip the vector and the list")
225+
{
226+
auto range = make_range(int_vector).zip(string_list);
227+
REQUIRE(!range.empty());
228+
THEN("First pair is (1, foo)")
229+
{
230+
const std::pair<int, std::string> first_pair = *range.begin();
231+
REQUIRE(first_pair.first == 41);
232+
REQUIRE(first_pair.second == "boo");
233+
}
234+
range = std::move(range).drop(1);
235+
THEN("Second pair is (2, bar)")
236+
{
237+
const std::pair<int, std::string> second_pair = *range.begin();
238+
REQUIRE(second_pair.first == 27);
239+
REQUIRE(second_pair.second == "far");
240+
}
241+
range = std::move(range).drop(1);
242+
THEN("Range is empty")
243+
{
244+
REQUIRE(range.empty());
245+
}
246+
}
247+
}
220248
}
221249

222250
class move_onlyt

0 commit comments

Comments
 (0)