Fix handling of real-valued 'to' selection ranges
[alexxy/gromacs.git] / src / gromacs / selection / tests / selectioncollection.cpp
index d299a2b56c2e110b334c0c66bf0069be7a0b111e..66369c1a7d6293a5865c7bd7ffc311c4c0b74ab1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, 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.
@@ -994,6 +994,32 @@ TEST_F(SelectionCollectionDataTest, HandlesWithinConstantPositions)
 }
 
 
+TEST_F(SelectionCollectionDataTest, HandlesOverlappingIntegerRanges)
+{
+    static const char * const selections[] = {
+        "atomnr 2 to 4 5 to 8",
+        "atomnr 2 to 5 4 to 7"
+    };
+    ASSERT_NO_FATAL_FAILURE(runTest(10, selections));
+}
+
+
+TEST_F(SelectionCollectionDataTest, HandlesOverlappingRealRanges)
+{
+    static const char * const selections[] = {
+        "charge {-0.35 to -0.05 0.25 to 0.75}",
+        "charge {0.05 to -0.3 -0.05 to 0.55}"
+    };
+    ASSERT_NO_FATAL_FAILURE(runParser(selections));
+    ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
+    for (int i = 0; i < top_->atoms.nr; ++i)
+    {
+        top_->atoms.atom[i].q = i / 10.0 - 0.5;
+    }
+    ASSERT_NO_FATAL_FAILURE(runCompiler());
+}
+
+
 TEST_F(SelectionCollectionDataTest, HandlesForcedStringMatchingMode)
 {
     static const char * const selections[] = {