Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / random / tests / threefry.cpp
index 7afd82665c2969b64120d8eb81892fb7805f9cb5..a31e6ead193dac9b32ffc6ee3139e5e8e708fca4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018,2019, 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.
@@ -55,18 +55,18 @@ namespace gmx
 namespace
 {
 
-class ThreeFry2x64Test : public ::testing::TestWithParam<std::vector<uint64_t> >
+class ThreeFry2x64Test : public ::testing::TestWithParam<std::vector<uint64_t>>
 {
 };
 
 TEST_P(ThreeFry2x64Test, Default)
 {
-    gmx::test::TestReferenceData       data;
-    gmx::test::TestReferenceChecker    checker(data.rootChecker());
-    const std::vector<uint64_t>        input = GetParam();
-    std::vector<uint64_t>              result;
+    gmx::test::TestReferenceData    data;
+    gmx::test::TestReferenceChecker checker(data.rootChecker());
+    const std::vector<uint64_t>     input = GetParam();
+    std::vector<uint64_t>           result;
 
-    gmx::ThreeFry2x64<0>               rng(input[2], input[3]);
+    gmx::ThreeFry2x64<0> rng(input[2], input[3]);
     rng.restart(input[0], input[1]);
 
     result.push_back(rng());
@@ -77,12 +77,12 @@ TEST_P(ThreeFry2x64Test, Default)
 
 TEST_P(ThreeFry2x64Test, Fast)
 {
-    gmx::test::TestReferenceData       data;
-    gmx::test::TestReferenceChecker    checker(data.rootChecker());
-    const std::vector<uint64_t>        input = GetParam();
-    std::vector<uint64_t>              result;
+    gmx::test::TestReferenceData    data;
+    gmx::test::TestReferenceChecker checker(data.rootChecker());
+    const std::vector<uint64_t>     input = GetParam();
+    std::vector<uint64_t>           result;
 
-    gmx::ThreeFry2x64Fast<0>           rng(input[2], input[3]);
+    gmx::ThreeFry2x64Fast<0> rng(input[2], input[3]);
     rng.restart(input[0], input[1]);
 
     result.push_back(rng());
@@ -93,12 +93,12 @@ TEST_P(ThreeFry2x64Test, Fast)
 
 TEST_P(ThreeFry2x64Test, Using40Rounds)
 {
-    gmx::test::TestReferenceData       data;
-    gmx::test::TestReferenceChecker    checker(data.rootChecker());
-    const std::vector<uint64_t>        input = GetParam();
-    std::vector<uint64_t>              result;
+    gmx::test::TestReferenceData    data;
+    gmx::test::TestReferenceChecker checker(data.rootChecker());
+    const std::vector<uint64_t>     input = GetParam();
+    std::vector<uint64_t>           result;
 
-    gmx::ThreeFry2x64General<40, 0>    rng(input[2], input[3]);
+    gmx::ThreeFry2x64General<40, 0> rng(input[2], input[3]);
     rng.restart(input[0], input[1]);
 
     result.push_back(rng());
@@ -114,9 +114,7 @@ TEST_P(ThreeFry2x64Test, Using40Rounds)
  *  The 2x64 flavors of ThreeFry64 will use the first four values, while
  *  the 4x64 version uses all eight.
  */
-const std::vector<uint64_t> bitsZero {{
-                                          0, 0, 0, 0
-                                      }};
+const std::vector<uint64_t> bitsZero{ { 0, 0, 0, 0 } };
 
 
 /*! \brief Constant array of integers with all bits set to one.
@@ -125,10 +123,8 @@ const std::vector<uint64_t> bitsZero {{
  *  The 2x64 flavors of ThreeFry64 will use the first four values, while
  *  the 4x64 version uses all eight.
  */
-const std::vector<uint64_t> bitsOne {{
-                                         0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,
-                                         0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL
-                                     }};
+const std::vector<uint64_t> bitsOne{ { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,
+                                       0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL } };
 
 /*! \brief Constant array of integers with bitpattern from Pi.
  *
@@ -136,15 +132,12 @@ const std::vector<uint64_t> bitsOne {{
  *  The 2x64 flavors of ThreeFry64 will use the first four values, while
  *  the 4x64 version uses all eight.
  */
-const std::vector<uint64_t> bitsPi {{
-                                        0x243f6a8885a308d3ULL, 0x13198a2e03707344ULL,
-                                        0xa4093822299f31d0ULL, 0x082efa98ec4e6c89ULL
-                                    }};
+const std::vector<uint64_t> bitsPi{ { 0x243f6a8885a308d3ULL, 0x13198a2e03707344ULL,
+                                      0xa4093822299f31d0ULL, 0x082efa98ec4e6c89ULL } };
 
 // Test the known ansers for the ThreeFry random function when the argument
 // is (1) all zero, (2) all ones, (3) the bits of pi, for a bunch of different flavors of ThreeFry.
-INSTANTIATE_TEST_CASE_P(KnownAnswersTest, ThreeFry2x64Test,
-                            ::testing::Values(bitsZero, bitsOne, bitsPi));
+INSTANTIATE_TEST_CASE_P(KnownAnswersTest, ThreeFry2x64Test, ::testing::Values(bitsZero, bitsOne, bitsPi));
 
 
 // ThreeFry2x64 tests
@@ -154,9 +147,10 @@ TEST_F(ThreeFry2x64Test, Logical)
     gmx::ThreeFry2x64<10> rngB(123456, gmx::RandomDomain::Other);
     gmx::ThreeFry2x64<10> rngC(123456, gmx::RandomDomain::Other);
 
-    rngB();              // draw just once first, so block is the same, but index has changed
+    rngB(); // draw just once first, so block is the same, but index has changed
     EXPECT_NE(rngA, rngB);
-    rngC(); rngC();      // two draws: next block, but index is the same
+    rngC();
+    rngC(); // two draws: next block, but index is the same
     EXPECT_NE(rngA, rngC);
     rngA();
     EXPECT_EQ(rngA, rngB);
@@ -166,13 +160,13 @@ TEST_F(ThreeFry2x64Test, Logical)
 
 TEST_F(ThreeFry2x64Test, InternalCounterSequence)
 {
-    gmx::test::TestReferenceData     data;
-    gmx::test::TestReferenceChecker  checker(data.rootChecker());
+    gmx::test::TestReferenceData    data;
+    gmx::test::TestReferenceChecker checker(data.rootChecker());
 
     // 66 bits of internal counter means the first four increments (giving 2*4=8 results)
     // correspond to incrementing word 0, and then we should carry over to word 1.
-    gmx::ThreeFry2x64<66>        rngA(123456, gmx::RandomDomain::Other);
-    std::vector<uint64_t>        result;
+    gmx::ThreeFry2x64<66> rngA(123456, gmx::RandomDomain::Other);
+    std::vector<uint64_t> result;
 
     result.reserve(16);
     for (int i = 0; i < 16; i++)
@@ -182,14 +176,14 @@ TEST_F(ThreeFry2x64Test, InternalCounterSequence)
     checker.checkSequence(result.begin(), result.end(), "ThreeFry2x64InternalCounterSequence");
 
     // Make sure nothing goes wrong with the internal counter sequence when we use a full 64-bit word
-    gmx::ThreeFry2x64<64>        rngB(123456, gmx::RandomDomain::Other);
+    gmx::ThreeFry2x64<64> rngB(123456, gmx::RandomDomain::Other);
     for (int i = 0; i < 16; i++)
     {
         rngB();
     }
 
     // Use every single bit for the internal counter
-    gmx::ThreeFry2x64<128>        rngC(123456, gmx::RandomDomain::Other);
+    gmx::ThreeFry2x64<128> rngC(123456, gmx::RandomDomain::Other);
     for (int i = 0; i < 16; i++)
     {
         rngC();
@@ -244,6 +238,6 @@ TEST_F(ThreeFry2x64Test, ExhaustInternalCounter)
     EXPECT_THROW_GMX(rngA(), gmx::InternalError);
 }
 
-}  // namespace
+} // namespace
 
-}  // namespace gmx
+} // namespace gmx