Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
69e2aa89
There was an error fetching the commit references. Please try again later.
Commit
69e2aa89
authored
8 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for EllpackIndexMultimap
parent
5fd17c63
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnitTests/Meshes/CMakeLists.txt
+6
-0
6 additions, 0 deletions
src/UnitTests/Meshes/CMakeLists.txt
src/UnitTests/Meshes/MultimapTest.cpp
+76
-0
76 additions, 0 deletions
src/UnitTests/Meshes/MultimapTest.cpp
with
82 additions
and
0 deletions
src/UnitTests/Meshes/CMakeLists.txt
+
6
−
0
View file @
69e2aa89
...
...
@@ -8,6 +8,12 @@ SET_TARGET_PROPERTIES( MeshEntityTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLA
TARGET_LINK_LIBRARIES
(
MeshEntityTest
${
mpiExt
}${
debugExt
}
${
GTEST_BOTH_LIBRARIES
}
tnl
${
mpiExt
}${
debugExt
}
-
${
tnlVersion
}
)
ADD_EXECUTABLE
(
MultimapTest
${
mpiExt
}${
debugExt
}
${
headers
}
MultimapTest.cpp
)
SET_TARGET_PROPERTIES
(
MultimapTest
${
mpiExt
}${
debugExt
}
PROPERTIES COMPILE_FLAGS
"
${
CXX_TESTS_FLAGS
}
"
)
TARGET_LINK_LIBRARIES
(
MultimapTest
${
mpiExt
}${
debugExt
}
${
GTEST_BOTH_LIBRARIES
}
tnl
${
mpiExt
}${
debugExt
}
-
${
tnlVersion
}
)
ADD_TEST
(
MeshTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MeshTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
MeshEntityTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MeshEntityTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
MultimapTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MultimapTest
${
mpiExt
}${
debugExt
}
)
This diff is collapsed.
Click to expand it.
src/UnitTests/Meshes/MultimapTest.cpp
0 → 100644
+
76
−
0
View file @
69e2aa89
#include
<TNL/Experimental/Multimaps/EllpackIndexMultimap.h>
using
namespace
TNL
;
using
IndexType
=
int
;
using
Device
=
Devices
::
Host
;
using
LocalIndexType
=
short
;
#ifdef HAVE_GTEST
#include
"gtest/gtest.h"
TEST
(
MultimapTest
,
TestTypedefs
)
{
using
MultimapType
=
TNL
::
EllpackIndexMultimap
<
IndexType
,
Device
,
LocalIndexType
>
;
const
bool
same_index
=
std
::
is_same
<
typename
MultimapType
::
IndexType
,
IndexType
>::
value
;
ASSERT_TRUE
(
same_index
);
const
bool
same_device
=
std
::
is_same
<
typename
MultimapType
::
DeviceType
,
Device
>::
value
;
ASSERT_TRUE
(
same_device
);
const
bool
same_localindex
=
std
::
is_same
<
typename
MultimapType
::
LocalIndexType
,
LocalIndexType
>::
value
;
ASSERT_TRUE
(
same_localindex
);
}
TEST
(
MultimapTest
,
TestSettingValues
)
{
using
MultimapType
=
TNL
::
EllpackIndexMultimap
<
IndexType
,
Device
,
LocalIndexType
>
;
IndexType
inputs
=
10
;
LocalIndexType
values
=
4
;
LocalIndexType
allocatedValues
=
2
;
MultimapType
map
;
map
.
setRanges
(
inputs
,
values
);
ASSERT_EQ
(
map
.
getKeysRange
(),
inputs
);
ASSERT_EQ
(
map
.
getValuesRange
(),
values
);
typename
MultimapType
::
ValuesAllocationVectorType
allocationRanges
;
ASSERT_TRUE
(
allocationRanges
.
setSize
(
inputs
)
);
allocationRanges
.
setValue
(
allocatedValues
);
ASSERT_TRUE
(
map
.
allocate
(
allocationRanges
)
);
for
(
IndexType
i
=
0
;
i
<
inputs
;
i
++
)
{
auto
values
=
map
.
getValues
(
i
);
const
auto
constValues
=
(
(
const
MultimapType
)
map
).
getValues
(
i
);
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
values
.
setOutput
(
o
,
i
+
o
);
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
{
ASSERT_EQ
(
values
.
getOutput
(
o
),
i
+
o
);
ASSERT_EQ
(
values
[
o
],
i
+
o
);
ASSERT_EQ
(
constValues
.
getOutput
(
o
),
i
+
o
);
ASSERT_EQ
(
constValues
[
o
],
i
+
o
);
}
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
values
[
o
]
=
i
*
o
;
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
{
ASSERT_EQ
(
values
.
getOutput
(
o
),
i
*
o
);
ASSERT_EQ
(
values
[
o
],
i
*
o
);
ASSERT_EQ
(
constValues
.
getOutput
(
o
),
i
*
o
);
ASSERT_EQ
(
constValues
[
o
],
i
*
o
);
}
}
}
#endif
int
main
(
int
argc
,
char
*
argv
[]
)
{
#ifdef HAVE_GTEST
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
#else
return
EXIT_FAILURE
;
#endif
}
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