diff --git a/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_1D_test.h b/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_1D_test.h index a7609ee7476931a0afed13711532bf162d0984ae..7377cbff2450debc69d05cc3e1fa69b7b20ba8e8 100644 --- a/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_1D_test.h +++ b/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_1D_test.h @@ -308,62 +308,4 @@ TYPED_TEST( DistributedNDArrayOverlaps_1D_test, synchronize ) #endif // HAVE_GTEST -#if (defined(HAVE_GTEST) && defined(HAVE_MPI)) -using CommunicatorType = Communicators::MpiCommunicator; - -#include <sstream> - -class MinimalistBufferedPrinter -: public ::testing::EmptyTestEventListener -{ -private: - std::stringstream sout; - -public: - // Called before a test starts. - virtual void OnTestStart(const ::testing::TestInfo& test_info) - { - sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl; - } - - // Called after a failed assertion or a SUCCEED() invocation. - virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result) - { - sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") - << test_part_result.file_name() << " " - << test_part_result.line_number() <<std::endl - << test_part_result.summary() <<std::endl; - } - - // Called after a test ends. - virtual void OnTestEnd(const ::testing::TestInfo& test_info) - { - const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup); - sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl; - std::cout << rank << ":" << std::endl << sout.str()<< std::endl; - sout.str( std::string() ); - sout.clear(); - } -}; -#endif - -#include "../../GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - - #ifdef HAVE_MPI - ::testing::TestEventListeners& listeners = - ::testing::UnitTest::GetInstance()->listeners(); - - delete listeners.Release(listeners.default_result_printer()); - listeners.Append(new MinimalistBufferedPrinter); - - Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv); - #endif - return RUN_ALL_TESTS(); -#else - throw GtestMissingError(); -#endif -} +#include "../../main_mpi.h" diff --git a/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_semi1D_test.h b/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_semi1D_test.h index a7f28ead5de63420e97730592948a1cfc2622b11..f1ac970eb2d26f268cc5bd294b05ffd5dcb78551 100644 --- a/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_semi1D_test.h +++ b/src/UnitTests/Containers/ndarray/DistributedNDArrayOverlaps_semi1D_test.h @@ -348,62 +348,4 @@ void test_helper_synchronize( DistributedArray& a, const int rank, const int npr #endif // HAVE_GTEST -#if (defined(HAVE_GTEST) && defined(HAVE_MPI)) -using CommunicatorType = Communicators::MpiCommunicator; - -#include <sstream> - -class MinimalistBufferedPrinter -: public ::testing::EmptyTestEventListener -{ -private: - std::stringstream sout; - -public: - // Called before a test starts. - virtual void OnTestStart(const ::testing::TestInfo& test_info) - { - sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl; - } - - // Called after a failed assertion or a SUCCEED() invocation. - virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result) - { - sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") - << test_part_result.file_name() << " " - << test_part_result.line_number() <<std::endl - << test_part_result.summary() <<std::endl; - } - - // Called after a test ends. - virtual void OnTestEnd(const ::testing::TestInfo& test_info) - { - const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup); - sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl; - std::cout << rank << ":" << std::endl << sout.str()<< std::endl; - sout.str( std::string() ); - sout.clear(); - } -}; -#endif - -#include "../../GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - - #ifdef HAVE_MPI - ::testing::TestEventListeners& listeners = - ::testing::UnitTest::GetInstance()->listeners(); - - delete listeners.Release(listeners.default_result_printer()); - listeners.Append(new MinimalistBufferedPrinter); - - Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv); - #endif - return RUN_ALL_TESTS(); -#else - throw GtestMissingError(); -#endif -} +#include "../../main_mpi.h" diff --git a/src/UnitTests/Containers/ndarray/DistributedNDArray_1D_test.h b/src/UnitTests/Containers/ndarray/DistributedNDArray_1D_test.h index 04afb91a4073750ba5583465b85eeda2239f0628..a8d3bcdab1cf911cf5386d050e0cc29636340a86 100644 --- a/src/UnitTests/Containers/ndarray/DistributedNDArray_1D_test.h +++ b/src/UnitTests/Containers/ndarray/DistributedNDArray_1D_test.h @@ -495,62 +495,4 @@ TYPED_TEST( DistributedNDArray_1D_test, forOverlaps ) #endif // HAVE_GTEST -#if (defined(HAVE_GTEST) && defined(HAVE_MPI)) -using CommunicatorType = Communicators::MpiCommunicator; - -#include <sstream> - -class MinimalistBufferedPrinter -: public ::testing::EmptyTestEventListener -{ -private: - std::stringstream sout; - -public: - // Called before a test starts. - virtual void OnTestStart(const ::testing::TestInfo& test_info) - { - sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl; - } - - // Called after a failed assertion or a SUCCEED() invocation. - virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result) - { - sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") - << test_part_result.file_name() << " " - << test_part_result.line_number() <<std::endl - << test_part_result.summary() <<std::endl; - } - - // Called after a test ends. - virtual void OnTestEnd(const ::testing::TestInfo& test_info) - { - const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup); - sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl; - std::cout << rank << ":" << std::endl << sout.str()<< std::endl; - sout.str( std::string() ); - sout.clear(); - } -}; -#endif - -#include "../../GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - - #ifdef HAVE_MPI - ::testing::TestEventListeners& listeners = - ::testing::UnitTest::GetInstance()->listeners(); - - delete listeners.Release(listeners.default_result_printer()); - listeners.Append(new MinimalistBufferedPrinter); - - Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv); - #endif - return RUN_ALL_TESTS(); -#else - throw GtestMissingError(); -#endif -} +#include "../../main_mpi.h" diff --git a/src/UnitTests/Containers/ndarray/DistributedNDArray_semi1D_test.h b/src/UnitTests/Containers/ndarray/DistributedNDArray_semi1D_test.h index 17108509d037be69b78ce7a13bc54edbf37731b3..6f777c215aab824f8d7a2c2916bd459845194e55 100644 --- a/src/UnitTests/Containers/ndarray/DistributedNDArray_semi1D_test.h +++ b/src/UnitTests/Containers/ndarray/DistributedNDArray_semi1D_test.h @@ -480,62 +480,4 @@ TYPED_TEST( DistributedNDArray_semi1D_test, forOverlaps ) #endif // HAVE_GTEST -#if (defined(HAVE_GTEST) && defined(HAVE_MPI)) -using CommunicatorType = Communicators::MpiCommunicator; - -#include <sstream> - -class MinimalistBufferedPrinter -: public ::testing::EmptyTestEventListener -{ -private: - std::stringstream sout; - -public: - // Called before a test starts. - virtual void OnTestStart(const ::testing::TestInfo& test_info) - { - sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl; - } - - // Called after a failed assertion or a SUCCEED() invocation. - virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result) - { - sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") - << test_part_result.file_name() << " " - << test_part_result.line_number() <<std::endl - << test_part_result.summary() <<std::endl; - } - - // Called after a test ends. - virtual void OnTestEnd(const ::testing::TestInfo& test_info) - { - const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup); - sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl; - std::cout << rank << ":" << std::endl << sout.str()<< std::endl; - sout.str( std::string() ); - sout.clear(); - } -}; -#endif - -#include "../../GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - - #ifdef HAVE_MPI - ::testing::TestEventListeners& listeners = - ::testing::UnitTest::GetInstance()->listeners(); - - delete listeners.Release(listeners.default_result_printer()); - listeners.Append(new MinimalistBufferedPrinter); - - Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv); - #endif - return RUN_ALL_TESTS(); -#else - throw GtestMissingError(); -#endif -} +#include "../../main_mpi.h" diff --git a/src/UnitTests/Containers/ndarray/NDArrayTest.h b/src/UnitTests/Containers/ndarray/NDArrayTest.h index 1e5d9a30cedf4c25b4e56d1c3a44511588848d86..3d2c85888768924f85d4220b569f969a917b76cd 100644 --- a/src/UnitTests/Containers/ndarray/NDArrayTest.h +++ b/src/UnitTests/Containers/ndarray/NDArrayTest.h @@ -1,3 +1,4 @@ +#ifdef HAVE_GTEST #include "gtest/gtest.h" #include <TNL/Containers/NDArray.h> @@ -1325,14 +1326,7 @@ TEST( NDArrayTest, forBoundary_static_6D ) << "i = " << i << ", j = " << j << ", k = " << k << ", l = " << l << ", m = " << m << ", n = " << n; } } +#endif // HAVE_GTEST -//#include "GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -//#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - return RUN_ALL_TESTS(); -//#else -// throw GtestMissingError(); -//#endif -} + +#include "../../main.h" diff --git a/src/UnitTests/Containers/ndarray/NDSubarrayTest.cpp b/src/UnitTests/Containers/ndarray/NDSubarrayTest.cpp index 1b57eed281183f4163501fabdc9027254e255eb9..f4f44003f82ca3597d41ff7dca8010a2c8192430 100644 --- a/src/UnitTests/Containers/ndarray/NDSubarrayTest.cpp +++ b/src/UnitTests/Containers/ndarray/NDSubarrayTest.cpp @@ -1,3 +1,4 @@ +#ifdef HAVE_GTEST #include "gtest/gtest.h" #include <TNL/Containers/NDArray.h> @@ -392,14 +393,7 @@ TEST( NDArraySubarrayTest, Dynamic_6D ) } a.setValue( 0 ); } +#endif // HAVE_GTEST -//#include "GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -//#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - return RUN_ALL_TESTS(); -//#else -// throw GtestMissingError(); -//#endif -} + +#include "../../main.h" diff --git a/src/UnitTests/Containers/ndarray/SlicedNDArrayTest.cpp b/src/UnitTests/Containers/ndarray/SlicedNDArrayTest.cpp index 8574a56021c6da57331dc63bb7747aa1ba262cb1..eda47a615f9390c75d81b59a817076d69ae9c606 100644 --- a/src/UnitTests/Containers/ndarray/SlicedNDArrayTest.cpp +++ b/src/UnitTests/Containers/ndarray/SlicedNDArrayTest.cpp @@ -1,3 +1,4 @@ +#ifdef HAVE_GTEST #include "gtest/gtest.h" #include <TNL/Containers/NDArray.h> @@ -238,14 +239,7 @@ TEST( SlicedNDArrayTest, CopySemantics ) EXPECT_EQ( a.getConstView(), c.getConstView() ); EXPECT_EQ( a.getConstView(), c_view.getConstView() ); } +#endif // HAVE_GTEST -//#include "GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -//#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - return RUN_ALL_TESTS(); -//#else -// throw GtestMissingError(); -//#endif -} + +#include "../../main.h" diff --git a/src/UnitTests/Containers/ndarray/StaticNDArrayCudaTest.cu b/src/UnitTests/Containers/ndarray/StaticNDArrayCudaTest.cu index 5a0561955f85cce3fac6798cd480466e495cc181..f2c83ba1640fb47e5f0c5777134394215b0ccd8b 100644 --- a/src/UnitTests/Containers/ndarray/StaticNDArrayCudaTest.cu +++ b/src/UnitTests/Containers/ndarray/StaticNDArrayCudaTest.cu @@ -1,3 +1,4 @@ +#ifdef HAVE_GTEST #include "gtest/gtest.h" #include <TNL/Containers/NDArray.h> @@ -76,14 +77,7 @@ TEST( StaticNDArrayCudaTest, CopyFromArray ) { __test_CopyFromArray(); } +#endif // HAVE_GTEST -//#include "GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -//#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - return RUN_ALL_TESTS(); -//#else -// throw GtestMissingError(); -//#endif -} + +#include "../../main.h" diff --git a/src/UnitTests/Containers/ndarray/StaticNDArrayTest.cpp b/src/UnitTests/Containers/ndarray/StaticNDArrayTest.cpp index e3ea290f26b92723d0490873f7caa263fee35f36..23ffd8066ef41dfe7ae3107bc56388a65a262687 100644 --- a/src/UnitTests/Containers/ndarray/StaticNDArrayTest.cpp +++ b/src/UnitTests/Containers/ndarray/StaticNDArrayTest.cpp @@ -1,3 +1,4 @@ +#ifdef HAVE_GTEST #include "gtest/gtest.h" #include <TNL/Containers/NDArray.h> @@ -92,14 +93,7 @@ TEST( StaticNDArrayTest, CopySemantics ) EXPECT_EQ( a.getConstView(), c.getConstView() ); EXPECT_EQ( a.getConstView(), c_view.getConstView() ); } +#endif // HAVE_GTEST -//#include "GtestMissingError.h" -int main( int argc, char* argv[] ) -{ -//#ifdef HAVE_GTEST - ::testing::InitGoogleTest( &argc, argv ); - return RUN_ALL_TESTS(); -//#else -// throw GtestMissingError(); -//#endif -} + +#include "../../main.h"