You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/02/10 22:41:27 UTC

svn commit: r1242942 - in /incubator/mesos/trunk/src: common/resources.hpp tests/resources_tests.cpp

Author: benh
Date: Fri Feb 10 21:41:26 2012
New Revision: 1242942

URL: http://svn.apache.org/viewvc?rev=1242942&view=rev
Log:
Make Resources() not be == to everything (contributed by Charles Reiss).

Modified:
    incubator/mesos/trunk/src/common/resources.hpp
    incubator/mesos/trunk/src/tests/resources_tests.cpp

Modified: incubator/mesos/trunk/src/common/resources.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/resources.hpp?rev=1242942&r1=1242941&r2=1242942&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/resources.hpp (original)
+++ incubator/mesos/trunk/src/common/resources.hpp Fri Feb 10 21:41:26 2012
@@ -152,6 +152,10 @@ public:
 
   bool operator == (const Resources& that) const
   {
+    if (size() != that.size()) {
+      return false;
+    }
+
     foreach (const Resource& resource, resources) {
       Option<Resource> option = that.get(resource);
       if (option.isNone()) {

Modified: incubator/mesos/trunk/src/tests/resources_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/resources_tests.cpp?rev=1242942&r1=1242941&r2=1242942&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/resources_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/resources_tests.cpp Fri Feb 10 21:41:26 2012
@@ -431,3 +431,11 @@ TEST(ResourcesTest, SetSubtraction)
   EXPECT_EQ(1, set.item_size());
   EXPECT_EQ("sda1", set.item(0));
 }
+
+TEST(ResourcesTest, EmptyUnequal)
+{
+  Resources empty = Resources::parse("");
+  Resources cpus2 = Resources::parse("cpus:2");
+
+  EXPECT_FALSE(empty == cpus2);
+}