You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/09/15 00:49:03 UTC
[2/6] mesos git commit: Moved `OfferEqMatcher` to the single test
file where it is used.
Moved `OfferEqMatcher` to the single test file where it is used.
Review: https://reviews.apache.org/r/51808/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5bd5549e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5bd5549e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5bd5549e
Branch: refs/heads/master
Commit: 5bd5549e82ea495cb0d31aaf731b2e2aaca84eda
Parents: 7b9fb69
Author: Neil Conway <ne...@gmail.com>
Authored: Tue Sep 13 19:17:05 2016 +0200
Committer: Michael Park <mp...@apache.org>
Committed: Wed Sep 14 15:01:58 2016 +0200
----------------------------------------------------------------------
src/tests/master_allocator_tests.cpp | 55 ++++++++++++++++++++++++++++++
src/tests/mesos.hpp | 56 -------------------------------
2 files changed, 55 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5bd5549e/src/tests/master_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_allocator_tests.cpp b/src/tests/master_allocator_tests.cpp
index 7eed672..b4ecd46 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -86,6 +86,61 @@ namespace internal {
namespace tests {
+class OfferEqMatcher
+ : public ::testing::MatcherInterface<const vector<Offer>&>
+{
+public:
+ OfferEqMatcher(int _cpus, int _mem)
+ : cpus(_cpus), mem(_mem) {}
+
+ virtual bool MatchAndExplain(
+ const vector<Offer>& offers,
+ ::testing::MatchResultListener* listener) const
+ {
+ double totalCpus = 0;
+ double totalMem = 0;
+
+ foreach (const Offer& offer, offers) {
+ foreach (const Resource& resource, offer.resources()) {
+ if (resource.name() == "cpus") {
+ totalCpus += resource.scalar().value();
+ } else if (resource.name() == "mem") {
+ totalMem += resource.scalar().value();
+ }
+ }
+ }
+
+ bool matches = totalCpus == cpus && totalMem == mem;
+
+ if (!matches) {
+ *listener << totalCpus << " cpus and " << totalMem << "mem";
+ }
+
+ return matches;
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const
+ {
+ *os << "contains " << cpus << " cpus and " << mem << " mem";
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const
+ {
+ *os << "does not contain " << cpus << " cpus and " << mem << " mem";
+ }
+
+private:
+ int cpus;
+ int mem;
+};
+
+
+const ::testing::Matcher<const vector<Offer>&> OfferEq(int cpus, int mem)
+{
+ return MakeMatcher(new OfferEqMatcher(cpus, mem));
+}
+
+
template <typename T>
class MasterAllocatorTest : public MesosTest {};
http://git-wip-us.apache.org/repos/asf/mesos/blob/5bd5549e/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 6bf921a..de4402e 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1716,62 +1716,6 @@ public:
};
-class OfferEqMatcher
- : public ::testing::MatcherInterface<const std::vector<Offer>&>
-{
-public:
- OfferEqMatcher(int _cpus, int _mem)
- : cpus(_cpus), mem(_mem) {}
-
- virtual bool MatchAndExplain(
- const std::vector<Offer>& offers,
- ::testing::MatchResultListener* listener) const
- {
- double totalCpus = 0;
- double totalMem = 0;
-
- foreach (const Offer& offer, offers) {
- foreach (const Resource& resource, offer.resources()) {
- if (resource.name() == "cpus") {
- totalCpus += resource.scalar().value();
- } else if (resource.name() == "mem") {
- totalMem += resource.scalar().value();
- }
- }
- }
-
- bool matches = totalCpus == cpus && totalMem == mem;
-
- if (!matches) {
- *listener << totalCpus << " cpus and " << totalMem << "mem";
- }
-
- return matches;
- }
-
- virtual void DescribeTo(::std::ostream* os) const
- {
- *os << "contains " << cpus << " cpus and " << mem << " mem";
- }
-
- virtual void DescribeNegationTo(::std::ostream* os) const
- {
- *os << "does not contain " << cpus << " cpus and " << mem << " mem";
- }
-
-private:
- int cpus;
- int mem;
-};
-
-
-inline const ::testing::Matcher<const std::vector<Offer>&> OfferEq(
- int cpus, int mem)
-{
- return MakeMatcher(new OfferEqMatcher(cpus, mem));
-}
-
-
ACTION_P(SendStatusUpdateFromTask, state)
{
TaskStatus status;