Compadre
1.5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
Compadre_UnitTests.cpp
Go to the documentation of this file.
1
#include <gtest/gtest.h>
2
#include <
Compadre_KokkosParser.hpp
>
3
#include "unittests/test_XYZ.hpp"
4
#include "unittests/test_NeighborLists.hpp"
5
#include "unittests/test_PointCloudSearch.hpp"
6
#include "unittests/test_LinearAlgebra.hpp"
7
#include "unittests/test_Targets.hpp"
8
#ifdef COMPADRE_USE_MPI
9
#include <mpi.h>
10
#endif
11
12
#define ASSERT_NO_DEATH(statement) \
13
ASSERT_EXIT({{ statement } ::exit(EXIT_SUCCESS); }, ::testing::ExitedWithCode(0), "")
14
15
//
16
// KokkosParser tests go here because they modify the Kokkos backend
17
//
18
TEST
(KokkosInitialize, NoArgsGiven) {
19
ASSERT_NO_DEATH
({
20
// default constructor is hidden for KokkosParser
21
// but still visible from this test
22
auto
kp =
Compadre::KokkosParser
(
false
);
23
});
24
}
25
TEST
(KokkosInitialize, NoCommandLineArgsGiven) {
26
std::vector<std::string> arguments = {
KOKKOS_THREADS_ARG
+std::string(
"=4"
)};
27
ASSERT_NO_DEATH
({
28
auto
kp = KokkosParser(arguments);
29
});
30
}
31
32
33
// this provides main(),
34
// but all other tests come from ./unittests/*.cpp
35
int
main
(
int
argc,
char
**argv) {
36
37
// initializes MPI (if available) with command line arguments given
38
#ifdef COMPADRE_USE_MPI
39
MPI_Init(&argc, &argv);
40
#endif
41
42
::testing::InitGoogleTest(&argc, argv);
43
::testing::GTEST_FLAG(filter) =
"Kokkos*"
;
44
int
sig = RUN_ALL_TESTS();
45
46
// initializes kokkos
47
Kokkos::initialize(argc, argv);
48
49
// execute all tests
50
::testing::GTEST_FLAG(filter) =
"-Kokkos*"
;
51
sig += RUN_ALL_TESTS();
52
53
// finalize Kokkos and MPI (if available)
54
Kokkos::finalize();
55
56
// finialize MPI (if available)
57
#ifdef COMPADRE_USE_MPI
58
MPI_Finalize();
59
#endif
60
return
sig;
61
}
Compadre_KokkosParser.hpp
KOKKOS_THREADS_ARG
constexpr char KOKKOS_THREADS_ARG[]
Definition
Compadre_Typedefs.hpp:123
main
int main(int argc, char **argv)
Definition
Compadre_UnitTests.cpp:35
ASSERT_NO_DEATH
#define ASSERT_NO_DEATH(statement)
Definition
Compadre_UnitTests.cpp:12
TEST
TEST(KokkosInitialize, NoArgsGiven)
Definition
Compadre_UnitTests.cpp:18
Compadre::KokkosParser
Class handling Kokkos command line arguments and returning parameters.
Definition
Compadre_KokkosParser.hpp:13
Generated by
1.17.0