#include "gromacs/topology/block.h"
#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/listoflists.h"
#include "gromacs/utility/smalloc.h"
#include "testutils/cmdlinetest.h"
addGroupToBlocka(ba, indices);
}
+//! Return ListOfLists filled with some datastructures
+ListOfLists<int> makeTestListOfLists()
+{
+ ListOfLists<int> list;
+
+ std::vector<int> indices = { 12, 11, 9, 6, 2 };
+ list.pushBack(indices);
+ indices = { 10, 8, 5, 1 };
+ list.pushBack(indices);
+ indices = { 7, 4, 0 };
+ list.pushBack(indices);
+
+ return list;
+}
+
class ExclusionBlockTest : public ::testing::Test
{
public:
{
const int natom = 3;
makeTestBlockAData(&ba_);
+ list_ = makeTestListOfLists();
b_.resize(natom);
}
~ExclusionBlockTest() override { done_blocka(&ba_); }
}
}
+ void compareBlocksAndList()
+ {
+ GMX_RELEASE_ASSERT(ssize(b_) == list_.ssize(), "The list counts should match");
+ for (index i = 0; i < ssize(b_); i++)
+ {
+ gmx::ArrayRef<const int> jList = list_[i];
+ EXPECT_EQ(b_[i].nra(), jList.ssize()) << "Block size mismatch at " << i << ".";
+ for (int j = 0; j < b_[i].nra(); j++)
+ {
+ EXPECT_EQ(b_[i].atomNumber[j], jList[j]) << "Block mismatch at " << i << " , " << j << ".";
+ }
+ }
+ }
+
protected:
t_blocka ba_;
+ ListOfLists<int> list_;
std::vector<ExclusionBlock> b_;
};
TEST_F(ExclusionBlockTest, MergeExclusions)
{
- mergeExclusions(&ba_, b_);
- compareBlocks();
+ mergeExclusions(&list_, b_);
+ compareBlocksAndList();
}
} // namespace