/*
* 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"
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;
};
{
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()
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()
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);
}
}