* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2016,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
ValueType& operator[](int i) { return x_[i]; }
//! Indexing operator to make the class work as the raw array.
ValueType operator[](int i) const { return x_[i]; }
+ //! Return whether all elements compare equal
+ bool operator==(const BasicVector<ValueType>& right)
+ {
+ return x_[0] == right[0] && x_[1] == right[1] && x_[2] == right[2];
+ }
+ //! Return whether any elements compare unequal
+ bool operator!=(const BasicVector<ValueType>& right)
+ {
+ return x_[0] != right[0] || x_[1] != right[1] || x_[2] != right[2];
+ }
//! Allow inplace addition for BasicVector
BasicVector<ValueType>& operator+=(const BasicVector<ValueType>& right)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2016,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2018,2019,2021, 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.
EXPECT_EQ(4, r[1][ZZ]);
}
+TEST(RVecTest, ComparesEqual)
+{
+ RVec a(1, 2, 3);
+ RVec b(1, 2, 3);
+ RVec c(1, 2, 2);
+ EXPECT_EQ(a == b, true);
+ EXPECT_EQ(a == c, false);
+}
+
+TEST(RVecTest, ComparesUnequal)
+{
+ RVec a(1, 2, 3);
+ RVec b(1, 2, 3);
+ RVec c(1, 2, 2);
+ EXPECT_EQ(a != b, false);
+ EXPECT_EQ(a != c, true);
+}
+
/*! \brief
* Test overloaded math operations
*/