Enable static anon namespace workaround on pathscale
[alexxy/gromacs.git] / src / gromacs / analysisdata / tests / arraydata.cpp
index 258212a26712cf8e8b47a34e101ef1bb09f27b4e..184a0ef631f53a15b79f00342a41efcf848479c7 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 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.
+ * Copyright (c) 2012,2013,2014, 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.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -48,7 +48,7 @@
 
 #include "gromacs/analysisdata/arraydata.h"
 
-#include "testutils/datatest.h"
+#include "gromacs/analysisdata/tests/datatest.h"
 #include "testutils/testasserts.h"
 
 using gmx::test::AnalysisDataTestInput;
@@ -69,8 +69,13 @@ class SimpleInputData
     public:
         static const AnalysisDataTestInput &get()
         {
+#ifndef STATIC_ANON_NAMESPACE_BUG
             static SimpleInputData singleton;
             return singleton.data_;
+#else
+            static SimpleInputData singleton_arraydata;
+            return singleton_arraydata.data_;
+#endif
         }
 
         SimpleInputData() : data_(1, false)
@@ -109,4 +114,42 @@ TEST_F(AnalysisArrayDataTest, StorageWorks)
     ASSERT_NO_THROW_GMX(data.valuesReady());
 }
 
+TEST_F(AnalysisArrayDataTest, CanSetXAxis)
+{
+    gmx::AnalysisArrayData       data;
+    data.setRowCount(5);
+    data.setXAxis(1.0, 1.0);
+    EXPECT_FLOAT_EQ(1.0, data.xvalue(0));
+    EXPECT_FLOAT_EQ(3.0, data.xvalue(2));
+    EXPECT_FLOAT_EQ(5.0, data.xvalue(4));
+    data.setXAxisValue(0, 3.0);
+    data.setXAxisValue(2, 1.0);
+    EXPECT_FLOAT_EQ(3.0, data.xvalue(0));
+    EXPECT_FLOAT_EQ(2.0, data.xvalue(1));
+    EXPECT_FLOAT_EQ(1.0, data.xvalue(2));
+    EXPECT_FLOAT_EQ(4.0, data.xvalue(3));
+}
+
+TEST_F(AnalysisArrayDataTest, CanSetXAxisBeforeRowCount)
+{
+    {
+        gmx::AnalysisArrayData       data;
+        data.setXAxis(1.0, 1.0);
+        data.setRowCount(5);
+        EXPECT_FLOAT_EQ(1.0, data.xvalue(0));
+        EXPECT_FLOAT_EQ(3.0, data.xvalue(2));
+        EXPECT_FLOAT_EQ(5.0, data.xvalue(4));
+    }
+    {
+        gmx::AnalysisArrayData       data;
+        data.setXAxisValue(0, 2.0);
+        data.setXAxisValue(1, 3.0);
+        data.setXAxisValue(2, 5.0);
+        data.setRowCount(3);
+        EXPECT_FLOAT_EQ(2.0, data.xvalue(0));
+        EXPECT_FLOAT_EQ(3.0, data.xvalue(1));
+        EXPECT_FLOAT_EQ(5.0, data.xvalue(2));
+    }
+}
+
 } // namespace