Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
4d3c7301
Commit
4d3c7301
authored
Oct 8, 2018
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add test for conversion of deque, valarray and unordered_set
parent
74b93636
No related branches found
No related tags found
1 merge request
!11
Feature/mpi
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils/Array.hpp
+1
-0
1 addition, 0 deletions
src/utils/Array.hpp
tests/test_Array.cpp
+37
-0
37 additions, 0 deletions
tests/test_Array.cpp
with
38 additions
and
0 deletions
src/utils/Array.hpp
+
1
−
0
View file @
4d3c7301
...
@@ -106,6 +106,7 @@ class Array
...
@@ -106,6 +106,7 @@ class Array
~
Array
()
=
default
;
~
Array
()
=
default
;
};
};
// map, multimap, unordered_map and stack cannot be copied this way
template
<
typename
Container
>
template
<
typename
Container
>
PASTIS_INLINE
PASTIS_INLINE
Array
<
std
::
remove_const_t
<
typename
Container
::
value_type
>>
Array
<
std
::
remove_const_t
<
typename
Container
::
value_type
>>
...
...
This diff is collapsed.
Click to expand it.
tests/test_Array.cpp
+
37
−
0
View file @
4d3c7301
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
#include
<vector>
#include
<vector>
#include
<set>
#include
<set>
#include
<list>
#include
<list>
#include
<deque>
#include
<valarray>
#include
<unordered_set>
// Instantiate to ensure full coverage is performed
// Instantiate to ensure full coverage is performed
template
class
Array
<
int
>;
template
class
Array
<
int
>;
...
@@ -176,6 +179,15 @@ TEST_CASE("Array", "[utils]") {
...
@@ -176,6 +179,15 @@ TEST_CASE("Array", "[utils]") {
}
}
}
}
{
std
::
valarray
<
int
>
v
{
1
,
2
,
5
,
3
};
Array
<
int
>
v_array
=
convert_to_array
(
v
);
REQUIRE
(
v_array
.
size
()
==
v
.
size
());
REQUIRE
(((
v_array
[
0
]
==
1
)
and
(
v_array
[
1
]
==
2
)
and
(
v_array
[
2
]
==
5
)
and
(
v_array
[
3
]
==
3
)));
}
{
{
std
::
set
<
int
>
s
{
4
,
2
,
5
,
3
,
1
,
3
,
2
};
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
);
...
@@ -186,6 +198,20 @@ TEST_CASE("Array", "[utils]") {
...
@@ -186,6 +198,20 @@ TEST_CASE("Array", "[utils]") {
(
s_array
[
4
]
==
5
)));
(
s_array
[
4
]
==
5
)));
}
}
{
std
::
unordered_set
<
int
>
us
{
4
,
2
,
5
,
3
,
1
,
3
,
2
};
Array
<
int
>
us_array
=
convert_to_array
(
us
);
REQUIRE
(
us_array
.
size
()
==
us
.
size
());
std
::
set
<
int
>
s
;
for
(
size_t
i
=
0
;
i
<
us_array
.
size
();
++
i
)
{
REQUIRE
((
us
.
find
(
us_array
[
i
])
!=
us
.
end
()));
s
.
insert
(
us_array
[
i
]);
}
REQUIRE
(
s
.
size
()
==
us_array
.
size
());
}
{
{
std
::
multiset
<
int
>
ms
{
4
,
2
,
5
,
3
,
1
,
3
,
2
};
std
::
multiset
<
int
>
ms
{
4
,
2
,
5
,
3
,
1
,
3
,
2
};
Array
<
int
>
ms_array
=
convert_to_array
(
ms
);
Array
<
int
>
ms_array
=
convert_to_array
(
ms
);
...
@@ -206,6 +232,17 @@ TEST_CASE("Array", "[utils]") {
...
@@ -206,6 +232,17 @@ TEST_CASE("Array", "[utils]") {
(
l_array
[
2
]
==
5
)
and
(
l_array
[
3
]
==
6
)
and
(
l_array
[
2
]
==
5
)
and
(
l_array
[
3
]
==
6
)
and
(
l_array
[
4
]
==
2
)));
(
l_array
[
4
]
==
2
)));
}
}
{
std
::
deque
<
int
>
q
{
1
,
3
,
5
,
6
,
2
};
q
.
push_front
(
2
);
Array
<
int
>
q_array
=
convert_to_array
(
q
);
REQUIRE
(
q_array
.
size
()
==
q
.
size
());
REQUIRE
(((
q_array
[
0
]
==
2
)
and
(
q_array
[
1
]
==
1
)
and
(
q_array
[
2
]
==
3
)
and
(
q_array
[
3
]
==
5
)
and
(
q_array
[
4
]
==
6
)
and
(
q_array
[
5
]
==
2
)));
}
}
}
#ifndef NDEBUG
#ifndef NDEBUG
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment