Add more selection unit tests
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 30 Oct 2014 18:45:52 +0000 (20:45 +0200)
committerTeemu Murtola <teemu.murtola@gmail.com>
Thu, 30 Oct 2014 19:42:50 +0000 (21:42 +0200)
Add tests for syntax like
  res_com x < 5
  res_com distance from ...  < 5
as these were not covered well with earlier tests.  Subsequent changes
will refactor the code responsible for evaluating these to allow syntax
like "z of com of ...".

Change-Id: I63b60cc2958fcf919a82b809f60465b8444904d2

src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForKeywords.xml [new file with mode: 0644]
src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForMethods.xml [new file with mode: 0644]
src/gromacs/selection/tests/selectioncollection.cpp

diff --git a/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForKeywords.xml b/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForKeywords.xml
new file mode 100644 (file)
index 0000000..d1c8f85
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <ParsedSelections Name="Parsed">
+    <ParsedSelection Name="Selection1">
+      <String Name="Input">res_cog x &gt; 2</String>
+      <String Name="Text">res_cog x &gt; 2</String>
+      <Bool Name="Dynamic">true</Bool>
+    </ParsedSelection>
+    <ParsedSelection Name="Selection2">
+      <String Name="Input">name CB and res_cog y &gt; 2.5</String>
+      <String Name="Text">name CB and res_cog y &gt; 2.5</String>
+      <Bool Name="Dynamic">true</Bool>
+    </ParsedSelection>
+  </ParsedSelections>
+  <CompiledSelections Name="Compiled">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">15</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+        <Int>3</Int>
+        <Int>4</Int>
+        <Int>5</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+        <Int>9</Int>
+        <Int>10</Int>
+        <Int>11</Int>
+        <Int>12</Int>
+        <Int>13</Int>
+        <Int>14</Int>
+      </Sequence>
+    </Selection>
+    <Selection Name="Selection2">
+      <Sequence Name="Atoms">
+        <Int Name="Length">5</Int>
+        <Int>0</Int>
+        <Int>3</Int>
+        <Int>6</Int>
+        <Int>9</Int>
+        <Int>12</Int>
+      </Sequence>
+    </Selection>
+  </CompiledSelections>
+  <EvaluatedSelections Name="Frame1">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">9</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+        <Int>9</Int>
+        <Int>10</Int>
+        <Int>11</Int>
+        <Int>12</Int>
+        <Int>13</Int>
+        <Int>14</Int>
+      </Sequence>
+    </Selection>
+    <Selection Name="Selection2">
+      <Sequence Name="Atoms">
+        <Int Name="Length">2</Int>
+        <Int>6</Int>
+        <Int>9</Int>
+      </Sequence>
+    </Selection>
+  </EvaluatedSelections>
+</ReferenceData>
diff --git a/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForMethods.xml b/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionModifiersForMethods.xml
new file mode 100644 (file)
index 0000000..a30f472
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <ParsedSelections Name="Parsed">
+    <ParsedSelection Name="Selection1">
+      <String Name="Input">res_cog distance from cog of resnr 1 &lt; 2</String>
+      <String Name="Text">res_cog distance from cog of resnr 1 &lt; 2</String>
+      <Bool Name="Dynamic">true</Bool>
+    </ParsedSelection>
+  </ParsedSelections>
+  <CompiledSelections Name="Compiled">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">15</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+        <Int>3</Int>
+        <Int>4</Int>
+        <Int>5</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+        <Int>9</Int>
+        <Int>10</Int>
+        <Int>11</Int>
+        <Int>12</Int>
+        <Int>13</Int>
+        <Int>14</Int>
+      </Sequence>
+    </Selection>
+  </CompiledSelections>
+  <EvaluatedSelections Name="Frame1">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">9</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+        <Int>3</Int>
+        <Int>4</Int>
+        <Int>5</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+      </Sequence>
+    </Selection>
+  </EvaluatedSelections>
+</ReferenceData>
index 9e6fd86281b473c7d77929ad4c57422547526ea8..c33e091b1c44aee25728648c83c0a463722382b7 100644 (file)
@@ -1115,6 +1115,27 @@ TEST_F(SelectionCollectionDataTest, HandlesEmptySelectionWithUnevaluatedExpressi
 }
 
 
+TEST_F(SelectionCollectionDataTest, HandlesPositionModifiersForKeywords)
+{
+    static const char * const selections[] = {
+        "res_cog x > 2",
+        "name CB and res_cog y > 2.5"
+    };
+    setFlags(TestFlags() | efTestEvaluation);
+    runTest("simple.gro", selections);
+}
+
+
+TEST_F(SelectionCollectionDataTest, HandlesPositionModifiersForMethods)
+{
+    static const char * const selections[] = {
+        "res_cog distance from cog of resnr 1 < 2"
+    };
+    setFlags(TestFlags() | efTestEvaluation);
+    runTest("simple.gro", selections);
+}
+
+
 TEST_F(SelectionCollectionDataTest, HandlesNumericComparisons)
 {
     static const char * const selections[] = {