Skip to content
Snippets Groups Projects
Commit e131b736 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add std::list conversion

parent 4a707322
Branches
Tags
1 merge request!11Feature/mpi
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include <list>
// Instantiate to ensure full coverage is performed // Instantiate to ensure full coverage is performed
template class Array<int>; template class Array<int>;
...@@ -162,6 +163,7 @@ TEST_CASE("Array", "[utils]") { ...@@ -162,6 +163,7 @@ TEST_CASE("Array", "[utils]") {
(v_array[2] == 5) and (v_array[3] == 3))); (v_array[2] == 5) and (v_array[3] == 3)));
} }
} }
{ {
std::vector<int> w; std::vector<int> w;
{ {
...@@ -175,7 +177,7 @@ TEST_CASE("Array", "[utils]") { ...@@ -175,7 +177,7 @@ TEST_CASE("Array", "[utils]") {
} }
{ {
std::set<int> s{4,2,5,3,1}; std::set<int> s{4,2,5,3,1,3,2};
Array<int> s_array = convert_to_array(s); Array<int> s_array = convert_to_array(s);
REQUIRE(s_array.size() == s.size()); REQUIRE(s_array.size() == s.size());
...@@ -183,6 +185,27 @@ TEST_CASE("Array", "[utils]") { ...@@ -183,6 +185,27 @@ TEST_CASE("Array", "[utils]") {
(s_array[2] == 3) and (s_array[3] == 4) and (s_array[2] == 3) and (s_array[3] == 4) and
(s_array[4] == 5))); (s_array[4] == 5)));
} }
{
std::multiset<int> ms{4,2,5,3,1,3,2};
Array<int> ms_array = convert_to_array(ms);
REQUIRE(ms_array.size() == ms.size());
REQUIRE(((ms_array[0] == 1) and (ms_array[1] == 2) and
(ms_array[2] == 2) and (ms_array[3] == 3) and
(ms_array[4] == 3) and (ms_array[5] == 4) and
(ms_array[6] == 5)));
}
{
std::list<int> l{1,3,5,6,2};
Array<int> l_array = convert_to_array(l);
REQUIRE(l_array.size() == l.size());
REQUIRE(((l_array[0] == 1) and (l_array[1] == 3) and
(l_array[2] == 5) and (l_array[3] == 6) and
(l_array[4] == 2)));
}
} }
#ifndef NDEBUG #ifndef NDEBUG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment