aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-12-07 08:48:02 -0800
committerNeale Ranns <nranns@cisco.com>2017-12-08 08:27:38 +0000
commitd3464b5b4aeea0804e6cc3e1b220673e98d9c4a5 (patch)
tree20a8a70ed8c5582d45f0bc59ad227144658ca249 /test
parentacf33e49b99f8046ae42ed5fd8bff47be396dd7c (diff)
VOM: prefix bit fiddling
Change-Id: I4fbf4a574f455628d56e78cefc1a76adc06bc801 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/ext/vom_test.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp
index f12f871a904..0a687c5017c 100644
--- a/test/ext/vom_test.cpp
+++ b/test/ext/vom_test.cpp
@@ -472,7 +472,7 @@ public:
}
};
-BOOST_AUTO_TEST_SUITE(VppOM_test)
+BOOST_AUTO_TEST_SUITE(vom)
#define TRY_CHECK_RC(stmt) \
{ \
@@ -1594,4 +1594,42 @@ BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
TRY_CHECK(OM::remove(rene));
}
+BOOST_AUTO_TEST_CASE(test_prefixes) {
+ route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);
+
+ BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));
+
+ route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);
+
+ BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
+ BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));
+
+ route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
+ BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
+ BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));
+
+ route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);
+
+ BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));
+
+ route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);
+
+ BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
+ BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
+ BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));
+
+ route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);
+
+ BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
+ BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
+ BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));
+
+ route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);
+
+ BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
+ BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
+ BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));
+
+}
+
BOOST_AUTO_TEST_SUITE_END()