Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / selection / tests / poscalc.cpp
index 40ffa76ef4514af4761dfd485c8396f7115bc032..1608a5b11b599847c823f1db12454413dfca30ca 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2013,2014, 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
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_selection
  */
-#include <gtest/gtest.h>
+#include "gmxpre.h"
+
+#include "gromacs/selection/poscalc.h"
 
 #include <vector>
 
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/typedefs.h"
-#include "gromacs/legacyheaders/vec.h"
+#include <gtest/gtest.h>
 
+#include "gromacs/fileio/trx.h"
+#include "gromacs/math/vec.h"
 #include "gromacs/selection/indexutil.h"
-#include "gromacs/selection/poscalc.h"
 #include "gromacs/selection/position.h"
+#include "gromacs/topology/topology.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/uniqueptr.h"
 
 #include "testutils/refdata.h"
 
@@ -121,16 +125,17 @@ class PositionCalculationTest : public ::testing::Test
         gmx::PositionCalculationCollection  pcc_;
 
     private:
+        typedef gmx::gmx_unique_ptr<gmx_ana_pos_t>::type PositionPointer;
+
         struct PositionTest
         {
-            PositionTest() : pos(NULL), pc(NULL), name(NULL) {}
-            PositionTest(gmx_ana_pos_t *pos, gmx_ana_poscalc_t *pc,
+            PositionTest(PositionPointer pos, gmx_ana_poscalc_t *pc,
                          const char *name)
-                : pos(pos), pc(pc), name(name)
+                : pos(gmx::move(pos)), pc(pc), name(name)
             {
             }
 
-            gmx_ana_pos_t                  *pos;
+            PositionPointer                 pos;
             gmx_ana_poscalc_t              *pc;
             const char                     *name;
         };
@@ -160,12 +165,6 @@ PositionCalculationTest::~PositionCalculationTest()
     {
         gmx_ana_poscalc_free(*pci);
     }
-
-    PositionTestList::iterator pi;
-    for (pi = posList_.begin(); pi != posList_.end(); ++pi)
-    {
-        gmx_ana_pos_free(pi->pos);
-    }
 }
 
 void PositionCalculationTest::generateCoordinates()
@@ -212,11 +211,11 @@ gmx_ana_pos_t *
 PositionCalculationTest::initPositions(gmx_ana_poscalc_t *pc, const char *name)
 {
     posList_.reserve(posList_.size() + 1);
-    gmx_ana_pos_t *p;
-    snew(p, 1);
-    posList_.push_back(PositionTest(p, pc, name));
-    gmx_ana_poscalc_init_pos(pc, p);
-    return p;
+    PositionPointer p(new gmx_ana_pos_t());
+    gmx_ana_pos_t  *result = p.get();
+    posList_.push_back(PositionTest(gmx::move(p), pc, name));
+    gmx_ana_poscalc_init_pos(pc, result);
+    return result;
 }
 
 void PositionCalculationTest::checkInitialized()
@@ -226,7 +225,7 @@ void PositionCalculationTest::checkInitialized()
     PositionTestList::const_iterator pi;
     for (pi = posList_.begin(); pi != posList_.end(); ++pi)
     {
-        checkPositions(&compound, pi->name, pi->pos, false);
+        checkPositions(&compound, pi->name, pi->pos.get(), false);
     }
 }