if (sel->v.type == INT_VALUE || sel->v.type == REAL_VALUE
|| sel->v.type == STR_VALUE)
{
- GMX_RELEASE_ASSERT(sel->v.u.ptr != NULL,
- "Selection method parameter not properly initialized");
_gmx_selvalue_setstore(&sel->u.param->val, sel->v.u.ptr);
}
}
{
GMX_THROW(InvalidInputError("Dynamic selections not supported"));
}
- addValue(*i);
+ // Create a copy to allow modifications.
+ Selection sel(*i);
+ sel.data().setFlags(selectionFlags_);
+ addValue(sel);
}
if (bFullValue)
{
{
GMX_THROW(InvalidInputError("Too few (valid) values provided"));
}
- ValueList::iterator i;
- for (i = values->begin(); i != values->end(); ++i)
- {
- i->data().setFlags(selectionFlags_);
- }
}
void SelectionOptionStorage::processAll()
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
/* Store the values */
n1 = init_comparison_value(&d->left, ¶m[0]);
n2 = init_comparison_value(&d->right, ¶m[3]);
- if (n1 == 0 || n2 == 0)
- {
- GMX_THROW(gmx::InternalError("One of the values for comparison missing"));
- }
/* Store the comparison type */
d->cmpt = comparison_type(d->cmpop);
if (d->cmpt == CMP_INVALID)
--- /dev/null
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+ <ParsedSelections Name="Parsed">
+ <ParsedSelection Name="Selection1">
+ <String Name="Input">none and x > 2</String>
+ <String Name="Text">none and x > 2</String>
+ <Bool Name="Dynamic">true</Bool>
+ </ParsedSelection>
+ <ParsedSelection Name="Selection2">
+ <String Name="Input">none and same resname as resnr 2</String>
+ <String Name="Text">none and same resname as resnr 2</String>
+ <Bool Name="Dynamic">false</Bool>
+ </ParsedSelection>
+ </ParsedSelections>
+ <CompiledSelections Name="Compiled">
+ <Selection Name="Selection1">
+ <Sequence Name="Atoms">
+ <Int Name="Length">0</Int>
+ </Sequence>
+ </Selection>
+ <Selection Name="Selection2">
+ <Sequence Name="Atoms">
+ <Int Name="Length">0</Int>
+ </Sequence>
+ </Selection>
+ </CompiledSelections>
+</ReferenceData>
}
+TEST_F(SelectionCollectionDataTest, HandlesEmptySelectionWithUnevaluatedExpressions)
+{
+ static const char * const selections[] = {
+ "none and x > 2",
+ "none and same resname as resnr 2"
+ };
+ runTest("simple.gro", selections);
+}
+
+
TEST_F(SelectionCollectionDataTest, HandlesNumericComparisons)
{
static const char * const selections[] = {
}
+TEST_F(SelectionOptionTest, ChecksEmptyDelayedSelections)
+{
+ gmx::Selection sel;
+ using gmx::SelectionOption;
+ ASSERT_NO_THROW_GMX(options_.addOption(
+ SelectionOption("sel").store(&sel)));
+ setManager();
+
+ gmx::OptionsAssigner assigner(&options_);
+ EXPECT_NO_THROW_GMX(assigner.start());
+ ASSERT_NO_THROW_GMX(assigner.startOption("sel"));
+ EXPECT_NO_THROW_GMX(assigner.finishOption());
+ EXPECT_NO_THROW_GMX(assigner.finish());
+ EXPECT_NO_THROW_GMX(options_.finish());
+ ASSERT_NO_THROW_GMX(manager_.parseRequestedFromString("none"));
+
+ EXPECT_THROW_GMX(sc_.compile(), gmx::InvalidInputError);
+}
+
+
TEST_F(SelectionOptionTest, HandlesTooManySelections)
{
gmx::Selection sel;