typedef gmx::test::AnalysisDataTestFixture SimpleHistogramModuleTest;
// Input data for the tests below.
-using gmx::test::END_OF_DATA;
using gmx::test::END_OF_FRAME;
using gmx::test::MPSTOP;
static const real simpleinputdata[] = {
1.0, 0.7, MPSTOP, 1.1, MPSTOP, 2.3, MPSTOP, 2.9, END_OF_FRAME,
2.0, 1.3, MPSTOP, 2.2, END_OF_FRAME,
- 3.0, 3.3, MPSTOP, 1.2, MPSTOP, 1.3, END_OF_FRAME,
- END_OF_DATA
+ 3.0, 3.3, MPSTOP, 1.2, MPSTOP, 1.3, END_OF_FRAME
};
TEST_F(SimpleHistogramModuleTest, ComputesCorrectly)
static const real weightedinputdata[] = {
1.0, 0.7, 0.5, MPSTOP, 1.1, 1.0, MPSTOP, 2.3, 1.0, MPSTOP, 2.9, 2.0, END_OF_FRAME,
2.0, 1.3, 1.0, MPSTOP, 2.2, 3.0, END_OF_FRAME,
- 3.0, 3.3, 0.5, MPSTOP, 1.2, 2.0, MPSTOP, 1.3, 1.0, END_OF_FRAME,
- END_OF_DATA
+ 3.0, 3.3, 0.5, MPSTOP, 1.2, 2.0, MPSTOP, 1.3, 1.0, END_OF_FRAME
};
TEST_F(WeightedHistogramModuleTest, ComputesCorrectly)
2.5, 4.0, 2.0, END_OF_FRAME,
3.0, 2.0, 1.0, END_OF_FRAME,
3.5, 0.0, 3.0, END_OF_FRAME,
- 4.0, 1.0, 3.0, END_OF_FRAME,
- END_OF_DATA
+ 4.0, 1.0, 3.0, END_OF_FRAME
};
/*! \internal \brief
void setFlags(TestFlags flags) { flags_ = flags; }
- void runTest(int natoms, const char *const *selections);
- void runTest(const char *filename, const char *const *selections);
+ void runTest(int natoms, const char *const *selections, size_t count);
+ void runTest(const char *filename, const char *const *selections,
+ size_t count);
+ template <size_t count>
+ void runTest(int natoms, const char *const (&selections)[count])
+ {
+ runTest(natoms, selections, count);
+ }
+ template <size_t count>
+ void runTest(const char *filename, const char *const (&selections)[count])
+ {
+ runTest(filename, selections, count);
+ }
private:
static void checkSelection(gmx::test::TestReferenceChecker *checker,
const gmx::Selection &sel, TestFlags flags);
- void runParser(const char *const *selections);
+ void runParser(const char *const *selections, size_t count);
void runCompiler();
void checkCompiled();
void runEvaluate();
void
-SelectionCollectionDataTest::runParser(const char *const *selections)
+SelectionCollectionDataTest::runParser(const char *const *selections,
+ size_t count)
{
using gmx::test::TestReferenceChecker;
TestReferenceChecker compound(checker_.checkCompound("ParsedSelections", "Parsed"));
size_t varcount = 0;
count_ = 0;
- for (size_t i = 0; selections[i] != NULL; ++i)
+ for (size_t i = 0; i < count; ++i)
{
SCOPED_TRACE(std::string("Parsing selection \"")
+ selections[i] + "\"");
void
-SelectionCollectionDataTest::runTest(int natoms, const char * const *selections)
+SelectionCollectionDataTest::runTest(int natoms, const char * const *selections,
+ size_t count)
{
- ASSERT_NO_FATAL_FAILURE(runParser(selections));
+ ASSERT_NO_FATAL_FAILURE(runParser(selections, count));
ASSERT_NO_FATAL_FAILURE(setAtomCount(natoms));
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
void
-SelectionCollectionDataTest::runTest(const char *filename, const char * const *selections)
+SelectionCollectionDataTest::runTest(const char *filename,
+ const char * const *selections,
+ size_t count)
{
- ASSERT_NO_FATAL_FAILURE(runParser(selections));
+ ASSERT_NO_FATAL_FAILURE(runParser(selections, count));
ASSERT_NO_FATAL_FAILURE(loadTopology(filename));
ASSERT_NO_FATAL_FAILURE(runCompiler());
if (flags_.test(efTestEvaluation))
{
static const char * const selections[] = {
"all",
- "none",
- NULL
+ "none"
};
runTest(10, selections);
}
static const char * const selections[] = {
"atomnr 1 to 3 6 to 8",
"atomnr 4 2 5 to 7",
- "atomnr <= 5",
- NULL
+ "atomnr <= 5"
};
runTest(10, selections);
}
{
static const char * const selections[] = {
"resnr 1 2 5",
- "resid 4 to 3",
- NULL
+ "resid 4 to 3"
};
runTest("simple.gro", selections);
}
{
static const char * const selections[] = {
"resindex 1 4",
- "residue 1 3",
- NULL
+ "residue 1 3"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"name CB",
- "atomname S1 S2",
- NULL
+ "atomname S1 S2"
};
runTest("simple.gro", selections);
}
"name HG21",
"name 1HG2",
"pdbname HG21 CB",
- "pdbatomname 1HG2",
- NULL
+ "pdbatomname 1HG2"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"chain A",
- "chain B",
- NULL
+ "chain B"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"altloc \" \"",
- "altloc A",
- NULL
+ "altloc A"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"insertcode \" \"",
- "insertcode A",
- NULL
+ "insertcode A"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"occupancy 1",
- "occupancy < .5",
- NULL
+ "occupancy < .5"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"beta 0",
- "beta >= 0.3",
- NULL
+ "beta >= 0.3"
};
runTest("simple.pdb", selections);
}
{
static const char * const selections[] = {
"resname RA",
- "resname RB RC",
- NULL
+ "resname RB RC"
};
runTest("simple.gro", selections);
}
static const char * const selections[] = {
"x < 3",
"y >= 3",
- "x {-1 to 2}",
- NULL
+ "x {-1 to 2}"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
TEST_F(SelectionCollectionDataTest, HandlesSameResidue)
{
static const char * const selections[] = {
- "same residue as atomnr 1 4 12",
- NULL
+ "same residue as atomnr 1 4 12"
};
runTest("simple.gro", selections);
}
TEST_F(SelectionCollectionDataTest, HandlesSameResidueName)
{
static const char * const selections[] = {
- "same resname as atomnr 1 14",
- NULL
+ "same resname as atomnr 1 14"
};
runTest("simple.gro", selections);
}
"res_cog of name CB and resnr 1 3",
"whole_res_cog of name CB and resnr 1 3",
"part_res_cog of x < 3",
- "dyn_res_cog of x < 3",
- NULL
+ "dyn_res_cog of x < 3"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
| efTestPositionAtoms);
TEST_F(SelectionCollectionDataTest, HandlesDistanceKeyword)
{
static const char * const selections[] = {
- "distance from cog of resnr 1 < 2",
- NULL
+ "distance from cog of resnr 1 < 2"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
TEST_F(SelectionCollectionDataTest, HandlesMinDistanceKeyword)
{
static const char * const selections[] = {
- "mindistance from resnr 1 < 2",
- NULL
+ "mindistance from resnr 1 < 2"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
TEST_F(SelectionCollectionDataTest, HandlesWithinKeyword)
{
static const char * const selections[] = {
- "within 1 of resnr 2",
- NULL
+ "within 1 of resnr 2"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
// Both of these should evaluate to empty on a correct implementation.
static const char * const selections[] = {
"resname TP and not insolidangle center cog of resname C span resname R cutoff 20",
- "resname TN and insolidangle center cog of resname C span resname R cutoff 20",
- NULL
+ "resname TN and insolidangle center cog of resname C span resname R cutoff 20"
};
setFlags(TestFlags() | efDontTestCompiledAtoms | efTestEvaluation);
runTest("sphere.gro", selections);
static const char * const selections[] = {
"all permute 3 1 2",
"res_cog of resnr 1 to 4 permute 2 1",
- "name CB S1 and res_cog x < 3 permute 2 1",
- NULL
+ "name CB S1 and res_cog x < 3 permute 2 1"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
| efTestPositionAtoms | efTestPositionMapping);
static const char * const selections[] = {
"name S2 plus name S1",
"res_cog of resnr 2 plus res_cog of resnr 1 plus res_cog of resnr 3",
- "name S1 and y < 3 plus res_cog of x < 2.5",
- NULL
+ "name S1 and y < 3 plus res_cog of x < 2.5"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
| efTestPositionAtoms | efTestPositionMapping);
static const char * const selections[] = {
"name S2 merge name S1",
"resnr 1 2 and name S2 merge resnr 1 2 and name S1 merge res_cog of resnr 1 2",
- "name S1 and x < 2.5 merge res_cog of x < 2.5",
- NULL
+ "name S1 and x < 2.5 merge res_cog of x < 2.5"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
| efTestPositionAtoms | efTestPositionMapping);
TEST_F(SelectionCollectionDataTest, HandlesConstantPositions)
{
static const char * const selections[] = {
- "[1, -2, 3.5]",
- NULL
+ "[1, -2, 3.5]"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
TEST_F(SelectionCollectionDataTest, HandlesWithinConstantPositions)
{
static const char * const selections[] = {
- "within 1 of [2, 1, 0]",
- NULL
+ "within 1 of [2, 1, 0]"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
{
static const char * const selections[] = {
"name = S1 \"C?\"",
- "name ? S1 \"C?\"",
- NULL
+ "name ? S1 \"C?\""
};
runTest("simple.gro", selections);
}
{
static const char * const selections[] = {
"name \"S?\"",
- "name ? \"S?\"",
- NULL
+ "name ? \"S?\""
};
runTest("simple.gro", selections);
}
{
static const char * const selections[] = {
"resname \"R[BD]\"",
- "resname ~ \"R[BD]\"",
- NULL
+ "resname ~ \"R[BD]\""
};
if (gmx::Regex::isSupported())
{
"atomnr 1 to 5 or not atomnr 3 to 8",
"not not atomnr 1 to 5 and atomnr 2 to 6 and not not atomnr 3 to 7",
"atomnr 1 to 5 and (atomnr 2 to 7 and atomnr 3 to 6)",
- "x < 5 and atomnr 1 to 5 and y < 3 and atomnr 2 to 4",
- NULL
+ "x < 5 and atomnr 1 to 5 and y < 3 and atomnr 2 to 4"
};
runTest(10, selections);
}
"2 < x",
"y > resnr",
"resnr < 2.5",
- "2.5 > resnr",
- NULL
+ "2.5 > resnr"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
"x+1 > 3",
"(y-1)^2 <= 1",
"x+--1 > 3",
- "-x+-1 < -3",
- NULL
+ "-x+-1 < -3"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
"value = x + y",
"value <= 4",
"index = resnr",
- "index < 3",
- NULL
+ "index < 3"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
"resname RA RB and x < 3 and value <= 4",
"index = atomnr",
"resname RA and index < 3",
- "resname RB and y < 3 and index < 6",
- NULL
+ "resname RB and y < 3 and index < 6"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
"within 1 of foo",
"bar = cog of resname RA",
"bar",
- "within 1 of bar",
- NULL
+ "within 1 of bar"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
static const char * const selections[] = {
"constpos = [1.0, 2.5, 0.5]",
"constpos",
- "within 2 of constpos",
- NULL
+ "within 2 of constpos"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates
| efTestPositionAtoms);
"constreal1 = 0.5",
"constreal2 = 2.7",
"resnr < constint",
- "x + constreal1 < constreal2",
- NULL
+ "x + constreal1 < constreal2"
};
setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
runTest("simple.gro", selections);
"atomnr 1 to 5 and (atomnr 4 to 7 or x < 2)",
"atomnr 1 to 5 and y < 3 and (atomnr 4 to 7 or x < 2)",
"atomnr 1 to 5 and not (atomnr 4 to 7 or x < 2)",
- "atomnr 1 to 5 or (atomnr 4 to 6 and (atomnr 5 to 7 or x < 2))",
- NULL
+ "atomnr 1 to 5 or (atomnr 4 to 6 and (atomnr 5 to 7 or x < 2))"
};
runTest(10, selections);
}
"foo = atomnr 4 to 7 or x < 2",
"atomnr 1 to 4 and foo",
"atomnr 2 to 6 and y < 3 and foo",
- "atomnr 6 to 10 and not foo",
- NULL
+ "atomnr 6 to 10 and not foo"
};
runTest(10, selections);
}
"bar2 = foo and y < 2",
"atomnr 1 to 4 and bar",
"atomnr 2 to 6 and y < 3 and bar2",
- "atomnr 6 to 10 and not foo",
- NULL
+ "atomnr 6 to 10 and not foo"
};
runTest(10, selections);
}
"unused1 = atomnr 1 to 3",
"foo = atomnr 4 to 7",
"atomnr 1 to 6 and foo",
- "unused2 = atomnr 3 to 5",
- NULL
+ "unused2 = atomnr 3 to 5"
};
runTest(10, selections);
}
static const char * const selections[] = {
"foo = atomnr 4 to 7 and x < 2",
"atomnr 1 to 5 and foo",
- "atomnr 3 to 7 and foo",
- NULL
+ "atomnr 3 to 7 and foo"
};
runTest(10, selections);
}
"foo = atomnr 4 to 7 and x < 2",
"atomnr 1 to 6 and foo",
"within 1 of foo",
- "foo",
- NULL
+ "foo"
};
runTest(10, selections);
}