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 2017/07/25 01:26:36 UTC
[1/2] mesos git commit: Added a copy assignment operator to
`net::IP::Network`.
Repository: mesos
Updated Branches:
refs/heads/master 096e5e3ab -> cd3380c4e
Added a copy assignment operator to `net::IP::Network`.
Review: https://reviews.apache.org/r/61004/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b80e239c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b80e239c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b80e239c
Branch: refs/heads/master
Commit: b80e239cd6e629d1e524184ad3fed93726313401
Parents: 096e5e3
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Mon Jul 24 18:23:14 2017 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jul 24 18:24:17 2017 -0700
----------------------------------------------------------------------
3rdparty/stout/include/stout/ip.hpp | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b80e239c/3rdparty/stout/include/stout/ip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/ip.hpp b/3rdparty/stout/include/stout/ip.hpp
index 51000b4..a722fa4 100644
--- a/3rdparty/stout/include/stout/ip.hpp
+++ b/3rdparty/stout/include/stout/ip.hpp
@@ -247,8 +247,18 @@ public:
// Need to add a copy constructor due to the presence of
// `unique_ptr`.
Network(const Network& network)
- :address_(new IP(network.address())),
- netmask_(new IP(network.netmask())) {};
+ : address_(new IP(network.address())),
+ netmask_(new IP(network.netmask())) {}
+
+ // Need to add a copy assignment operator due to the use of
+ // `std::unique_ptr`.
+ Network& operator=(const Network& network)
+ {
+ address_.reset(new IP(network.address()));
+ netmask_.reset(new IP(network.netmask()));
+
+ return *this;
+ }
IP address() const { return *address_; }
@@ -348,10 +358,10 @@ public:
}
explicit IPv4(const in_addr& in)
- : IP(in) {};
+ : IP(in) {}
explicit IPv4(uint32_t ip)
- : IP(ip) {};
+ : IP(ip) {}
// Returns the in_addr storage.
in_addr in() const
@@ -391,7 +401,7 @@ public:
}
explicit IPv6(const in6_addr& in6)
- : IP(in6) {};
+ : IP(in6) {}
in6_addr in6() const
{
[2/2] mesos git commit: Added a test to check for copy assignment of
`net::IP::Network`.
Posted by be...@apache.org.
Added a test to check for copy assignment of `net::IP::Network`.
Review: https://reviews.apache.org/r/61005/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cd3380c4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cd3380c4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cd3380c4
Branch: refs/heads/master
Commit: cd3380c4e9521b4b26f9030658816eee7a4b89a1
Parents: b80e239
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Mon Jul 24 18:24:51 2017 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Jul 24 18:25:49 2017 -0700
----------------------------------------------------------------------
3rdparty/stout/tests/ip_tests.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/cd3380c4/3rdparty/stout/tests/ip_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/ip_tests.cpp b/3rdparty/stout/tests/ip_tests.cpp
index dba0de6..a38e93c 100644
--- a/3rdparty/stout/tests/ip_tests.cpp
+++ b/3rdparty/stout/tests/ip_tests.cpp
@@ -238,3 +238,21 @@ TEST(NetTest, ConstructIPv6Network)
ASSERT_SOME(network2);
EXPECT_EQ(network.get(), network2.get());
}
+
+
+// Check the copy assignment operator for `net::IP::Network` works.
+TEST(NetTest, CopyIPNetwork)
+{
+ Try<net::IP::Network> network = net::IP::Network::parse("192.168.1.1/16");
+ EXPECT_SOME(network);
+
+ net::IP::Network network2 = network.get();
+ EXPECT_EQ(network2, network.get());
+
+ // Check the same for IPv6.
+ network = net::IP::Network::parse("::1/128");
+ EXPECT_SOME(network);
+
+ network2 = network.get();
+ EXPECT_EQ(network2, network.get());
+}