Enable clang tidy/warnings for tests
authorRoland Schulz <roland.schulz@intel.com>
Wed, 18 Jul 2018 01:39:01 +0000 (18:39 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 18 Aug 2018 00:07:38 +0000 (02:07 +0200)
Also move check configuration into .clang-tidy file to allow
running clang-tidy seperately from the build to apply automatic
fixes.

Also relaxes some scalar tests. Commit b9057925955f changed contants
and relaxed SIMD tests without also relaxing scalar tests.

Change-Id: Ia895e219502b665db7ca0effaa03af3d3d380256

82 files changed:
docs/dev-manual/tools.rst
src/.clang-tidy
src/CMakeLists.txt
src/external/.clang-tidy [new file with mode: 0644]
src/external/googletest/googlemock/include/gmock/gmock-spec-builders.h
src/gromacs/CMakeLists.txt
src/gromacs/analysisdata/tests/datatest.h
src/gromacs/awh/tests/bias.cpp
src/gromacs/awh/tests/biasstate.cpp
src/gromacs/awh/tests/grid.cpp
src/gromacs/commandline/tests/cmdlinehelpmodule.cpp
src/gromacs/commandline/tests/cmdlineprogramcontext.cpp
src/gromacs/compat/tests/make_unique.cpp
src/gromacs/correlationfunctions/tests/autocorr.cpp
src/gromacs/correlationfunctions/tests/expfit.cpp
src/gromacs/ewald/tests/pmebsplinetest.cpp
src/gromacs/ewald/tests/pmegathertest.cpp
src/gromacs/ewald/tests/pmesolvetest.cpp
src/gromacs/ewald/tests/pmesplinespreadtest.cpp
src/gromacs/ewald/tests/pmetestcommon.cpp
src/gromacs/ewald/tests/testhardwarecontexts.cpp
src/gromacs/fileio/tests/readinp.cpp
src/gromacs/fileio/tests/tngio.cpp
src/gromacs/gmxpreprocess/tests/genconf.cpp
src/gromacs/gmxpreprocess/tests/readir.cpp
src/gromacs/gmxpreprocess/tests/solvate.cpp
src/gromacs/linearalgebra/.clang-tidy [new file with mode: 0644]
src/gromacs/math/tests/functions.cpp
src/gromacs/math/tests/vectypes.cpp
src/gromacs/mdlib/nbnxn_kernels/.clang-tidy [deleted file]
src/gromacs/mdlib/tests/mdebin.cpp
src/gromacs/mdrunutility/tests/threadaffinitytest.cpp
src/gromacs/options/tests/treesupport.cpp
src/gromacs/random/tests/exponentialdistribution.cpp
src/gromacs/random/tests/gammadistribution.cpp
src/gromacs/random/tests/normaldistribution.cpp
src/gromacs/random/tests/tabulatednormaldistribution.cpp
src/gromacs/random/tests/threefry.cpp
src/gromacs/random/tests/uniformintdistribution.cpp
src/gromacs/random/tests/uniformrealdistribution.cpp
src/gromacs/selection/parser_internal.h
src/gromacs/selection/tests/nbsearch.cpp
src/gromacs/selection/tests/poscalc.cpp
src/gromacs/selection/tests/toputils.cpp
src/gromacs/simd/tests/CMakeLists.txt
src/gromacs/simd/tests/base.cpp
src/gromacs/simd/tests/base.h
src/gromacs/simd/tests/data.cpp [deleted file]
src/gromacs/simd/tests/data.h
src/gromacs/simd/tests/scalar.cpp
src/gromacs/simd/tests/simd.h
src/gromacs/simd/tests/simd4.h
src/gromacs/simd/tests/simd4_math.cpp
src/gromacs/simd/tests/simd_math.cpp
src/gromacs/tables/tests/splinetable.cpp
src/gromacs/trajectoryanalysis/tests/surfacearea.cpp
src/gromacs/utility/bitmask.h
src/gromacs/utility/tests/alignedallocator-impl.h
src/gromacs/utility/tests/arrayref.cpp
src/gromacs/utility/tests/bitmask.h
src/gromacs/utility/tests/mutex.cpp
src/programs/mdrun/mdrun.cpp
src/programs/mdrun/tests/energyreader.cpp
src/programs/mdrun/tests/initialconstraints.cpp
src/programs/mdrun/tests/moduletest.cpp
src/programs/mdrun/tests/multisimtest.cpp
src/programs/mdrun/tests/rerun.cpp
src/programs/mdrun/tests/tabulated_bonded_interactions.cpp
src/programs/mdrun/tests/tpitest.cpp
src/testutils/TestMacros.cmake
src/testutils/cmdlinetest.cpp
src/testutils/cmdlinetest.h
src/testutils/conftest.cpp
src/testutils/interactivetest.cpp
src/testutils/refdata-checkers.h
src/testutils/refdata-impl.h
src/testutils/refdata.cpp
src/testutils/refdata.h
src/testutils/testasserts.cpp
src/testutils/testasserts.h
src/testutils/testinit.cpp
src/testutils/testoptions.h

index 404898d23a564c6ef937e2756066ec2570c3c30f..9da071e6e5a2e68f9f0a7ceb6dc80b73c7baad21 100644 (file)
@@ -82,18 +82,24 @@ unit testing (CTest)
 regression tests
 
 clang-tidy
-  `clang-tidy <http://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`
+  `clang-tidy <http://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`_
   is used for static code analysis. clang-tidy is easy to install. It is contained in
-  the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`. Only
-  version 6.0 is supported. Others might miss tests or give false positives.
-  It is run automatically on Jenkins for each commit. To run it manually, configure
-  with ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug`` and then run make
-  normally (for ``CMAKE_BUILD_TYPE`` any type which enables asserts (e.g. ASAN) works).
-  The name of the clang-tidy executable that CMake should search for be set with
-  ``-DCLANG_TIDY=...`, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
-  Many checks have fixes which automatically get applied when building with clang-tidy
-  enabled, so you may want to run this tool locally to apply the fixes before
-  you upload to Gerrit.
+  the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`_. Only
+  version 6.0.* is supported. Others might miss tests or give false positives.
+  It is run automatically on Jenkins for each commit. Many checks have fixes which can automatically be
+  applied. To run it, the build has to be configured with
+  ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on``.
+  Any ``CMAKE_BUILD_TYPE`` which enables asserts (e.g. ASAN) works. Such a configured build will
+  run both the compiler as well as clang-tidy when building. The name of the clang-tidy executable is set with
+``-DCLANG_TIDY=...``, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
+  To apply the automatic fixes to the issue identified clang-tidy should be run sepereately (running clang-tidy
+  with ``-fix`` as part of the build can corrupt header files). To fix a specific file run
+  ``clang-tidy -fix -header-filter '.*' {file}``, to fix all files in parallel
+  ``run-clang-tidy.py -fix -header-filter '.*' '(?<!/selection/parser\.cpp|selection/scanner\.cpp)$'``,
+  and to fix all modified files ``run-clang-tidy.py -fix -header-filter '.*' $(git diff HEAD --name-only)``.
+  The run-clang-tidy.py script is in the
+  ``share/clang/`` subfolder of the llvm distribution. ``clang-tidy`` has to be able to find the
+  ``compile_commands.json`` file. Eithe run from the build folder or add a symlink to the source folder.
 
 clang static analyzer
 
index f70b77d1e3e089b9a88db4a00c3591a83abbfae2..75da6d7eca088425e19255a3a51c056ae83a1778 100644 (file)
@@ -1,4 +1,16 @@
+Checks:  clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.strcpy,
+         bugprone-*,misc-*,readability-*,performance-*,mpi-*,-misc-incorrect-roundings,
+         -readability-inconsistent-declaration-parameter-name,-readability-implicit-bool-conversion,
+         -readability-function-size,-readability-else-after-return,
+         modernize-use-nullptr,modernize-use-emplace,
+         modernize-make-unique,modernize-make-shared,
+         google-readability-casting,
+         cppcoreguidelines-*,-cppcoreguidelines-pro-*,-cppcoreguidelines-owning-memory,
+         -cppcoreguidelines-no-malloc,-cppcoreguidelines-special-member-functions
+
 CheckOptions:
+  - key:           cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+    value:         1
   - key:           modernize-make-unique.MakeSmartPtrFunction
     value:         gmx::compat::make_unique
   - key:           modernize-make-unique.MakeSmartPtrFunctionHeader
index dde7c7ae151f5db51f3017b253ec2f9a0c9f61af..d0c18815288006aaaa5feadab828970d8c2479c3 100644 (file)
@@ -50,6 +50,49 @@ configure_file(config.h.cmakein config.h)
 configure_file(gmxpre-config.h.cmakein gmxpre-config.h)
 configure_file(buildinfo.h.cmakein buildinfo.h ESCAPE_QUOTES)
 
+####
+set(IGNORED_CLANG_ALL_WARNINGS
+    "-Wno-c++98-compat -Wno-c++98-compat-pedantic" #No intention of C++98 compability
+    "-Wno-source-uses-openmp" #Don't warn for no-omp build
+    "-Wno-c++17-extensions"   #Allowed in attributes (compilers are required to ignore unknown attributes)
+    "-Wno-documentation-unknown-command" #Custom commands are used
+    "-Wno-covered-switch-default" #GCC gives maybe-uninitialized without default label and checks for illegal enum values.
+    "-Wno-switch-enum" # default statement for enum is OK
+
+    #Following ones are undecided/TODO
+    "-Wno-disabled-macro-expansion"
+    "-Wno-cast-align"
+    "-Wno-reserved-id-macro"
+    "-Wno-global-constructors"
+    "-Wno-exit-time-destructors"
+    "-Wno-unused-macros"
+    "-Wno-weak-vtables"
+    "-Wno-conditional-uninitialized"
+    "-Wno-format-nonliteral"
+    "-Wno-shadow"
+    "-Wno-cast-qual"
+    "-Wno-documentation"
+    "-Wno-used-but-marked-unused"
+    "-Wno-padded"
+    "-Wno-float-equal"
+    "-Wno-old-style-cast"
+    "-Wno-conversion"
+    "-Wno-double-promotion")
+string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
+
+if (GMX_CLANG_TIDY)
+   set(CLANG_TIDY "clang-tidy" CACHE STRING "Name of clang-tidy executable")
+   find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY}"
+       DOC "Path to clang-tidy executable")
+   if(NOT CLANG_TIDY_EXE)
+       message(FATAL_ERROR "clang-tidy not found.")
+   endif()
+   if(CMAKE_VERSION VERSION_LESS "3.6")
+       message(FATAL_ERROR "clang-tidy support requires cmake 3.6.")
+   endif()
+endif()
+#####
+
 if (BUILD_TESTING)
     if(NOT GMX_DEVELOPER_BUILD)
         set(UNITTEST_TARGET_OPTIONS EXCLUDE_FROM_ALL)
diff --git a/src/external/.clang-tidy b/src/external/.clang-tidy
new file mode 100644 (file)
index 0000000..de0482b
--- /dev/null
@@ -0,0 +1 @@
+Checks: -*
index fed7de66bc4ce21de9c74a74523dd30faa5bdffd..0985379c72991147b7ca4f9e904c0bfcaf4e98ff 100644 (file)
@@ -1269,7 +1269,7 @@ class MockSpec {
       const char* file, int line, const char* obj, const char* call) {
     const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
     LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
-    return function_mocker_->AddNewExpectation(
+    return function_mocker_->AddNewExpectation( // NOLINT
         file, line, source_text, matchers_);
   }
 
@@ -1469,7 +1469,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
     MutexLock l(&g_gmock_mutex);
     VerifyAndClearExpectationsLocked();
     Mock::UnregisterLocked(this);
-    ClearDefaultActionsLocked();
+    ClearDefaultActionsLocked(); // NOLINT
   }
 
   // Returns the ON_CALL spec that matches this mock function with the
index 9022e5c4b67ad5646b77f9ddc41d469c0d3b73c3..a1b441d44c8ac2a84c06e5a159eb7c8d7d9b94f5 100644 (file)
@@ -269,32 +269,6 @@ set_target_properties(libgromacs PROPERTIES
 gmx_manage_lmfit()
 target_link_libraries(libgromacs PRIVATE lmfit)
 
-set(IGNORED_CLANG_ALL_WARNINGS
-    "-Wno-c++98-compat -Wno-c++98-compat-pedantic" #No intention of C++98 compability
-    "-Wno-source-uses-openmp" #Don't warn for no-omp build
-    "-Wno-c++17-extensions"   #Allowed in attributes (compilers are required to ignore unknown attributes)
-    "-Wno-documentation-unknown-command" #Custom commands are used
-    "-Wno-covered-switch-default" #GCC gives maybe-uninitialized without default label and checks for illegal enum values.
-    "-Wno-switch-enum" # default statement for enum is OK
-
-    #Following ones are undecided/TODO
-    "-Wno-disabled-macro-expansion"
-    "-Wno-reserved-id-macro"
-    "-Wno-global-constructors"
-    "-Wno-exit-time-destructors"
-    "-Wno-unused-macros"
-    "-Wno-weak-vtables"
-    "-Wno-conditional-uninitialized"
-    "-Wno-format-nonliteral"
-    "-Wno-shadow"
-    "-Wno-cast-qual"
-    "-Wno-documentation"
-    "-Wno-used-but-marked-unused"
-    "-Wno-padded"
-    "-Wno-float-equal"
-    "-Wno-conversion"
-    "-Wno-double-promotion")
-string(REPLACE " " ";" IGNORED_CLANG_ALL_WARNINGS "${IGNORED_CLANG_ALL_WARNINGS}")
 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
    target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS}>)
 endif()
@@ -325,34 +299,10 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
      >
    )
 endif()
+
 if (GMX_CLANG_TIDY)
-   set(CLANG_TIDY "clang-tidy" CACHE STRING "Name of clang-tidy executable")
-   find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY}"
-       DOC "Path to clang-tidy executable")
-   if(NOT CLANG_TIDY_EXE)
-       message(FATAL_ERROR "clang-tidy not found.")
-   endif()
-   if(CMAKE_VERSION VERSION_LESS "3.6")
-       message(FATAL_ERROR "clang-tidy support requires cmake 3.6.")
-   endif()
-   set(CLANG_TIDY_CHECKS
-       "-clang-analyzer-security.insecureAPI.strcpy"
-       "bugprone-*" "misc-*" "readability-*" "performance-*" "mpi-*"
-       "-misc-incorrect-roundings" #TODO: #2562
-       "-readability-else-after-return"
-       "-readability-inconsistent-declaration-parameter-name"
-       "-readability-implicit-bool-conversion" #TODO: Remove gmx_bool
-       "modernize-use-nullptr" "modernize-use-emplace"
-       "modernize-make-unique" "modernize-make-shared"
-       "google-readability-casting"
-       "cppcoreguidelines-*" "-cppcoreguidelines-pro-*"
-       "-cppcoreguidelines-owning-memory"
-       "-cppcoreguidelines-no-malloc"
-       "-cppcoreguidelines-special-member-functions" #in conflict with Wunused-member-function
-       )
-   string(REPLACE ";" "," CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS}")
    set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY
-       "${CLANG_TIDY_EXE};--checks=${CLANG_TIDY_CHECKS};-warnings-as-errors=*;-header-filter=.*")
+       "${CLANG_TIDY_EXE};-warnings-as-errors=*;-header-filter=.*")
 endif()
 
 gmx_write_installed_header_list()
index 2117124b884201ab3756bedeed3c9b4577f70883..8111d1e481205a13b0e35363e138fe0e2885cb8f 100644 (file)
@@ -454,7 +454,7 @@ class AnalysisDataTestFixture : public ::testing::Test
         void addReferenceCheckerModule(const char           *id,
                                        AbstractAnalysisData *source);
 
-    protected:
+    private:
         /*! \brief
          * Reference data object used for the reference checker modules.
          *
index 51fb32b0b84532120116f61f152ebb9a92deb232..86e28c0cf0974978d208314f75d42e6d9c08eb61 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "gromacs/awh/correlationgrid.h"
 #include "gromacs/awh/pointstate.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/mdtypes/awh-params.h"
 #include "gromacs/utility/stringutil.h"
 
@@ -107,7 +108,7 @@ static AwhTestParameters getAwhTestParameters(int eawhgrowth,
     double                 k           = 1000;
     int64_t                seed        = 93471803;
 
-    params.dimParams.push_back(DimParams(convFactor, k, params.beta));
+    params.dimParams.emplace_back(convFactor, k, params.beta);
 
     AwhParams             &awhParams = params.awhParams;
 
@@ -202,7 +203,7 @@ class BiasTest : public ::testing::TestWithParam<BiasTestParameters>
             int    numSamples = coordinates_.size() - 1; // No sample taken at step 0
             GMX_RELEASE_ASSERT(numSamples % params.awhParams.numSamplesUpdateFreeEnergy == 0, "This test is intended to reproduce the situation when the might need to write output during a normal AWH run, therefore the number of samples should be a multiple of the free-energy update interval (but the test should also runs fine without this condition).");
 
-            bias_ = std::unique_ptr<Bias>(new Bias(-1, params.awhParams, params.awhBiasParams, params.dimParams, params.beta, mdTimeStep, 1, "", Bias::ThisRankWillDoIO::No, disableUpdateSkips));
+            bias_ = gmx::compat::make_unique<Bias>(-1, params.awhParams, params.awhBiasParams, params.dimParams, params.beta, mdTimeStep, 1, "", Bias::ThisRankWillDoIO::No, disableUpdateSkips);
         }
 };
 
@@ -211,7 +212,7 @@ TEST_P(BiasTest, ForcesBiasPmf)
     gmx::test::TestReferenceData     data;
     gmx::test::TestReferenceChecker  checker(data.rootChecker());
 
-    Bias                            &bias = *bias_.get();
+    Bias                            &bias = *bias_;
 
     /* Make strings with the properties we expect to be different in the tests.
      * These also helps to interpret the reference data.
index 68465bfc34346e3793e4f84c9084b4b1912c1ac4..1ba40d7c542d07268af6403bd47761d8689bbc16 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "gromacs/awh/grid.h"
 #include "gromacs/awh/pointstate.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/mdtypes/awh-params.h"
 #include "gromacs/utility/smalloc.h"
@@ -136,11 +137,11 @@ class BiasStateTest : public ::testing::TestWithParam<const char *>
             const AwhParams        &awhParams     = params.awhParams;
             const AwhBiasParams    &awhBiasParams = awhParams.awhBiasParams[0];
             std::vector<DimParams>  dimParams;
-            dimParams.push_back(DimParams(1.0, 15.0, params.beta));
-            dimParams.push_back(DimParams(1.0, 15.0, params.beta));
+            dimParams.emplace_back(1.0, 15.0, params.beta);
+            dimParams.emplace_back(1.0, 15.0, params.beta);
             Grid                    grid(dimParams, awhBiasParams.dimParams);
             BiasParams              biasParams(awhParams, awhBiasParams, dimParams, 1.0, 1.0, BiasParams::DisableUpdateSkips::no, 1, grid.axis(), 0);
-            biasState_ = std::unique_ptr<BiasState>(new BiasState(awhBiasParams, 1.0, dimParams, grid));
+            biasState_ = gmx::compat::make_unique<BiasState>(awhBiasParams, 1.0, dimParams, grid);
 
             // Here we initialize the grid point state using the input file
             std::string             filename = gmx::test::TestFileManager::getInputFilePath(GetParam());
index 8cc7a8729125c5c288b1dd8d8b2275e4c3b89f37..e1a883746c9d083a9eb369dae19d49b9011f2821 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -84,8 +84,8 @@ TEST(gridTest, neighborhood)
 
     /* Set up dimParams to get about 15 points along each dimension */
     std::vector<DimParams> dimParams;
-    dimParams.push_back(DimParams(conversionFactor, 1/(beta*0.7*0.7), beta));
-    dimParams.push_back(DimParams(conversionFactor, 1/(beta*0.1*0.1), beta));
+    dimParams.emplace_back(conversionFactor, 1/(beta*0.7*0.7), beta);
+    dimParams.emplace_back(conversionFactor, 1/(beta*0.1*0.1), beta);
 
     Grid       grid(dimParams, awhDimParams.data());
 
index a959670afe8d44e4c64aba2aeeb98e2099e7a7d5..15f036bc8d644e6b5d503a6790bdbb5efca3e2dd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -61,7 +61,6 @@ namespace
 
 using gmx::test::CommandLine;
 using gmx::test::MockHelpTopic;
-using gmx::test::MockModule;
 using gmx::test::MockOptionsModule;
 
 //! Test fixture for the tests.
index 0bb6864c6e82690b0ada468076355892e08c53a8..4cdf6d1f8bd39cf4bcef2230a997503d7f442385 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -57,7 +57,6 @@
 
 #include "testutils/cmdlinetest.h"
 
-using gmx::test::CommandLine;
 using gmx::Path;
 
 #if GMX_NATIVE_WINDOWS || GMX_CYGWIN
index a99dff748176d40c7c00ac6b455ba827faf04263..72cc32ca7e7007f20ffc212e0add64cadd455e38 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -57,11 +57,11 @@ struct dummy
     dummy() :
         foo {0},
     bar {0}
-    {};
+    {}
     dummy(const char a, const char b) :
         foo {a},
     bar {b}
-    {};
+    {}
 };
 
 TEST(CompatibilityHelper, MakeUniqueCompiles)
index 2d7053b4d9df635b8a300f9697562b73374aa10f..f5b5f2733a6e4d1c23898ee63e3c2e957c0c6fab 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -50,6 +50,7 @@
 
 #include <gtest/gtest.h>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/correlationfunctions/expfit.h"
 #include "gromacs/fft/fft.h"
 #include "gromacs/utility/gmxassert.h"
@@ -97,7 +98,7 @@ class AutocorrTest : public ::testing::Test
         {
             int         n        = 0;
             std::string fileName = "testCOS3.xvg";
-            data_                = CorrelationDataSetPointer(new CorrelationDataSet(fileName));
+            data_                = gmx::compat::make_unique<CorrelationDataSet>(fileName);
             nrFrames_            = data_->getNrLines();
             tempArgs_            = add_acf_pargs(&n, nullptr);
         }
index 5d5bd967df52f86794f1275f8360863d8d616f7c..4f365f0a35f224f5e49eb68fdcbd19c268c0cbd1 100644 (file)
@@ -63,7 +63,7 @@ namespace gmx
 
 namespace
 {
-
+#if HAVE_LMFIT
 class ExpfitData
 {
     public:
@@ -156,7 +156,6 @@ std::vector<ExpfitData> ExpfitTest::data_;
 
 // TODO calling test() leads to a fatal error, which we could in
 // principle test for.
-#if HAVE_LMFIT
 
 TEST_F (ExpfitTest, EffnEXP1) {
     double  param[] = {25};
index 14308bb5ebe568531cf1ca68c634848677a1434e..7549d1aa23c9753216cc5b215ed7c46f6b1822fc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -142,7 +142,7 @@ const int       sanePmeOrder = 4;
 //! Sane grid size
 const IVec      saneGridSize = {32, 25, 47};
 /*! \brief Hand-picked invalid input for the exception tests */
-static std::vector<BSplineModuliInputParameters> const invalidInputs
+std::vector<BSplineModuliInputParameters> const invalidInputs
 {
     /* Invalid grid sizes */
     BSplineModuliInputParameters {
@@ -175,7 +175,7 @@ INSTANTIATE_TEST_CASE_P(InsaneInput, PmeBSplineModuliFailureTest, ::testing::Val
 /* Valid input instances */
 
 //! A couple of valid inputs for grid sizes. It is good to test both even and odd dimensions.
-static std::vector<IVec> const sampleGridSizes
+std::vector<IVec> const sampleGridSizes
 {
     IVec {
         64, 32, 64
index 6d1286f79429badb3781c6324933137cf627e969..34219cb84569bb008002afff944053d06f232c2e 100644 (file)
@@ -64,7 +64,7 @@ namespace
 /* Valid input instances */
 
 //! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
 {
     // normal box
     Matrix3x3 {{
@@ -81,7 +81,7 @@ static std::vector<Matrix3x3> const c_sampleBoxes
 };
 
 //! A couple of valid inputs for grid sizes
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
 {
     IVec {
         16, 12, 14
@@ -91,13 +91,13 @@ static std::vector<IVec> const c_sampleGridSizes
     }
 };
 //! Random charges
-static std::vector<real> const c_sampleChargesFull
+std::vector<real> const c_sampleChargesFull
 {
     4.95f, 3.11f, 3.97f, 1.08f, 2.09f, 1.1f, 4.13f, 3.31f, 2.8f, 5.83f, 5.09f, 6.1f, 2.86f, 0.24f, 5.76f, 5.19f, 0.72f
 };
 
 //! All the input atom gridline indices
-static std::vector<IVec> const c_sampleGridLineIndicesFull
+std::vector<IVec> const c_sampleGridLineIndicesFull
 {
     IVec {
         4, 2, 6
@@ -156,7 +156,7 @@ static std::vector<IVec> const c_sampleGridLineIndicesFull
 // but that should not affect the reproducibility, which we're after
 
 //! A lot of bogus input spline values - should have at list (max PME order = 5) * (DIM = 3) * (total unique atom number in all test cases = 16) values
-static std::vector<real> const c_sampleSplineValuesFull
+std::vector<real> const c_sampleSplineValuesFull
 {
     0.12f, 0.81f, 0.29f, 0.22f, 0.13f, 0.19f, 0.12f, 0.8f, 0.44f, 0.38f, 0.32f, 0.36f, 0.27f, 0.11f, 0.17f, 0.94f, 0.07f, 0.9f, 0.98f, 0.96f, 0.07f, 0.94f, 0.77f, 0.24f, 0.84f, 0.16f, 0.77f, 0.57f, 0.52f, 0.27f, 0.39f, 0.45f, 0.6f, 0.59f, 0.44f, 0.91f, 0.97f, 0.43f, 0.24f, 0.52f, 0.73f, 0.55f, 0.99f, 0.39f, 0.97f, 0.35f, 0.1f, 0.68f, 0.19f, 0.1f, 0.77f, 0.2f, 0.43f, 0.69f, 0.76f, 0.32f, 0.31f, 0.94f, 0.53f, 0.6f, 0.93f, 0.57f, 0.94f, 0.88f, 0.75f, 0.77f, 0.91f, 0.72f, 0.07f, 0.78f, 0.09f, 0.02f, 0.48f, 0.97f, 0.89f, 0.39f, 0.48f, 0.19f, 0.02f, 0.92f, 0.8f, 0.41f, 0.53f, 0.32f, 0.38f, 0.58f, 0.36f, 0.46f, 0.92f, 0.91f, 0.01f, 0.86f, 0.54f, 0.86f, 0.94f, 0.37f, 0.35f, 0.81f, 0.89f, 0.48f,
     0.34f, 0.18f, 0.11f, 0.02f, 0.87f, 0.95f, 0.66f, 0.67f, 0.38f, 0.45f, 0.04f, 0.94f, 0.54f, 0.76f, 0.58f, 0.83f, 0.31f, 0.73f, 0.71f, 0.06f, 0.35f, 0.32f, 0.35f, 0.61f, 0.27f, 0.98f, 0.83f, 0.11f, 0.3f, 0.42f, 0.95f, 0.69f, 0.58f, 0.29f, 0.1f, 0.68f, 0.94f, 0.62f, 0.51f, 0.47f, 0.04f, 0.47f, 0.34f, 0.71f, 0.52f, 0.19f, 0.69f, 0.5f, 0.59f, 0.05f, 0.74f, 0.11f, 0.4f, 0.81f, 0.24f, 0.53f, 0.71f, 0.07f, 0.17f, 0.41f, 0.23f, 0.78f, 0.27f, 0.1f, 0.71f, 0.36f, 0.67f, 0.6f, 0.94f, 0.69f, 0.19f, 0.58f, 0.68f, 0.5f, 0.62f, 0.38f, 0.29f, 0.44f, 0.04f, 0.89f, 0.0f, 0.76f, 0.22f, 0.16f, 0.08f, 0.62f, 0.51f, 0.62f, 0.83f, 0.72f, 0.96f, 0.99f, 0.4f, 0.79f, 0.83f, 0.21f, 0.43f, 0.32f, 0.44f, 0.72f,
@@ -165,7 +165,7 @@ static std::vector<real> const c_sampleSplineValuesFull
 };
 
 //! A lot of bogus input spline derivatives - should have at list (max PME order = 5) * (DIM = 3) * (total unique atom number in all test cases = 16) values
-static std::vector<real> const c_sampleSplineDerivativesFull
+std::vector<real> const c_sampleSplineDerivativesFull
 {
     0.82f, 0.88f, 0.83f, 0.11f, 0.93f, 0.32f, 0.71f, 0.37f, 0.69f, 0.88f, 0.11f, 0.38f, 0.25f, 0.5f, 0.36f, 0.81f, 0.78f, 0.31f, 0.66f, 0.32f, 0.27f, 0.35f, 0.53f, 0.83f, 0.08f, 0.08f, 0.94f, 0.71f, 0.65f, 0.24f, 0.13f, 0.01f, 0.33f, 0.65f, 0.24f, 0.53f, 0.45f, 0.84f, 0.33f, 0.97f, 0.31f, 0.7f, 0.03f, 0.31f, 0.41f, 0.76f, 0.12f, 0.3f, 0.57f, 0.65f, 0.87f, 0.99f, 0.42f, 0.97f, 0.32f, 0.39f, 0.73f, 0.23f, 0.03f, 0.67f, 0.97f, 0.57f, 0.42f, 0.38f, 0.54f, 0.17f, 0.53f, 0.54f, 0.18f, 0.8f, 0.76f, 0.13f, 0.29f, 0.83f, 0.77f, 0.56f, 0.4f, 0.87f, 0.36f, 0.18f, 0.59f, 0.04f, 0.05f, 0.61f, 0.26f, 0.91f, 0.62f, 0.16f, 0.89f, 0.23f, 0.26f, 0.59f, 0.33f, 0.2f, 0.49f, 0.41f, 0.25f, 0.4f, 0.16f, 0.83f,
     0.44f, 0.82f, 0.21f, 0.95f, 0.14f, 0.8f, 0.37f, 0.31f, 0.41f, 0.53f, 0.15f, 0.85f, 0.78f, 0.17f, 0.92f, 0.03f, 0.13f, 0.2f, 0.03f, 0.33f, 0.87f, 0.38f, 0, 0.08f, 0.79f, 0.36f, 0.53f, 0.05f, 0.07f, 0.94f, 0.23f, 0.85f, 0.13f, 0.27f, 0.23f, 0.22f, 0.26f, 0.38f, 0.15f, 0.48f, 0.18f, 0.33f, 0.23f, 0.62f, 0.1f, 0.36f, 0.99f, 0.07f, 0.02f, 0.04f, 0.09f, 0.29f, 0.52f, 0.29f, 0.83f, 0.97f, 0.61f, 0.81f, 0.49f, 0.56f, 0.08f, 0.09f, 0.03f, 0.65f, 0.46f, 0.1f, 0.06f, 0.06f, 0.39f, 0.29f, 0.04f, 0.03f, 0.1f, 0.83f, 0.94f, 0.59f, 0.97f, 0.82f, 0.2f, 0.66f, 0.23f, 0.11f, 0.03f, 0.16f, 0.27f, 0.53f, 0.94f, 0.46f, 0.43f, 0.29f, 0.97f, 0.64f, 0.46f, 0.37f, 0.43f, 0.48f, 0.37f, 0.93f, 0.5f, 0.2f,
@@ -174,7 +174,7 @@ static std::vector<real> const c_sampleSplineDerivativesFull
 };
 
 //! 2 c_sample grids - only non-zero values have to be listed
-static std::vector<SparseRealGridValuesInput> const c_sampleGrids
+std::vector<SparseRealGridValuesInput> const c_sampleGrids
 {
     SparseRealGridValuesInput {{
                                    IVec {
@@ -248,7 +248,7 @@ static std::vector<SparseRealGridValuesInput> const c_sampleGrids
 };
 
 //! Input forces for reduction
-static std::vector<RVec> const c_sampleForcesFull {
+std::vector<RVec> const c_sampleForcesFull {
     RVec {
         0.02f, 0.87f, 0.95f
     }, RVec {
@@ -284,11 +284,11 @@ static std::vector<RVec> const c_sampleForcesFull {
 };
 
 //! PME orders to test
-static std::vector<int> const pmeOrders {
+std::vector<int> const pmeOrders {
     3, 4, 5
 };
 //! Atom counts to test
-static std::vector<size_t> const atomCounts {
+std::vector<size_t> const atomCounts {
     1, 2, 13
 };
 
index 532ba51bb9f628c48a8a4cc531c9048949368e04..32a296e2ce7229635d372698e093ff321ec3bbde 100644 (file)
@@ -250,7 +250,7 @@ TEST_P(PmeSolveTest, ReproducesOutputs)
 /* Valid input instances */
 
 //! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
 {
     // normal box
     Matrix3x3 {{
@@ -267,7 +267,7 @@ static std::vector<Matrix3x3> const c_sampleBoxes
 };
 
 //! A couple of valid inputs for grid sizes
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
 {
     IVec {
         16, 12, 28
@@ -283,7 +283,7 @@ const auto c_inputBoxes     = ::testing::ValuesIn(c_sampleBoxes);
 const auto c_inputGridSizes = ::testing::ValuesIn(c_sampleGridSizes);
 
 //! 2 sample complex grids - only non-zero values have to be listed
-static std::vector<SparseComplexGridValuesInput> const c_sampleGrids
+std::vector<SparseComplexGridValuesInput> const c_sampleGrids
 {
     SparseComplexGridValuesInput {{
                                       IVec {
index 01df43ed82c11fbc2d66627376993902980c7e5d..aca761a393c92f3ddccd7ebb4af70320ca245f65 100644 (file)
@@ -211,7 +211,7 @@ class PmeSplineAndSpreadTest : public ::testing::TestWithParam<SplineAndSpreadIn
                         /* The wrapped grid */
                         SparseRealGridValuesOutput nonZeroGridValues = pmeGetRealGrid(pmeSafe.get(), codePath);
                         TestReferenceChecker       gridValuesChecker(rootChecker.checkCompound("NonZeroGridValues", "RealSpaceGrid"));
-                        const auto                 ulpToleranceGrid = 2 * ulpToleranceSplineValues * (int)(ceil(sqrt(atomCount)));
+                        const auto                 ulpToleranceGrid = 2 * ulpToleranceSplineValues * static_cast<int>(ceil(sqrt(atomCount)));
                         /* 2 is empiric; sqrt(atomCount) assumes all the input charges may spread onto the same cell */
                         SCOPED_TRACE(formatString("Testing grid values with tolerance of %ld", ulpToleranceGrid));
                         if (!gridValuesSizeAssigned)
@@ -245,7 +245,7 @@ TEST_P(PmeSplineAndSpreadTest, ReproducesOutputs)
 /* Valid input instances */
 
 //! A couple of valid inputs for boxes.
-static std::vector<Matrix3x3> const c_sampleBoxes
+std::vector<Matrix3x3> const c_sampleBoxes
 {
     // normal box
     Matrix3x3 {{
@@ -262,7 +262,7 @@ static std::vector<Matrix3x3> const c_sampleBoxes
 };
 
 //! A couple of valid inputs for grid sizes.
-static std::vector<IVec> const c_sampleGridSizes
+std::vector<IVec> const c_sampleGridSizes
 {
     IVec {
         16, 12, 14
@@ -273,19 +273,19 @@ static std::vector<IVec> const c_sampleGridSizes
 };
 
 //! Random charges
-static std::vector<real> const c_sampleChargesFull
+std::vector<real> const c_sampleChargesFull
 {
     4.95f, 3.11f, 3.97f, 1.08f, 2.09f, 1.1f, 4.13f, 3.31f, 2.8f, 5.83f, 5.09f, 6.1f, 2.86f, 0.24f, 5.76f, 5.19f, 0.72f
 };
 //! 1 charge
-static auto const c_sampleCharges1 = ChargesVector(c_sampleChargesFull).subArray(0, 1);
+auto const c_sampleCharges1 = ChargesVector(c_sampleChargesFull).subArray(0, 1);
 //! 2 charges
-static auto const c_sampleCharges2 = ChargesVector(c_sampleChargesFull).subArray(1, 2);
+auto const c_sampleCharges2 = ChargesVector(c_sampleChargesFull).subArray(1, 2);
 //! 13 charges
-static auto const c_sampleCharges13 = ChargesVector(c_sampleChargesFull).subArray(3, 13);
+auto const c_sampleCharges13 = ChargesVector(c_sampleChargesFull).subArray(3, 13);
 
 //! Random coordinate vectors
-static CoordinatesVector const c_sampleCoordinatesFull
+CoordinatesVector const c_sampleCoordinatesFull
 {
     {
         5.59f, 1.37f, 0.95f
@@ -324,11 +324,11 @@ static CoordinatesVector const c_sampleCoordinatesFull
     }
 };
 //! 1 coordinate vector
-static CoordinatesVector const c_sampleCoordinates1(c_sampleCoordinatesFull.begin(), c_sampleCoordinatesFull.begin() + 1);
+CoordinatesVector const c_sampleCoordinates1(c_sampleCoordinatesFull.begin(), c_sampleCoordinatesFull.begin() + 1);
 //! 2 coordinate vectors
-static CoordinatesVector const c_sampleCoordinates2(c_sampleCoordinatesFull.begin() + 1, c_sampleCoordinatesFull.begin() + 3);
+CoordinatesVector const c_sampleCoordinates2(c_sampleCoordinatesFull.begin() + 1, c_sampleCoordinatesFull.begin() + 3);
 //! 13 coordinate vectors
-static CoordinatesVector const c_sampleCoordinates13(c_sampleCoordinatesFull.begin() + 3, c_sampleCoordinatesFull.begin() + 16);
+CoordinatesVector const c_sampleCoordinates13(c_sampleCoordinatesFull.begin() + 3, c_sampleCoordinatesFull.begin() + 16);
 
 //! moved out from instantiantions for readability
 auto c_inputBoxes     = ::testing::ValuesIn(c_sampleBoxes);
index 8faab8c2aff6c1cd1e9c5e9ed0bf54c6791cb512..9bcd6e1704694a9d78ef67a17b5bb9a5cf258a4b 100644 (file)
@@ -245,7 +245,7 @@ static void pmeGetComplexGridSizesInternal(const gmx_pme_t      *pme,
 }
 
 //! Getting the PME grid memory buffer and its sizes - template definition
-template<typename ValueType> static void pmeGetGridAndSizesInternal(const gmx_pme_t *, CodePath, ValueType * &, IVec &, IVec &)
+template<typename ValueType> static void pmeGetGridAndSizesInternal(const gmx_pme_t * /*unused*/, CodePath /*unused*/, ValueType * & /*unused*/, IVec & /*unused*/, IVec & /*unused*/)
 {
     GMX_THROW(InternalError("Deleted function call"));
     // explicitly deleting general template does not compile in clang/icc, see https://llvm.org/bugs/show_bug.cgi?id=17537
@@ -259,7 +259,7 @@ template<> void pmeGetGridAndSizesInternal<real>(const gmx_pme_t *pme, CodePath
 }
 
 //! Getting the PME complex grid memory buffer and its sizes
-template<> void pmeGetGridAndSizesInternal<t_complex>(const gmx_pme_t *pme, CodePath, t_complex * &grid, IVec &gridSize, IVec &paddedGridSize)
+template<> void pmeGetGridAndSizesInternal<t_complex>(const gmx_pme_t *pme, CodePath /*unused*/, t_complex * &grid, IVec &gridSize, IVec &paddedGridSize)
 {
     grid = pmeGetComplexGridInternal(pme);
     pmeGetComplexGridSizesInternal(pme, gridSize, paddedGridSize);
index b3c95b29eb7bf6e4c60d4af8834a3e874bc9f047..ddea88771270399a94bf9cb0111920a6a1c0a4bb 100644 (file)
@@ -71,7 +71,6 @@ const char *codePathToString(CodePath codePath)
         default:
             GMX_THROW(NotImplementedError("This CodePath should support codePathToString"));
     }
-    return "";
 }
 
 /* Implements the "construct on first use" idiom to avoid any static
index e3d764ce8cc1fa087826b9eeb8ee524ddece86d3..9206ac34932708f3ccac25c812fd2a96388c3484 100644 (file)
@@ -57,8 +57,8 @@ class ReadTest : public ::testing::Test
 {
     public:
         ReadTest() : inputField_ {{(t_inpfile(0, 0, false, false, false, "test", ""))}},
-        wi_(),
-        wiGuard_()
+        wi_()
+
         {
             wi_ = init_warning(FALSE, 0);
             wiGuard_.reset(wi_);
index 21610568ac726d3ed1861f914dfdc415bfce551e..77ca67b5737f3386b1167468b24e632b7d3b6bb8 100644 (file)
@@ -66,7 +66,7 @@ class TngTest : public ::testing::Test
 TEST_F(TngTest, CanOpenTngFile)
 {
     gmx_tng_trajectory_t tng;
-    gmx_tng_open(fileManager_.getInputFilePath("spc2-traj.tng").c_str(),
+    gmx_tng_open(gmx::test::TestFileManager::getInputFilePath("spc2-traj.tng").c_str(),
                  'r',
                  &tng);
     gmx_tng_close(&tng);
index 20831a85a569c26539a828c8064db76f453ef114..15dc632af0616da4905935de8221c4da3bde664c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -59,7 +59,7 @@ class GenconfTest : public gmx::test::CommandLineTestBase
     public:
         GenconfTest()
         {
-            std::string confFileName = fileManager().getInputFilePath("spc-and-methanol.gro");
+            std::string confFileName = gmx::test::TestFileManager::getInputFilePath("spc-and-methanol.gro");
             commandLine().addOption("-f", confFileName);
             commandLine().addOption("-seed", "1993"); // make random operations reproducible
             setOutputFile("-o", "out.gro", ExactTextMatch());
index 6c07d2eab4ea9ae010d55de1195806bb1d15a015..b6a721a36d2c30a4009b9ca9f6c841aadb95e0f8 100644 (file)
@@ -71,8 +71,8 @@ namespace test
 class GetIrTest : public ::testing::Test
 {
     public:
-        GetIrTest() : fileManager_(), ir_(), mdModules_(), opts_(),
-                      wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
+        GetIrTest() :  opts_(),
+                       wi_(init_warning(FALSE, 0)), wiGuard_(wi_)
 
         {
             snew(opts_.include, STRLEN);
index f1858fc9b538b1b2f596c46eafcb03f1f8da0746..6c4c03297442cc8bd0e1fc688bc3adc4897eacb9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -105,7 +105,7 @@ TEST_F(SolvateTest, cs_cp_p_Works)
     setInputFile("-cp", "spc-and-methanol.gro");
 
     // TODO: Consider adding a convenience method for this.
-    std::string topFileName           = fileManager().getInputFilePath("spc-and-methanol.top");
+    std::string topFileName           = gmx::test::TestFileManager::getInputFilePath("spc-and-methanol.top");
     std::string modifiableTopFileName = fileManager().getTemporaryFilePath(".top");
     gmx_file_copy(topFileName.c_str(), modifiableTopFileName.c_str(), true);
     commandLine().addOption("-p", modifiableTopFileName);
diff --git a/src/gromacs/linearalgebra/.clang-tidy b/src/gromacs/linearalgebra/.clang-tidy
new file mode 100644 (file)
index 0000000..de0482b
--- /dev/null
@@ -0,0 +1 @@
+Checks: -*
index b5306392a6580d2d887e4e531e57637ff3a8cf76..abe2d076b3ca65e35715c10d6efc609ec836a207 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -144,7 +144,7 @@ TEST(FunctionTest, InvsqrtDouble)
     gmx::test::TestReferenceChecker  checker(data.rootChecker());
     std::vector<double>              result;
 
-    for (double f = 1.0; f < 10.0; f += 1.0)
+    for (double f = 1.0; f < 10.0; f += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
     {
         result.push_back(gmx::invsqrt(f));
     }
@@ -223,7 +223,7 @@ TEST(FunctionTest, SixthrootDouble)
     gmx::test::TestReferenceChecker  checker(data.rootChecker());
     std::vector<double>              result;
 
-    for (double d = 0; d < 10.0; d += 1.0)
+    for (double d = 0; d < 10.0; d += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
     {
         result.push_back(gmx::sixthroot(d));
     }
@@ -236,6 +236,7 @@ TEST(FunctionTest, SixthrootInteger)
     gmx::test::TestReferenceChecker  checker(data.rootChecker());
     std::vector<double>              result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(gmx::sixthroot(i));
@@ -262,7 +263,7 @@ TEST(FunctionTest, InvsixthrootDouble)
     gmx::test::TestReferenceChecker  checker(data.rootChecker());
     std::vector<double>              result;
 
-    for (double d = 1.0; d < 10.0; d += 1.0)
+    for (double d = 1.0; d < 10.0; d += 1.0) // NOLINT(clang-analyzer-security.FloatLoopCounter)
     {
         result.push_back(gmx::invsixthroot(d));
     }
index 279f0535db18181993176b01ef0efbc98c7d34e3..1c2e22b892ebdfb4672d92a976d03b2d99b2369c 100644 (file)
@@ -153,7 +153,7 @@ TEST(RVecTest, CopyAssignmentWorks)
 TEST(RVecTest, MoveConstructorWorks)
 {
     RVec v(1, 2, 3);
-    RVec copy(std::move(v));
+    RVec copy(v);
     EXPECT_EQ(1, copy[XX]);
     EXPECT_EQ(2, copy[YY]);
     EXPECT_EQ(3, copy[ZZ]);
@@ -163,7 +163,7 @@ TEST(RVecTest, MoveAssignmentWorks)
 {
     RVec v(1, 2, 3);
     RVec copy;
-    copy = std::move(v);
+    copy = v;
     EXPECT_EQ(1, copy[XX]);
     EXPECT_EQ(2, copy[YY]);
     EXPECT_EQ(3, copy[ZZ]);
diff --git a/src/gromacs/mdlib/nbnxn_kernels/.clang-tidy b/src/gromacs/mdlib/nbnxn_kernels/.clang-tidy
deleted file mode 100644 (file)
index c05e99a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CheckOptions:
-  - key:             readability-function-size.StatementThreshold
-    value:           2000
index 6b2cba8415283be4440320f26a56deb8886ca391..7cae684b628eb81415b8cdb7ee07bf671bb08ded 100644 (file)
@@ -80,9 +80,9 @@ class PrintEbin : public ::testing::Test
         TestReferenceChecker             checker_;
 
         PrintEbin() : ebin_ {0}, ebinGuard_(&ebin_), mdebin_ {0},
-        fileManager_(), logFilename_(fileManager_.getTemporaryFilePath(".log")),
+        logFilename_(fileManager_.getTemporaryFilePath(".log")),
         log_(std::fopen(logFilename_.c_str(), "w")), logFileGuard_(log_),
-        refData_ {}, checker_(refData_.rootChecker())
+        checker_(refData_.rootChecker())
         {
             mdebin_.ebin = &ebin_;
         }
index 4e9524c4112b07e9cd204b544aea20b825b483aa..3510be85c04d59ef8d6fc047830f205351fb4d75 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <gmock/gmock.h>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/hardware/hardwaretopology.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/utility/basenetwork.h"
@@ -86,7 +87,7 @@ ThreadAffinityTestHelper::~ThreadAffinityTestHelper()
 
 void ThreadAffinityTestHelper::setLogicalProcessorCount(int logicalProcessorCount)
 {
-    hwTop_.reset(new HardwareTopology(logicalProcessorCount));
+    hwTop_ = gmx::compat::make_unique<HardwareTopology>(logicalProcessorCount);
 }
 
 } // namespace test
index b82764389378d1184ace0db274360d78f2e024b5..5ff24135c231f632ff2f83b434aba5165b935de7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -359,7 +359,7 @@ class TreeValueSupportTest : public ::testing::Test
 
         std::string formatBuffer(const std::vector<char> &buffer)
         {
-            return gmx::formatAndJoin(buffer, " ", [](char c) { return gmx::formatString("%02x", (unsigned char)c); });
+            return gmx::formatAndJoin(buffer, " ", [](char c) { return gmx::formatString("%02x", static_cast<unsigned char>(c)); });
         }
 };
 
index 684242433c084060acd7a67b754312571e875a90..759a2c17eebe4eb232f5527e3e02fb84e707d207 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -64,6 +64,7 @@ TEST(ExponentialDistributionTest, Output)
     gmx::ExponentialDistribution<real>  dist(5.0);
     std::vector<real>                   result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index 2d3ce20c76cf716925df3b78f17b7c5958b9791b..4cee2ca2a22a7828c881d91eb8b26d6cbe55ce21 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -64,6 +64,7 @@ TEST(GammaDistributionTest, Output)
     gmx::GammaDistribution<real>       dist(2.0, 5.0);
     std::vector<real>                  result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index a6d5022ce1e5307844d919b14fe93d89b009c482..3ad6af4ab70f9de4deb948ff815290ba2cdf06cb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -64,6 +64,7 @@ TEST(NormalDistributionTest, Output)
     gmx::NormalDistribution<real>       dist(2.0, 5.0);
     std::vector<real>                   result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index 0d02da7f02a751217d0b2fa3cd03ca063b173a9b..6693d875b4d6674502b65e0a1279883dbfc50905 100644 (file)
@@ -64,6 +64,7 @@ TEST(TabulatedNormalDistributionTest, Output14)
     gmx::TabulatedNormalDistribution<>   dist(2.0, 5.0); // Use default 14-bit resolution
     std::vector<float>                   result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
@@ -80,6 +81,7 @@ TEST(TabulatedNormalDistributionTest, Output16)
     gmx::TabulatedNormalDistribution<float, 16>   dist(2.0, 5.0); // Use larger 16-bit table
     std::vector<float>                            result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
@@ -96,6 +98,7 @@ TEST(TabulatedNormalDistributionTest, OutputDouble14)
     gmx::TabulatedNormalDistribution<double>      dist(2.0, 5.0);
     std::vector<double>                           result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index 0930892b3907890d0e9505fa40909b037d59e5e8..6552fec98abc0afdaa671702dff2da126c4246bc 100644 (file)
@@ -174,6 +174,7 @@ TEST_F(ThreeFry2x64Test, InternalCounterSequence)
     gmx::ThreeFry2x64<66>        rngA(123456, gmx::RandomDomain::Other);
     std::vector<uint64_t>        result;
 
+    result.reserve(16);
     for (int i = 0; i < 16; i++)
     {
         result.push_back(rngA());
index 40e99f0140d4fe39798815d07e26452f78e9bb4b..b7cd01ef61e390512e42f40400463906076bb512 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -64,6 +64,7 @@ TEST(UniformIntDistributionTest, Output)
     gmx::UniformIntDistribution<int>        dist(1, 1000);
     std::vector<int>                        result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index 6121eb463e2235e0c3ccaa1d0be090c5fe44d490..599d89ebea468cebed16c21c0abc6ee3f53f0b9e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -63,6 +63,7 @@ TEST(UniformRealDistributionTest, GenerateCanonical)
     gmx::ThreeFry2x64<8>                rng(123456, gmx::RandomDomain::Other);
     std::vector<real>                   result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(gmx::generateCanonical<real, std::numeric_limits<real>::digits>(rng));
@@ -79,6 +80,7 @@ TEST(UniformRealDistributionTest, Output)
     gmx::UniformRealDistribution<real>      dist(1.0, 10.0);
     std::vector<real>                       result;
 
+    result.reserve(10);
     for (int i = 0; i < 10; i++)
     {
         result.push_back(dist(rng));
index ee2fc570295eaf4f74e7bbd255f1e7b6d5f93cc9..b8e489f6e3d187966a3c0ec250b7f4c171da5d0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -82,7 +82,7 @@ yyerror(YYLTYPE *location, yyscan_t scanner, char const *s)
 //! Logic for computing the location of the output of Bison reduction.
 #define YYLLOC_DEFAULT(Current, Rhs, N)                          \
     do {                                                         \
-        if (N != 0)                                              \
+        if ((N) != 0)                                              \
         {                                                        \
             (Current).startIndex = YYRHSLOC(Rhs, 1).startIndex;  \
             (Current).endIndex   = YYRHSLOC(Rhs, N).endIndex;    \
@@ -218,7 +218,7 @@ void set_empty(ValueType * &dest)
  */
 #define CHECK_SEL(sel) \
     if (!*(sel)) { \
-        delete sel; \
+        delete (sel); \
         YYERROR; \
     }
 
index 4e0c86802d0ee20518a30bf407c8f1e6a78d3680..e3afd50051d75036fd9316f6490fc8cd7636bf70 100644 (file)
@@ -168,11 +168,7 @@ class NeighborhoodSearchTestData
             const std::vector<RefPair>          &refPairs = testPositions_[testIndex].refPairs;
             std::vector<RefPair>::const_iterator foundRefPair
                 = std::lower_bound(refPairs.begin(), refPairs.end(), pair);
-            if (foundRefPair == refPairs.end() || foundRefPair->refIndex != pair.refIndex)
-            {
-                return false;
-            }
-            return true;
+            return !(foundRefPair == refPairs.end() || foundRefPair->refIndex != pair.refIndex);
         }
 
         // Return a tolerance that accounts for the magnitudes of the coordinates
index 7daa1b4fb106b87fb61e28bfce4abda018cc40bc..a7fb303f1dd38dfccd460ac97e9965689792ea2f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -109,20 +109,6 @@ class PositionCalculationTest : public ::testing::Test
             {
             }
 
-            // Default move constructor and assignment. Only needed for old compilers.
-            PositionTest(PositionTest &&o)
-                : pos(std::move(o.pos)), pc(o.pc), name(o.name)
-            {
-            }
-
-            PositionTest &operator= (PositionTest &&o)
-            {
-                pos  = std::move(o.pos);
-                pc   = o.pc;
-                name = o.name;
-                return *this;
-            }
-
             PositionPointer                 pos;
             gmx_ana_poscalc_t              *pc;
             const char                     *name;
index f294aa179ed2eee61aabc96fc47b4978d7a97706..5d1ed80ed62f297ca1ad1a77f8ee907fca326983 100644 (file)
@@ -68,7 +68,7 @@ namespace test
 {
 
 TopologyManager::TopologyManager()
-    : mtop_(), frame_(nullptr)
+    :  frame_(nullptr)
 {
 }
 
index b41ba5614cd41d1bfd3d7d9413a5bb26f4d0a12e..78730cef426b1e024c1308753de44c3b66cfffe9 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -35,7 +35,6 @@
 gmx_add_unit_test(SimdUnitTests simd-test
                   bootstrap_loadstore.cpp
                  base.cpp
-                  data.cpp
                   simd.cpp
                  simd_floatingpoint.cpp
                   simd_floatingpoint_util.cpp
index 41825a9b38dcea311622d3c0cbe836d5140981a1..bc16427175c3365bb48dbf482eba1a83aef213cb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -97,7 +97,7 @@ SimdBaseTest::compareVectorRealUlp(const char * refExpr,   const char * tstExpr,
 
     for (i = 0, allOk = true; i < tst.size(); i++)
     {
-        absDiff[i]  = fabs(ref[i]-tst[i]);
+        absDiff[i]  = std::abs(ref[i]-tst[i]);
         conv0.r     = ref[i];
         conv1.r     = tst[i];
         ulpDiff[i]  = llabs(conv0.i-conv1.i);
@@ -106,7 +106,7 @@ SimdBaseTest::compareVectorRealUlp(const char * refExpr,   const char * tstExpr,
         allOk       = allOk && ( ( absDiff[i] < absTol_ ) || ( ( ref[i]*tst[i] >= 0 ) && (ulpDiff[i] <= ulpTol_) ) );
     }
 
-    if (allOk == true)
+    if (allOk)
     {
         return ::testing::AssertionSuccess();
     }
index 77d4a3dcbabb9a649bf5bd1e49b33bc514e14ec2..2f85847a5901b2b1fb60cbf9960f112e9e380571 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -114,6 +114,16 @@ class SimdBaseTest : public ::testing::Test
         /*! \brief Adjust ulp tolerance from the default 10 (float) or 255 (double). */
         void setUlpTol(std::int64_t newTol)   { ulpTol_ = newTol; }
 
+        /*! \brief Adjust ulp tolerance for single accuracy functions. */
+        void setUlpTolSingleAccuracy(std::int64_t newTol)
+        {
+#if GMX_DOUBLE
+            setUlpTol(newTol * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+#else
+            setUlpTol(newTol);
+#endif
+        }
+
         /*! \brief Adjust the absolute tolerance from the default 0.
          *
          * If values are closer than the absolute tolerance, the test will pass
diff --git a/src/gromacs/simd/tests/data.cpp b/src/gromacs/simd/tests/data.cpp
deleted file mode 100644 (file)
index 1e3ab7b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-#include "gmxpre.h"
-
-#include "data.h"
-
-#include "gromacs/utility/real.h"
-
-
-namespace gmx
-{
-namespace test
-{
-
-/*! \cond internal */
-/*! \addtogroup module_simd */
-/*! \{ */
-
-// Common test data constants used both for SIMD, SIMD4, and scalar tests.
-// We both want numbers that are easy to identify with integer part from 0 to 9,
-// and to fill all digits in the mantissa and avoid identical differences
-// between adjacent numbers we add a fraction of primes.
-const real czero = 0.0;
-const real c0    = 0.0 + 1.0/3.0;
-const real c1    = 1.0 + 5.0/7.0;
-const real c2    = 2.0 + 9.0/13.0;
-const real c3    = 3.0 + 17.0/19.0;
-const real c4    = 4.0 + 23.0/29.0;
-const real c5    = 5.0 + 31.0/37.0;
-const real c6    = 6.0 + 41.0/43.0;
-const real c7    = 7.0 + 47.0/53.0;
-const real c8    = 8.0 + 59.0/61.0;
-
-/*! \} */
-/*! \endcond */
-
-} // namespace test
-
-} // namespace gmx
index b66abcece7bcb2ebdc5723cda11a1f272b854e1b..c1074ebac6528f60356a354768ab624f89daaf46 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -61,18 +61,16 @@ namespace test
 /*! \cond internal */
 /*! \addtogroup module_simd */
 /*! \{ */
-extern const real czero; //!< Value 0.0 in real precision
-extern const real c0;    //!< Random fp value using entire mantissa
-extern const real c1;    //!< Random fp value using entire mantissa
-extern const real c2;    //!< Random fp value using entire mantissa
-extern const real c3;    //!< Random fp value using entire mantissa
-extern const real c4;    //!< Random fp value using entire mantissa
-extern const real c5;    //!< Random fp value using entire mantissa
-extern const real c5;    //!< Random fp value using entire mantissa
-extern const real c6;    //!< Random fp value using entire mantissa
-extern const real c7;    //!< Random fp value using entire mantissa
-extern const real c8;    //!< Random fp value using entire mantissa
-extern const real c9;    //!< Random fp value using entire mantissa
+constexpr real czero = 0.0;             //!< zero
+constexpr real c0    = 0.0 + 1.0/3.0;   //!< test constant
+constexpr real c1    = 1.0 + 5.0/7.0;   //!< test constant
+constexpr real c2    = 2.0 + 9.0/13.0;  //!< test constant
+constexpr real c3    = 3.0 + 17.0/19.0; //!< test constant
+constexpr real c4    = 4.0 + 23.0/29.0; //!< test constant
+constexpr real c5    = 5.0 + 31.0/37.0; //!< test constant
+constexpr real c6    = 6.0 + 41.0/43.0; //!< test constant
+constexpr real c7    = 7.0 + 47.0/53.0; //!< test constant
+constexpr real c8    = 8.0 + 59.0/61.0; //!< test constant
 
 /*! \} */
 /*! \endcond */
index cfd77f153b95f21248398826d51a7adaa3b609e8..2b3f9f9e6a0d42f8b0845e86f2aa7e0b238c1f63 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -42,6 +42,8 @@
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/real.h"
 
+#include "testutils/testasserts.h"
+
 #include "data.h"
 
 namespace gmx
@@ -109,40 +111,40 @@ TEST(SimdScalarTest, andNot)
 
 TEST(SimdScalarTest, fma)
 {
-    EXPECT_EQ(c1*c2+c3, fma(real(c1), real(c2), real(c3)));
+    EXPECT_REAL_EQ_TOL(c1*c2+c3, fma(real(c1), real(c2), real(c3)), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, fms)
 {
-    EXPECT_EQ(c1*c2-c3, fms(c1, c2, c3));
+    EXPECT_REAL_EQ_TOL(c1*c2-c3, fms(c1, c2, c3), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, fnma)
 {
-    EXPECT_EQ(-c1*c2+c3, fnma(c1, c2, c3));
+    EXPECT_REAL_EQ_TOL(-c1*c2+c3, fnma(c1, c2, c3), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, fnms)
 {
-    EXPECT_EQ(-c1*c2-c3, fnms(c1, c2, c3));
+    EXPECT_REAL_EQ_TOL(-c1*c2-c3, fnms(c1, c2, c3), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, maskAdd)
 {
-    EXPECT_EQ(c1, maskAdd(c1, c2, false));
-    EXPECT_EQ(c1+c2, maskAdd(c1, c2, true));
+    EXPECT_REAL_EQ_TOL(c1, maskAdd(c1, c2, false), defaultRealTolerance());
+    EXPECT_REAL_EQ_TOL(c1+c2, maskAdd(c1, c2, true), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, maskzMul)
 {
-    EXPECT_EQ(czero, maskzMul(c1, c2, false));
-    EXPECT_EQ(c1*c2, maskzMul(c1, c2, true));
+    EXPECT_REAL_EQ_TOL(czero, maskzMul(c1, c2, false), defaultRealTolerance());
+    EXPECT_REAL_EQ_TOL(c1*c2, maskzMul(c1, c2, true), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, maskzFma)
 {
-    EXPECT_EQ(czero, maskzFma(c1, c2, c3, false));
-    EXPECT_EQ(c1*c2+c3, maskzFma(c1, c2, c3, true));
+    EXPECT_REAL_EQ_TOL(czero, maskzFma(c1, c2, c3, false), defaultRealTolerance());
+    EXPECT_REAL_EQ_TOL(c1*c2+c3, maskzFma(c1, c2, c3, true), defaultRealTolerance());
 }
 
 TEST(SimdScalarTest, abs)
index b4d08f4c5858ec6aa6895f301428957a8da2049a..60fb2ba2e86d58651a72c57968e54c41c8accb0b 100644 (file)
@@ -189,7 +189,7 @@ class SimdTest : public SimdBaseTest
 
             ::testing::AssertionResult
         compareSimdRealUlp(const char * refExpr, const char * tstExpr,
-                           const SimdReal ref, const SimdReal tst);
+                           SimdReal ref, SimdReal tst);
 
         /*! \brief Compare two real SIMD variables for exact equality.
          *
@@ -205,7 +205,7 @@ class SimdTest : public SimdBaseTest
          */
         ::testing::AssertionResult
         compareSimdEq(const char * refExpr, const char * tstExpr,
-                      const SimdReal ref, const SimdReal tst);
+                      SimdReal ref, SimdReal tst);
 
         /*! \brief Compare two 32-bit integer SIMD variables.
          *
@@ -221,7 +221,7 @@ class SimdTest : public SimdBaseTest
          */
         ::testing::AssertionResult
         compareSimdEq(const char * refExpr, const char *  tstExpr,
-                      const SimdInt32 ref, const SimdInt32 tst);
+                      SimdInt32 ref, SimdInt32 tst);
 #endif
 };
 
@@ -230,7 +230,7 @@ class SimdTest : public SimdBaseTest
  *
  * The returned vector will have the same length as the SIMD width.
  */
-std::vector<real> simdReal2Vector(const SimdReal simd);
+std::vector<real> simdReal2Vector(SimdReal simd);
 
 /*! \brief Return floating-point SIMD value from std::vector<real>.
  *
@@ -268,7 +268,7 @@ SimdReal   setSimdRealFrom1R(real value);
  *
  * The returned vector will have the same length as the SIMD width.
  */
-std::vector<std::int32_t>   simdInt2Vector(const SimdInt32 simd);
+std::vector<std::int32_t>   simdInt2Vector(SimdInt32 simd);
 
 /*! \brief Return 32-bit integer SIMD value from std::vector<int>.
  *
index 4d4eecde531a5b824ff9d4edb2a7a1cb89b6f5c3..b7971035ddf6fb63d2d542f63a76143acdbf91fd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -122,7 +122,7 @@ class Simd4Test : public SimdBaseTest
          */
         ::testing::AssertionResult
         compareSimd4RealUlp(const char * refExpr, const char * tstExpr,
-                            const Simd4Real ref, const Simd4Real tst);
+                            Simd4Real ref, Simd4Real tst);
 
         /*! \brief Compare two real SIMD4 variables for exact equality.
          *
@@ -138,14 +138,14 @@ class Simd4Test : public SimdBaseTest
          */
         ::testing::AssertionResult
         compareSimd4RealEq(const char * refExpr, const char * tstExpr,
-                           const Simd4Real ref, const Simd4Real tst);
+                           Simd4Real ref, Simd4Real tst);
 };
 
 /*! \brief Convert SIMD4 real to std::vector<real>.
  *
  * The returned vector will have the same length as the SIMD4 width.
  */
-std::vector<real> simd4Real2Vector(const Simd4Real simd4);
+std::vector<real> simd4Real2Vector(Simd4Real simd4);
 
 /*! \brief Return floating-point SIMD4 value from std::vector<real>.
  *
index d1f7aacccfcd31bd2fb160f398260ef30a5239b5..989eca28000583f4f4f32e178284f1a4e947b177 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "config.h"
 
+#include <cmath>
 #include <cstdint>
 
 #include <vector>
@@ -124,17 +125,17 @@ Simd4MathTest::compareSimd4MathFunction(const char * refFuncExpr, const char *si
         vtst  = simd4Real2Vector(simd4Func(vector2Simd4Real(vx)));
 
         bool eq = true, signOk = true;
-        for (int i = 0; i < GMX_SIMD4_WIDTH && eq == true; i++)
+        for (int i = 0; i < GMX_SIMD4_WIDTH && eq; i++)
         {
-            eq     = eq && ( fabs(vref[i]-vtst[i]) < absTol_ );
+            eq     = eq && ( std::abs(vref[i]-vtst[i]) < absTol_ );
             signOk = signOk && ( vref[i]*vtst[i] >= 0 );
         }
-        if (eq == true)
+        if (eq)
         {
             // Go to next point if everything within absolute tolerance
             continue;
         }
-        else if (signOk == false)
+        else if (!signOk)
         {
             return ::testing::AssertionFailure()
                    << "Failing SIMD4 math function comparison due to sign differences." << std::endl
@@ -195,7 +196,7 @@ namespace
 /*! \{ */
 
 /*! \brief Function wrapper to evaluate reference 1/sqrt(x) */
-static real
+real
 refInvsqrt(real x)
 {
     return 1.0/std::sqrt(x);
@@ -211,7 +212,7 @@ TEST_F(Simd4MathTest, invsqrtSingleaccuracy)
 {
     setRange(1e-10, 1e10);
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
     GMX_EXPECT_SIMD4_FUNC_NEAR(refInvsqrt, invsqrtSingleAccuracy);
 }
 
index 7c1e65195abe7063f5059e914048b3e1cd4844eb..a62d893a9a86029dddf6d509ea84df77e743ab38 100644 (file)
@@ -162,7 +162,7 @@ SimdMathTest::compareSimdMathFunction(const char              * refFuncExpr,
                 }
             }
 
-            absDiff = fabs(vref[i]-vtst[i]);
+            absDiff = std::abs(vref[i]-vtst[i]);
             absOk   = absOk  && ( absDiff < absTol_ );
             signOk  = signOk && ( (vref[i] >= 0 && vtst[i] >= 0) ||
                                   (vref[i] <= 0 && vtst[i] <= 0));
@@ -186,7 +186,7 @@ SimdMathTest::compareSimdMathFunction(const char              * refFuncExpr,
                 }
             }
         }
-        if ( (absOk == false) && (signOk == false) )
+        if ( (!absOk) && (!signOk) )
         {
             return ::testing::AssertionFailure()
                    << "Failing SIMD math function comparison due to sign differences." << std::endl
@@ -241,7 +241,7 @@ TEST_F(SimdMathTest, copysign)
 }
 
 /*! \brief Function wrapper to evaluate reference 1/sqrt(x) */
-static real
+real
 refInvsqrt(real x)
 {
     return 1.0/std::sqrt(x);
@@ -291,15 +291,14 @@ TEST_F(SimdMathTest, invsqrtPair)
 }
 
 /*! \brief Function wrapper to evaluate reference sqrt(x) */
-static real
+real
 refSqrt(real x)
 {
     return std::sqrt(x);
 }
 
 /*! \brief Dummy function returning 0.0 to test function ranges that should be zero */
-gmx_unused static real
-refZero(real gmx_unused x)
+gmx_unused real refZero(real gmx_unused x)
 {
     return 0.0;
 }
@@ -664,7 +663,7 @@ TEST_F(SimdMathTest, pmePotentialCorrection)
 TEST_F(SimdMathTest, invsqrtSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(1.01*GMX_FLOAT_MIN, GMX_FLOAT_MAX);
     GMX_EXPECT_SIMD_FUNC_NEAR(refInvsqrt, invsqrtSingleAccuracy);
@@ -691,7 +690,7 @@ tst_invsqrt_SingleAccuracy_pair1(SimdReal x)
 TEST_F(SimdMathTest, invsqrtPairSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(1.01*GMX_FLOAT_MIN, GMX_FLOAT_MAX);
     GMX_EXPECT_SIMD_FUNC_NEAR(refInvsqrt, tst_invsqrt_SingleAccuracy_pair0);
@@ -701,7 +700,7 @@ TEST_F(SimdMathTest, invsqrtPairSingleAccuracy)
 TEST_F(SimdMathTest, sqrtSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // First test that 0.0 and a few other values works
     GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom3R(0, std::sqrt(c0), std::sqrt(c1)), sqrtSingleAccuracy(setSimdRealFrom3R(0, c0, c1)));
@@ -721,7 +720,7 @@ TEST_F(SimdMathTest, sqrtSingleAccuracy)
 TEST_F(SimdMathTest, sqrtSingleAccuracyUnsafe)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // Test the full range
     setRange(GMX_FLOAT_MIN, GMX_FLOAT_MAX);
@@ -731,7 +730,7 @@ TEST_F(SimdMathTest, sqrtSingleAccuracyUnsafe)
 TEST_F(SimdMathTest, invSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // test <0
     setRange(-1e10, -1e-10);
@@ -743,7 +742,7 @@ TEST_F(SimdMathTest, invSingleAccuracy)
 TEST_F(SimdMathTest, logSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(1e-30, 1e30);
     GMX_EXPECT_SIMD_FUNC_NEAR(std::log, logSingleAccuracy);
@@ -752,7 +751,7 @@ TEST_F(SimdMathTest, logSingleAccuracy)
 TEST_F(SimdMathTest, exp2SingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
 #if GMX_DOUBLE
     setRange(-1022.49, 1023.49);
@@ -780,7 +779,7 @@ TEST_F(SimdMathTest, exp2SingleAccuracy)
 TEST_F(SimdMathTest, exp2SingleAccuracyUnsafe)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
 #if GMX_DOUBLE
     setRange(-1022.49, 1023.49);
@@ -793,7 +792,7 @@ TEST_F(SimdMathTest, exp2SingleAccuracyUnsafe)
 TEST_F(SimdMathTest, expSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
 #if GMX_DOUBLE
     setRange(-708.7, 709.4);
@@ -823,7 +822,7 @@ TEST_F(SimdMathTest, expSingleAccuracy)
 TEST_F(SimdMathTest, expSingleAccuracyUnsafe)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
 #if GMX_DOUBLE
     setRange(-708.7, 709.4);
@@ -836,7 +835,7 @@ TEST_F(SimdMathTest, expSingleAccuracyUnsafe)
 TEST_F(SimdMathTest, erfSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(-9, 9);
     setAbsTol(GMX_REAL_MIN);
@@ -846,7 +845,7 @@ TEST_F(SimdMathTest, erfSingleAccuracy)
 TEST_F(SimdMathTest, erfcSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(-9, 9);
     setAbsTol(GMX_REAL_MIN);
@@ -859,7 +858,7 @@ TEST_F(SimdMathTest, erfcSingleAccuracy)
 TEST_F(SimdMathTest, sinSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(-8*M_PI, 8*M_PI);
     GMX_EXPECT_SIMD_FUNC_NEAR(std::sin, sinSingleAccuracy);
@@ -872,7 +871,7 @@ TEST_F(SimdMathTest, sinSingleAccuracy)
 TEST_F(SimdMathTest, cosSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     setRange(-8*M_PI, 8*M_PI);
     GMX_EXPECT_SIMD_FUNC_NEAR(std::cos, cosSingleAccuracy);
@@ -884,7 +883,7 @@ TEST_F(SimdMathTest, cosSingleAccuracy)
 TEST_F(SimdMathTest, tanSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // Tan(x) is a little sensitive due to the division in the algorithm.
     // Rather than using lots of extra FP operations, we accept the algorithm
@@ -899,7 +898,7 @@ TEST_F(SimdMathTest, tanSingleAccuracy)
 TEST_F(SimdMathTest, asinSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // Our present asin(x) algorithm achieves 2-3 ulp accuracy
     setRange(-1, 1);
@@ -909,7 +908,7 @@ TEST_F(SimdMathTest, asinSingleAccuracy)
 TEST_F(SimdMathTest, acosSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // Our present acos(x) algorithm achieves 2-3 ulp accuracy
     setRange(-1, 1);
@@ -919,7 +918,7 @@ TEST_F(SimdMathTest, acosSingleAccuracy)
 TEST_F(SimdMathTest, atanSingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // Our present atan(x) algorithm achieves 1 ulp accuracy
     setRange(-10000, 10000);
@@ -929,7 +928,7 @@ TEST_F(SimdMathTest, atanSingleAccuracy)
 TEST_F(SimdMathTest, atan2SingleAccuracy)
 {
     /* Increase the allowed error by the difference between the actual precision and single */
-    setUlpTol(ulpTol_ * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(ulpTol_);
 
     // test each quadrant
     GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom3R(std::atan2(c0, c3), std::atan2(c1, c4), std::atan2(c2, c5)),
@@ -961,7 +960,7 @@ TEST_F(SimdMathTest, pmeForceCorrectionSingleAccuracy)
     // The PME corrections will be added to ~1/r2, so absolute tolerance of EPS is fine.
     // Pme correction only needs to be ~1e-6 accuracy single.
     // Then increase the allowed error by the difference between the actual precision and single.
-    setUlpTol( (std::int64_t(5e-6/GMX_FLOAT_EPS)) * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(std::int64_t(5e-6/GMX_FLOAT_EPS));
 
     setRange(0.15, 4);
     setAbsTol(GMX_FLOAT_EPS);
@@ -973,7 +972,7 @@ TEST_F(SimdMathTest, pmePotentialCorrectionSingleAccuracy)
     // The PME corrections will be added to ~1/r, so absolute tolerance of EPS is fine.
     // Pme correction only needs to be ~1e-6 accuracy single.
     // Then increase the allowed error by the difference between the actual precision and single.
-    setUlpTol( (std::int64_t(5e-6/GMX_FLOAT_EPS)) * (1LL << (std::numeric_limits<real>::digits-std::numeric_limits<float>::digits)));
+    setUlpTolSingleAccuracy(std::int64_t(5e-6/GMX_FLOAT_EPS));
 
     setRange(0.15, 4);
     setAbsTol(GMX_FLOAT_EPS);
index afb40706b0188f445dfa14ee923658fa80043369..44c7061b93ca196d70f7cf879e8d079dd8681a87 100644 (file)
@@ -135,7 +135,7 @@ SplineTableTest<T>::testSplineTableAgainstFunctions(const std::string
 
     FloatingPointTolerance funcTolerance(relativeToleranceAsFloatingPoint(0.0, tolerance_));
 
-    for (real x = testRange.first; x < testRange.second; x += dx)
+    for (real x = testRange.first; x < testRange.second; x += dx) // NOLINT(clang-analyzer-security.FloatLoopCounter)
     {
         real h                = std::sqrt(GMX_REAL_EPS);
         real secondDerivative = (refDer(x+h)-refDer(x))/h;
index cdc64442bc29ef31fbb814a2239df83cf4adfc04..73a874e620366bd5d281f48c68be691384686052 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -104,17 +104,6 @@ class SurfaceAreaTest : public ::testing::Test
             *radius = 1.5*dist(rng_) + 0.5;
         }
 
-        void addDummySpheres(int count)
-        {
-            for (int i = 0; i < count; ++i)
-            {
-                rvec x;
-                real radius;
-                generateRandomPosition(x, &radius);
-                addSphere(x[XX], x[YY], x[ZZ], radius, false);
-            }
-        }
-
         void generateRandomPositions(int count)
         {
             x_.reserve(count);
index 40b897bff3521adf2a502cc47aa0d361e0d47ad5..d0e3c095726a060771321157c7d885ca5d5bc715 100644 (file)
@@ -48,6 +48,8 @@
 
 #include <string.h>
 
+#include <array>
+
 #include "gromacs/utility/basedefinitions.h"
 
 /*! \brief Size of bitmask. Has to be 32 or multiple of 64. */
@@ -121,34 +123,34 @@ inline static void bitmask_union(gmx_bitmask_t* a, gmx_bitmask_t b)
 }
 #else
 #define BITMASK_ALEN (BITMASK_SIZE/64)
-typedef uint64_t gmx_bitmask_t[BITMASK_ALEN];
+using gmx_bitmask_t = std::array<uint64_t, BITMASK_ALEN>;
 
 inline static void bitmask_clear(gmx_bitmask_t* m)
 {
-    memset(*m, 0, BITMASK_SIZE/8);
+    m->fill(0);
 }
 
 inline static void bitmask_set_bit(gmx_bitmask_t* m, int b)
 {
-    (*m)[b/64] |= ((uint64_t)1 << (b%64));
+    (*m)[b/64] |= (static_cast<uint64_t>(1) << (b%64));
 }
 
 inline static void bitmask_init_bit(gmx_bitmask_t* m, int b)
 {
     bitmask_clear(m);
-    (*m)[b/64] = ((uint64_t)1 << (b%64));
+    (*m)[b/64] = (static_cast<uint64_t>(1) << (b%64));
 }
 
 inline static void bitmask_init_low_bits(gmx_bitmask_t* m, int b)
 {
-    memset(*m, 255, b/64*8);
-    (*m)[b/64] = ((uint64_t)1 << (b%64)) - 1;
-    memset(&(*m)[b/64+1], 0, (BITMASK_ALEN-b/64-1)*8);
+    memset(m->data(), 255, b/64*8);
+    (*m)[b/64] = (static_cast<uint64_t>(1) << (b%64)) - 1;
+    memset(&(m->data())[b/64+1], 0, (BITMASK_ALEN-b/64-1)*8);
 }
 
 inline static bool bitmask_is_set(gmx_bitmask_t m, int b)
 {
-    return (m[b/64] & ((uint64_t)1 << (b%64))) != 0;
+    return (m[b/64] & (static_cast<uint64_t>(1) << (b%64))) != 0;
 }
 
 inline static bool bitmask_is_disjoint(gmx_bitmask_t a, gmx_bitmask_t b)
index d5922882003b92a0407cbeda9ac6707437d85c9f..1982c1a874c80cd9b0c5a4afbf736730b93a43f2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -80,7 +80,7 @@ class AllocatorTest : public ::testing::Test
 
 // NB need to use this->mask() because of GoogleTest quirks
 
-TYPED_TEST(AllocatorTest, AllocatorAlignAllocatesWithAlignment)
+TYPED_TEST(AllocatorTest, AllocatorAlignAllocatesWithAlignment) //NOLINT(misc-definitions-in-headers)
 {
     using pointer = typename TypeParam::pointer;
     TypeParam a;
@@ -91,7 +91,7 @@ TYPED_TEST(AllocatorTest, AllocatorAlignAllocatesWithAlignment)
 }
 
 
-TYPED_TEST(AllocatorTest, VectorAllocatesAndResizesWithAlignment)
+TYPED_TEST(AllocatorTest, VectorAllocatesAndResizesWithAlignment) //NOLINT(misc-definitions-in-headers)
 {
     using value_type = typename TypeParam::value_type;
     std::vector<value_type, TypeParam> v(10);
@@ -107,7 +107,7 @@ TYPED_TEST(AllocatorTest, VectorAllocatesAndResizesWithAlignment)
     }
 }
 
-TYPED_TEST(AllocatorTest, VectorAllocatesAndReservesWithAlignment)
+TYPED_TEST(AllocatorTest, VectorAllocatesAndReservesWithAlignment) //NOLINT(misc-definitions-in-headers)
 {
     using value_type = typename TypeParam::value_type;
     std::vector<value_type, TypeParam> v(10);
index f6f98fcabc1390ee5a85e1f3a1e1cd5348352651..99153f5b5d8480f8a2b7f2e29a3cc38f9b2b689b 100644 (file)
@@ -147,7 +147,7 @@ TYPED_TEST_CASE(ArrayRefTest, ArrayRefTypes);
         static_cast<typename TestFixture::ValueType>(2.4),      \
         static_cast<typename TestFixture::ValueType>(3.1)       \
     };                                                          \
-    size_t (aSize) = sizeof((a)) / sizeof(typename TestFixture::ValueType);
+    size_t aSize = sizeof((a)) / sizeof(typename TestFixture::ValueType);
 
 #define DEFINE_NON_CONST_ARRAY(a, aSize)                        \
     typename TestFixture::NonConstValueType (a)[] = {           \
@@ -155,7 +155,7 @@ TYPED_TEST_CASE(ArrayRefTest, ArrayRefTypes);
         static_cast<typename TestFixture::ValueType>(2.4),      \
         static_cast<typename TestFixture::ValueType>(3.1)       \
     };                                                          \
-    size_t (aSize) = sizeof((a)) / sizeof(typename TestFixture::ValueType);
+    size_t aSize = sizeof((a)) / sizeof(typename TestFixture::ValueType);
 
 
 TYPED_TEST(ArrayRefTest, MakeWithAssignmentWorks)
index 3cc5376b1f1f410d74a8e4b4af0651e7e80b6796..9fb0dd0c9e3105874293129f03f8637b4252a167 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -58,7 +58,7 @@ class BITMASK_CLASSNAME(BITMASK_SIZE) : public ::testing::TestWithParam<int>
 {
 };
 
-BITMASK_TEST_P(SetAndClear)
+BITMASK_TEST_P(SetAndClear) //NOLINT(misc-definitions-in-headers)
 {
     gmx_bitmask_t m;
     int           i = GetParam();
@@ -74,7 +74,7 @@ BITMASK_TEST_P(SetAndClear)
     EXPECT_TRUE(bitmask_is_zero(m));
 }
 
-BITMASK_TEST_P(InitBit)
+BITMASK_TEST_P(InitBit) //NOLINT(misc-definitions-in-headers)
 {
     gmx_bitmask_t m1, m2;
     int           i = GetParam();
@@ -85,7 +85,7 @@ BITMASK_TEST_P(InitBit)
     EXPECT_TRUE(bitmask_is_equal(m1, m2));
 }
 
-BITMASK_TEST_P(InitLowBits)
+BITMASK_TEST_P(InitLowBits) //NOLINT(misc-definitions-in-headers)
 {
     gmx_bitmask_t m;
     int           i = GetParam();
@@ -96,7 +96,7 @@ BITMASK_TEST_P(InitLowBits)
     }
 }
 
-BITMASK_TEST_P(Disjoint)
+BITMASK_TEST_P(Disjoint) //NOLINT(misc-definitions-in-headers)
 {
     gmx_bitmask_t m1, m2;
     int           i = GetParam();
@@ -107,7 +107,7 @@ BITMASK_TEST_P(Disjoint)
     EXPECT_TRUE(bitmask_is_disjoint(m1, m2));
 }
 
-BITMASK_TEST_P(Union)
+BITMASK_TEST_P(Union) //NOLINT(misc-definitions-in-headers)
 {
     gmx_bitmask_t m1, m2;
     int           i = GetParam();
index 4fbc0ad947d27d44995105fdae49afd3823b2d4e..2cc6990c152573ec82bf0a55979ac35e1ce6e1f8 100644 (file)
@@ -94,9 +94,9 @@ TEST(MutexBasicTest, CanBeUsedInLockGuard)
 }
 
 //! A shared value for a mutex to protect
-static int   g_sharedValue;
+int   g_sharedValue;
 //! A mutex to protect a shared value
-static Mutex g_sharedValueMutex;
+Mutex g_sharedValueMutex;
 
 //! Function type for asynchronous tasks.
 using TaskType = std::function<int(void)>;
index 8a5c3278a2575e9ea1ca648ce2589f18640ac36a..1d56da89b96de64c5a7acc62cbf95f49981fbdf5 100644 (file)
@@ -215,8 +215,8 @@ int Mdrunner::mainFunction(int argc, char *argv[])
         "exceeds [TT]-maxh[tt]\\*0.99 hours. This option is particularly useful in",
         "combination with setting [TT]nsteps[tt] to -1 either in the mdp or using the",
         "similarly named command line option. This results in an infinite run,",
-        "terminated only when the time limit set by [TT]-maxh[tt] is reached (if any)"
-        "or upon receiving a signal."
+        "terminated only when the time limit set by [TT]-maxh[tt] is reached (if any)",
+        "or upon receiving a signal.",
         "[PAR]",
         "When [TT]mdrun[tt] receives a TERM or INT signal (e.g. when ctrl+C is",
         "pressed), it will stop at the next neighbor search step or at the",
@@ -239,7 +239,7 @@ int Mdrunner::mainFunction(int argc, char *argv[])
         "IMD remote can be turned on by [TT]-imdpull[tt].",
         "The port [TT]mdrun[tt] listens to can be altered by [TT]-imdport[tt].The",
         "file pointed to by [TT]-if[tt] contains atom indices and forces if IMD",
-        "pulling is used."
+        "pulling is used.",
         "[PAR]",
         "When [TT]mdrun[tt] is started with MPI, it does not run niced by default."
     };
@@ -499,9 +499,9 @@ int Mdrunner::mainFunction(int argc, char *argv[])
 
     domdecOptions.rankOrder    = static_cast<DdRankOrder>(nenum(ddrank_opt_choices));
     domdecOptions.dlbOption    = static_cast<DlbOption>(nenum(dddlb_opt_choices));
-    domdecOptions.numCells[XX] = (int)(realddxyz[XX] + 0.5);
-    domdecOptions.numCells[YY] = (int)(realddxyz[YY] + 0.5);
-    domdecOptions.numCells[ZZ] = (int)(realddxyz[ZZ] + 0.5);
+    domdecOptions.numCells[XX] = static_cast<int>(realddxyz[XX] + 0.5);
+    domdecOptions.numCells[YY] = static_cast<int>(realddxyz[YY] + 0.5);
+    domdecOptions.numCells[ZZ] = static_cast<int>(realddxyz[ZZ] + 0.5);
 
     nbpu_opt    = nbpu_opt_choices[0];
     pme_opt     = pme_opt_choices[0];
index 2069aaaeb7f6603277e32b197cbd9066c729ad23..91a742424ff37c4ff6e709aa5e3477e8926859ae 100644 (file)
@@ -94,7 +94,7 @@ openEnergyFileToReadFields(const std::string              &filename,
             auto        requiredEnergy = std::find_if(std::begin(namesOfRequiredEnergyFields),
                                                       std::end(namesOfRequiredEnergyFields),
                                                       [name](const std::string &n){
-                                                          return 0 == n.compare(name);
+                                                          return name == n;
                                                       });
             if (requiredEnergy != namesOfRequiredEnergyFields.end())
             {
index 8441ef7a7344657725e592cbe0c385cc9c21f6a0..9b3e4c1afe4cfab01d570a950c329f36650e6209 100644 (file)
@@ -124,7 +124,7 @@ TEST_P(InitialConstraintsTest, Works)
 }
 
 //! Integrators with energy conservation to test
-static const EnergyIntegratorType c_integratorsToTest [] = {"md", "md-vv", "md-vv-avek"};
+const EnergyIntegratorType c_integratorsToTest [] = {"md", "md-vv", "md-vv-avek"};
 
 INSTANTIATE_TEST_CASE_P(Checking, InitialConstraintsTest, ::testing::ValuesIn(c_integratorsToTest));
 
index de04f7f7b963893a7b823b034b7fc7177880306c..aeed2e7cf340fc7a15d2414ee25bfd66ab4ac964 100644 (file)
@@ -92,10 +92,6 @@ GMX_TEST_OPTIONS(MdrunTestOptions, options)
 }
 
 SimulationRunner::SimulationRunner(TestFileManager *fileManager) :
-    topFileName_(),
-    groFileName_(),
-    fullPrecisionTrajectoryFileName_(),
-    ndxFileName_(),
     mdpOutputFileName_(fileManager->getTemporaryFilePath("output.mdp")),
     tprFileName_(fileManager->getTemporaryFilePath(".tpr")),
     logFileName_(fileManager->getTemporaryFilePath(".log")),
@@ -143,15 +139,15 @@ SimulationRunner::useStringAsNdxFile(const char *ndxString)
 void
 SimulationRunner::useTopGroAndNdxFromDatabase(const char *name)
 {
-    topFileName_ = fileManager_.getInputFilePath((std::string(name) + ".top").c_str());
-    groFileName_ = fileManager_.getInputFilePath((std::string(name) + ".gro").c_str());
-    ndxFileName_ = fileManager_.getInputFilePath((std::string(name) + ".ndx").c_str());
+    topFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".top").c_str());
+    groFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".gro").c_str());
+    ndxFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".ndx").c_str());
 }
 
 void
 SimulationRunner::useGroFromDatabase(const char *name)
 {
-    groFileName_ = fileManager_.getInputFilePath((std::string(name) + ".gro").c_str());
+    groFileName_ = gmx::test::TestFileManager::getInputFilePath((std::string(name) + ".gro").c_str());
 }
 
 int
index bfa3378a3fea0362cafb15aa64840c55a403d16d..add40e2a6debf27e5d4b4e949d953c41da822a29 100644 (file)
@@ -68,8 +68,8 @@ namespace test
 
 MultiSimTest::MultiSimTest() : size_(gmx_node_num()),
                                rank_(gmx_node_rank()),
-                               mdrunCaller_(new CommandLine),
-                               fileManager_()
+                               mdrunCaller_(new CommandLine)
+
 {
     const char *directoryNameFormat = "sim_%d";
 
index 84368cee16e1e69b95a30946c784c6c547e34d75..598828cf4f42689219c6497729f87770724303ad 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -68,7 +68,7 @@ TEST_P(MdrunRerun, WithDifferentInputFormats)
     runner_.useTopGroAndNdxFromDatabase("spc2");
     EXPECT_EQ(0, runner_.callGrompp());
 
-    std::string rerunFileName = fileManager_.getInputFilePath(GetParam());
+    std::string rerunFileName = gmx::test::TestFileManager::getInputFilePath(GetParam());
 
     ::gmx::test::CommandLine rerunCaller;
     rerunCaller.append("mdrun");
index 4e18b667f8f470bff7bbec7aaac50aa0bc9de5b8..794b342666b25122fb19a3194e0cdcc7205fdce1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -57,7 +57,7 @@ namespace test
 {
 
 //! Format string for building a configurable .top file
-const char *g_butaneTopFileFormatString = "\
+static const char *g_butaneTopFileFormatString = "\
 [ defaults ]\n\
 ; nbfunc       comb-rule       gen-pairs       fudgeLJ fudgeQQ\n\
   1            1               no              1.0     1.0\n\
@@ -98,8 +98,8 @@ class BondedInteractionsTest : public gmx::test::MdrunTestFixture
         {
             runner_.topFileName_ = fileManager_.getTemporaryFilePath("butane1.top");
             TextWriter::writeFileFromString(runner_.topFileName_, formatString(g_butaneTopFileFormatString, interaction));
-            runner_.groFileName_ = fileManager_.getInputFilePath("butane1.gro");
-            runner_.ndxFileName_ = fileManager_.getInputFilePath("butane1.ndx");
+            runner_.groFileName_ = gmx::test::TestFileManager::getInputFilePath("butane1.gro");
+            runner_.ndxFileName_ = gmx::test::TestFileManager::getInputFilePath("butane1.ndx");
             /* TODO Now that Verlet is the default, change the implementation
                of useEmptyMdpFile() to do that. */
             runner_.useStringAsMdpFile("");
@@ -142,7 +142,7 @@ TEST_F(BondedInteractionsTest, TabulatedBondWorks)
     EXPECT_EQ(0, runner_.callGrompp());
 
     test::CommandLine rerunCaller   = setupMdrun();
-    std::string       tableFileName = fileManager_.getInputFilePath("butane_b0.xvg");
+    std::string       tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_b0.xvg");
     rerunCaller.addOption("-tableb", tableFileName);
     ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
     checkMdrun();
@@ -170,7 +170,7 @@ TEST_F(BondedInteractionsTest, TabulatedAngleWorks)
     EXPECT_EQ(0, runner_.callGrompp());
 
     test::CommandLine rerunCaller   = setupMdrun();
-    std::string       tableFileName = fileManager_.getInputFilePath("butane_a0.xvg");
+    std::string       tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_a0.xvg");
     rerunCaller.addOption("-tableb", tableFileName);
     ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
     checkMdrun();
@@ -198,7 +198,7 @@ TEST_F(BondedInteractionsTest, TabulatedDihedralWorks)
     EXPECT_EQ(0, runner_.callGrompp());
 
     test::CommandLine rerunCaller   = setupMdrun();
-    std::string       tableFileName = fileManager_.getInputFilePath("butane_d0.xvg");
+    std::string       tableFileName = gmx::test::TestFileManager::getInputFilePath("butane_d0.xvg");
     rerunCaller.addOption("-tableb", tableFileName);
     ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
     checkMdrun();
index 70a56342a959f94306377db2971f4f2ebdbf2e25..db16d0c93b2ee11a5f42b512759b8e8371452678 100644 (file)
@@ -75,7 +75,7 @@ void TpiTest::runTest()
     runner_.ndxFileName_ = "";
     ASSERT_EQ(0, runner_.callGrompp());
 
-    auto        rerunFileName = fileManager_.getInputFilePath("spc216.gro");
+    auto        rerunFileName = gmx::test::TestFileManager::getInputFilePath("spc216.gro");
     CommandLine commandLine;
     commandLine.append("-rerun");
     commandLine.append(rerunFileName);
index 4204f7a7cd2bf46ff50bcd162b6beb19fb35c457..9fc88f3c98baf64a5601604daf9b408af1df7ff0 100644 (file)
@@ -83,6 +83,13 @@ function (gmx_add_gtest_executable EXENAME)
             APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
         set_property(TARGET ${EXENAME}
             APPEND PROPERTY COMPILE_DEFINITIONS "${EXTRA_COMPILE_DEFINITIONS}")
+        if(GMX_CLANG_TIDY)
+            set_target_properties(${EXENAME} PROPERTIES CXX_CLANG_TIDY
+                "${CLANG_TIDY_EXE};-warnings-as-errors=*;-header-filter=.*")
+        endif()
+        if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
+            target_compile_options(${EXENAME} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-zero-as-null-pointer-constant -Wno-missing-variable-declarations>)
+        endif()
     endif()
 endfunction()
 
index b88b3138bbb73bfbd8e14c873c58aadc2d9772a0..c2cdc40520734e132782066db68231deefa73f82 100644 (file)
@@ -319,8 +319,8 @@ int CommandLineTestHelper::runModuleDirect(
 
 // static
 int CommandLineTestHelper::runModuleFactory(
-        std::function<std::unique_ptr<ICommandLineOptionsModule>()>  factory,
-        CommandLine                                                 *commandLine)
+        const std::function<std::unique_ptr<ICommandLineOptionsModule>()> &factory,
+        CommandLine                                                       *commandLine)
 {
     return runModuleDirect(factory(), commandLine);
 }
index 7d9204625f9ca52f885ecffd1cc5657b8808b960..c488dc6af1ebd943f4ef89b4d3979d8f20bb47a7 100644 (file)
@@ -258,8 +258,8 @@ class CommandLineTestHelper
          *     module.
          */
         static int
-        runModuleFactory(std::function<std::unique_ptr<ICommandLineOptionsModule>()>  factory,
-                         CommandLine                                                 *commandLine);
+        runModuleFactory(const std::function<std::unique_ptr<ICommandLineOptionsModule>()> &factory,
+                         CommandLine                                                       *commandLine);
 
         /*! \brief
          * Initializes an instance.
index dc591eea3a1ad2448753ca3742ccb4691ef451b8..e98dfd0cc8cacfd4eeee876f69f7ff94b3b39eba 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -83,7 +83,7 @@ class ConfMatcher : public ITextBlockMatcher
 
 void checkConfFile(TextInputStream         *input,
                    TestReferenceChecker    *checker,
-                   const ConfMatchSettings  &)
+                   const ConfMatchSettings  & /*unused*/)
 {
 
     TestReferenceChecker groChecker(checker->checkCompound("GroFile", "Header"));
index 0944b066dbbd545b75e322f74528cd29551bbe6a..5874e9dc9160b2bb624f7a5fe45fdf93aa8f365c 100644 (file)
@@ -44,6 +44,7 @@
 #include "interactivetest.h"
 
 #include <string>
+#include <utility>
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -83,7 +84,7 @@ class InteractiveTestHelper::Impl
 {
     public:
         explicit Impl(TestReferenceChecker checker)
-            : checker_(checker), bLastNewline_(true),
+            : checker_(std::move(checker)), bLastNewline_(true),
               currentLine_(0), bHasOutput_(false)
         {
             using ::testing::_;
index 9a5c4fd0a4ae145532b1beb1db5ae5f0cca3949a..2b35b9283b557d987cde16754b5dbff4c4c4cf63 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -78,9 +78,9 @@ class IReferenceDataEntryChecker
 class NullChecker : public IReferenceDataEntryChecker
 {
     public:
-        virtual void fillEntry(ReferenceDataEntry *) const {}
+        virtual void fillEntry(ReferenceDataEntry * /*entry*/) const {}
         virtual ::testing::AssertionResult
-        checkEntry(const ReferenceDataEntry &, const std::string &) const
+        checkEntry(const ReferenceDataEntry & /*entry*/, const std::string & /*fullId*/) const
         {
             return ::testing::AssertionSuccess();
         }
@@ -240,12 +240,12 @@ class ValueExtractor : public IReferenceDataEntryChecker
         {
         }
 
-        virtual void fillEntry(ReferenceDataEntry *) const
+        virtual void fillEntry(ReferenceDataEntry * /*entry*/) const
         {
             GMX_THROW(TestException("Extracting value from non-existent reference data entry"));
         }
         virtual ::testing::AssertionResult
-        checkEntry(const ReferenceDataEntry &entry, const std::string &) const
+        checkEntry(const ReferenceDataEntry &entry, const std::string & /*fullId*/) const
         {
             extractValue(entry.value());
             return ::testing::AssertionSuccess();
index 144668763cd4fe7d8e8400b51ec759f7f5fc9e24..440607dc58672aab820943b7dee1f20825ae7931 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -46,6 +46,7 @@
 #include <memory>
 #include <string>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/utility/gmxassert.h"
 
 namespace gmx
@@ -62,7 +63,7 @@ class ReferenceDataEntry
 
         static EntryPointer createRoot()
         {
-            return EntryPointer(new ReferenceDataEntry("", ""));
+            return gmx::compat::make_unique<ReferenceDataEntry>("", "");
         }
 
         ReferenceDataEntry(const char *type, const char *id)
index 8cdd31cb3531838b5bab17dbe13a998b9b803215..e0526def22625e141b2a94f61c26103177dfab6c 100644 (file)
@@ -199,7 +199,7 @@ class ReferenceDataTestEventListener : public ::testing::EmptyTestEventListener
             }
         }
 
-        virtual void OnTestProgramEnd(const ::testing::UnitTest &)
+        virtual void OnTestProgramEnd(const ::testing::UnitTest & /*unused*/)
         {
             // Could be used e.g. to free internal buffers allocated by an XML parsing library
         }
@@ -726,13 +726,13 @@ TestReferenceChecker::TestReferenceChecker(const TestReferenceChecker &other)
 {
 }
 
-TestReferenceChecker::TestReferenceChecker(TestReferenceChecker &&other)
+TestReferenceChecker::TestReferenceChecker(TestReferenceChecker &&other) noexcept
     : impl_(std::move(other.impl_))
 {
 }
 
 TestReferenceChecker &
-TestReferenceChecker::operator=(TestReferenceChecker &&other)
+TestReferenceChecker::operator=(TestReferenceChecker &&other) noexcept
 {
     impl_ = std::move(other.impl_);
     return *this;
index fb4dd712a187c359a23837830e9cb7ae7b9cfcab..f6a12445f3c3f6e83667ce0a747a1a9c9d8659fa 100644 (file)
@@ -252,13 +252,13 @@ class TestReferenceChecker
         //! Creates a deep copy of the other checker.
         explicit TestReferenceChecker(const TestReferenceChecker &other);
         //! Moves the checker.
-        TestReferenceChecker(TestReferenceChecker &&other);
+        TestReferenceChecker(TestReferenceChecker &&other) noexcept;
         ~TestReferenceChecker();
 
         //! Prevents implicit copying during assignment.
         TestReferenceChecker &operator=(const TestReferenceChecker &) = delete;
         //! Assigns a test reference checker.
-        TestReferenceChecker &operator=(TestReferenceChecker &&other);
+        TestReferenceChecker &operator=(TestReferenceChecker &&other) noexcept;
 
         //! Returns whether the checker is initialized.
         bool isValid() const;
index 1d8be9cd7dfa3aa45affc418df907d30c3f21e55..c7990838d420ada60beadb9f01b5b63ed11f5af9 100644 (file)
@@ -279,12 +279,7 @@ bool FloatingPointTolerance::isWithin(
 
     const uint64_t ulpTolerance
         = difference.isDouble() ? doubleUlpTolerance_ : singleUlpTolerance_;
-    if (ulpTolerance < UINT64_MAX && difference.asUlps() <= ulpTolerance)
-    {
-        return true;
-    }
-
-    return false;
+    return ulpTolerance < UINT64_MAX && difference.asUlps() <= ulpTolerance;
 }
 
 std::string FloatingPointTolerance::toString(const FloatingPointDifference &difference) const
index 2add34ba1322ead5f6ca4408716fe538059ef088..8e6b2e4d9760575fe671a55938f2696d8b13f136 100644 (file)
@@ -486,10 +486,10 @@ relativeToleranceAsUlp(double magnitude, uint64_t ulpDiff)
     return relativeToleranceAsPrecisionDependentUlp(magnitude, ulpDiff, ulpDiff);
 }
 
-namespace
+namespace detail
 {
 //! Default tolerance in ULPs for two floating-point values to compare equal.
-static uint64_t g_defaultUlpTolerance = 4;
+constexpr uint64_t g_defaultUlpTolerance = 4;
 }
 
 /*! \brief
@@ -499,7 +499,7 @@ static uint64_t g_defaultUlpTolerance = 4;
  */
 static inline FloatingPointTolerance defaultRealTolerance()
 {
-    return relativeToleranceAsUlp(1.0, g_defaultUlpTolerance);
+    return relativeToleranceAsUlp(1.0, detail::g_defaultUlpTolerance);
 }
 
 
@@ -515,7 +515,7 @@ static inline FloatingPointTolerance defaultRealTolerance()
 static inline FloatingPointTolerance defaultFloatTolerance()
 {
     return relativeToleranceAsPrecisionDependentUlp
-               (1.0, g_defaultUlpTolerance, g_defaultUlpTolerance * (GMX_FLOAT_EPS / GMX_DOUBLE_EPS));
+               (1.0, detail::g_defaultUlpTolerance, detail::g_defaultUlpTolerance * (GMX_FLOAT_EPS / GMX_DOUBLE_EPS));
 }
 
 /*! \name Assertions for floating-point comparison
index e7a2e90ba2d08e5ad06ee2d02947585b7feb024c..882931b1286f5785da22daa920c2522bb09e869f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -56,6 +56,7 @@
 #include "gromacs/commandline/cmdlineinit.h"
 #include "gromacs/commandline/cmdlineparser.h"
 #include "gromacs/commandline/cmdlineprogramcontext.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/math/utilities.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/options.h"
@@ -185,7 +186,7 @@ void initTestUtils(const char *dataPath, const char *tempPath, bool usesMpi,
         {
             callAddGlobalTestEnvironment();
         }
-        g_testContext.reset(new TestProgramContext(context));
+        g_testContext = gmx::compat::make_unique<TestProgramContext>(context);
         setProgramContext(g_testContext.get());
         // Use the default finder that does not respect GMXLIB, since the tests
         // generally can only get confused by a different set of data files.
index 62dd76926f0ccd6d56543d092ae2cba0b2589884..553baffe92b13d3e5554464c9a515ce60366645c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -163,21 +163,21 @@ void initTestOptions(IOptionsContainer *options);
  */
 /* *INDENT-ON* */
 #define GMX_TEST_OPTIONS(name, options) \
-    class name : public ::gmx::test::TestOptionsProvider \
+    class name : public ::gmx::test::TestOptionsProvider /*NOLINT(misc-macro-parentheses)*/ \
     { \
         public: \
             name() \
             { \
                 ::gmx::test::registerTestOptions(#name, this); \
             } \
-            virtual void initOptions(::gmx::IOptionsContainer *options); \
+            virtual void initOptions(::gmx::IOptionsContainer *(options)); \
     }; \
     \
     static name s_ ## name ## Instance; \
     \
-    void name::initOptions(::gmx::IOptionsContainer *options)
+    void name::initOptions(::gmx::IOptionsContainer *options) //NOLINT(misc-macro-parentheses)
 
-} // namespace test
-} // namespace gmx
+}                                                             // namespace test
+}                                                             // namespace gmx
 
 #endif