diff options
author | and42 <[email protected]> | 2022-02-10 16:47:12 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:12 +0300 |
commit | 984590e9d9d7c0f912885d93ae78be402ae7b4f4 (patch) | |
tree | 339adc63bce23800021202ae4a8328a843dc447a /util/network/endpoint_ut.cpp | |
parent | 4fc9a1a64db469cc94894abfec740aa5c9e9789b (diff) |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'util/network/endpoint_ut.cpp')
-rw-r--r-- | util/network/endpoint_ut.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp index 30becbfe775..d5e40dd6e1c 100644 --- a/util/network/endpoint_ut.cpp +++ b/util/network/endpoint_ut.cpp @@ -1,25 +1,25 @@ -#include "endpoint.h" - +#include "endpoint.h" + #include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/hash_set.h> -#include <util/generic/strbuf.h> - + +#include <util/generic/hash_set.h> +#include <util/generic/strbuf.h> + Y_UNIT_TEST_SUITE(TEndpointTest) { Y_UNIT_TEST(TestSimple) { TVector<TNetworkAddress> addrs; - TEndpoint ep0; - - UNIT_ASSERT(ep0.IsIpV4()); - UNIT_ASSERT_VALUES_EQUAL(0, ep0.Port()); - UNIT_ASSERT_VALUES_EQUAL("0.0.0.0", ep0.IpToString()); - + TEndpoint ep0; + + UNIT_ASSERT(ep0.IsIpV4()); + UNIT_ASSERT_VALUES_EQUAL(0, ep0.Port()); + UNIT_ASSERT_VALUES_EQUAL("0.0.0.0", ep0.IpToString()); + TEndpoint ep1; - + try { TNetworkAddress na1("25.26.27.28", 24242); - + addrs.push_back(na1); ep1 = TEndpoint(new NAddr::TAddrInfo(&*na1.Begin())); @@ -35,56 +35,56 @@ Y_UNIT_TEST_SUITE(TEndpointTest) { ep1 = TEndpoint(new NAddr::TAddrInfo(&*n.Begin())); } - ep0.SetPort(12345); - - TEndpoint ep2(ep0); - - ep0.SetPort(0); - - UNIT_ASSERT_VALUES_EQUAL(12345, ep2.Port()); - - TEndpoint ep2_; - - ep2_.SetPort(12345); - - UNIT_ASSERT(ep2 == ep2_); - - TNetworkAddress na3("2a02:6b8:0:1410::5f6c:f3c2", 54321); - TEndpoint ep3(new NAddr::TAddrInfo(&*na3.Begin())); - - UNIT_ASSERT(ep3.IsIpV6()); + ep0.SetPort(12345); + + TEndpoint ep2(ep0); + + ep0.SetPort(0); + + UNIT_ASSERT_VALUES_EQUAL(12345, ep2.Port()); + + TEndpoint ep2_; + + ep2_.SetPort(12345); + + UNIT_ASSERT(ep2 == ep2_); + + TNetworkAddress na3("2a02:6b8:0:1410::5f6c:f3c2", 54321); + TEndpoint ep3(new NAddr::TAddrInfo(&*na3.Begin())); + + UNIT_ASSERT(ep3.IsIpV6()); UNIT_ASSERT(ep3.IpToString().StartsWith(TStringBuf("2a02:6b8:0:1410:"))); UNIT_ASSERT(ep3.IpToString().EndsWith(TStringBuf(":5f6c:f3c2"))); - UNIT_ASSERT_VALUES_EQUAL(54321, ep3.Port()); - - TNetworkAddress na4("2a02:6b8:0:1410:0::5f6c:f3c2", 1); - TEndpoint ep4(new NAddr::TAddrInfo(&*na4.Begin())); - - TEndpoint ep3_ = ep4; - - ep3_.SetPort(54321); - + UNIT_ASSERT_VALUES_EQUAL(54321, ep3.Port()); + + TNetworkAddress na4("2a02:6b8:0:1410:0::5f6c:f3c2", 1); + TEndpoint ep4(new NAddr::TAddrInfo(&*na4.Begin())); + + TEndpoint ep3_ = ep4; + + ep3_.SetPort(54321); + THashSet<TEndpoint> he; - - he.insert(ep0); - he.insert(ep1); - he.insert(ep2); - + + he.insert(ep0); + he.insert(ep1); + he.insert(ep2); + UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); - - he.insert(ep2_); - + + he.insert(ep2_); + UNIT_ASSERT_VALUES_EQUAL(3u, he.size()); - - he.insert(ep3); - he.insert(ep3_); - + + he.insert(ep3); + he.insert(ep3_); + UNIT_ASSERT_VALUES_EQUAL(4u, he.size()); - - he.insert(ep4); - + + he.insert(ep4); + UNIT_ASSERT_VALUES_EQUAL(5u, he.size()); - } + } Y_UNIT_TEST(TestEqual) { const TString ip1 = "2a02:6b8:0:1410::5f6c:f3c2"; @@ -120,4 +120,4 @@ Y_UNIT_TEST_SUITE(TEndpointTest) { UNIT_ASSERT(!ep2.IsUnix()); UNIT_ASSERT(ep2.SockAddr()->sa_family != AF_UNIX); } -} +} |