diff options
author | AlexSm <alex@ydb.tech> | 2023-12-27 23:31:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 23:31:58 +0100 |
commit | d67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch) | |
tree | 8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp/ipmath/ipmath_ut.cpp | |
parent | 1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff) | |
download | ydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz |
Import libs 4 (#758)
Diffstat (limited to 'library/cpp/ipmath/ipmath_ut.cpp')
-rw-r--r-- | library/cpp/ipmath/ipmath_ut.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/cpp/ipmath/ipmath_ut.cpp b/library/cpp/ipmath/ipmath_ut.cpp index 179f232503..8179c1bd67 100644 --- a/library/cpp/ipmath/ipmath_ut.cpp +++ b/library/cpp/ipmath/ipmath_ut.cpp @@ -35,6 +35,7 @@ public: UNIT_TEST(IpRangeFromIpv6); UNIT_TEST(FullIpRange); UNIT_TEST(IpRangeFromCidr); + UNIT_TEST(IpRangeFromCompact); UNIT_TEST(IpRangeFromIpv4Builder); UNIT_TEST(IpRangeFromInvalidIpv4); UNIT_TEST(IpRangeFromInvalidIpv6); @@ -145,6 +146,15 @@ public: ASSERT_THROW(TIpAddressRange::FromCidrString("::/150"), TInvalidIpRangeException); } + void IpRangeFromCompact() { + // FromCidrString disallows node addresses + EXPECT_THROW(TIpAddressRange::FromCidrString("10.10.36.12/12"), TInvalidIpRangeException); + + // FromCompactString allows to use node address instead of network address (suffix of zeroes is not required) + ASSERT_THAT(TIpAddressRange::FromCompactString("10.10.36.12/12"), Eq(TIpAddressRange::FromCidrString("10.0.0.0/12"))); + ASSERT_THAT(TIpAddressRange::FromCompactString("abcd:ef01:2345::/24"), Eq(TIpAddressRange::FromCidrString("abcd:ef00::/24"))); + } + void RangeFromRangeString() { { auto range = TIpAddressRange::FromRangeString("10.0.0.0-10.0.0.3"); |