Compadre  1.5.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Compadre_UnitTests.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
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) {
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")};
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 }
Class handling Kokkos command line arguments and returning parameters.
int main(int argc, char **argv)
#define ASSERT_NO_DEATH(statement)
TEST(KokkosInitialize, NoArgsGiven)
constexpr char KOKKOS_THREADS_ARG[]