Compadre  1.5.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Compadre_UnitTests.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Compadre: COMpatible PArticle Discretization and REmap Toolkit
4 //
5 // Copyright 2018 NTESS and the Compadre contributors.
6 // SPDX-License-Identifier: BSD-2-Clause
7 // *****************************************************************************
8 // @HEADER
9 #include <gtest/gtest.h>
11 #include "unittests/test_XYZ.hpp"
12 #include "unittests/test_NeighborLists.hpp"
13 #include "unittests/test_PointCloudSearch.hpp"
14 #include "unittests/test_LinearAlgebra.hpp"
15 #include "unittests/test_Targets.hpp"
16 #ifdef COMPADRE_USE_MPI
17 #include <mpi.h>
18 #endif
19 
20 #define ASSERT_NO_DEATH(statement) \
21 ASSERT_EXIT({{ statement } ::exit(EXIT_SUCCESS); }, ::testing::ExitedWithCode(0), "")
22 
23 //
24 // KokkosParser tests go here because they modify the Kokkos backend
25 //
26 TEST (KokkosInitialize, NoArgsGiven) {
28  // default constructor is hidden for KokkosParser
29  // but still visible from this test
30  auto kp = Compadre::KokkosParser(false);
31  });
32 }
33 TEST (KokkosInitialize, NoCommandLineArgsGiven) {
34  std::vector<std::string> arguments = {KOKKOS_THREADS_ARG+std::string("=4")};
36  auto kp = KokkosParser(arguments);
37  });
38 }
39 
40 
41 // this provides main(),
42 // but all other tests come from ./unittests/*.cpp
43 int main(int argc, char **argv) {
44 
45  // initializes MPI (if available) with command line arguments given
46  #ifdef COMPADRE_USE_MPI
47  MPI_Init(&argc, &argv);
48  #endif
49 
50  ::testing::InitGoogleTest(&argc, argv);
51  ::testing::GTEST_FLAG(filter) = "Kokkos*";
52  int sig = RUN_ALL_TESTS();
53 
54  // initializes kokkos
55  Kokkos::initialize(argc, argv);
56 
57  // execute all tests
58  ::testing::GTEST_FLAG(filter) = "-Kokkos*";
59  sig += RUN_ALL_TESTS();
60 
61  // finalize Kokkos and MPI (if available)
62  Kokkos::finalize();
63 
64  // finialize MPI (if available)
65  #ifdef COMPADRE_USE_MPI
66  MPI_Finalize();
67  #endif
68  return sig;
69 }
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[]