Skip to content

Commit e2ba043

Browse files
committed
Implements ParseNetwork unit test.
This commit implements a unit test that validates the `ParseNetwork(std::string)` implementation in `netbase.cpp`.
1 parent aa39ca7 commit e2ba043

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/netbase_tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,22 @@ BOOST_AUTO_TEST_CASE(netbase_getgroup)
302302
BOOST_CHECK(CreateInternal("baz.net").GetGroup() == internal_group);
303303
}
304304

305+
BOOST_AUTO_TEST_CASE(netbase_parsenetwork)
306+
{
307+
BOOST_CHECK_EQUAL(ParseNetwork("ipv4"), NET_IPV4);
308+
BOOST_CHECK_EQUAL(ParseNetwork("ipv6"), NET_IPV6);
309+
BOOST_CHECK_EQUAL(ParseNetwork("onion"), NET_ONION);
310+
BOOST_CHECK_EQUAL(ParseNetwork("tor"), NET_ONION);
311+
312+
BOOST_CHECK_EQUAL(ParseNetwork("IPv4"), NET_IPV4);
313+
BOOST_CHECK_EQUAL(ParseNetwork("IPv6"), NET_IPV6);
314+
BOOST_CHECK_EQUAL(ParseNetwork("ONION"), NET_ONION);
315+
BOOST_CHECK_EQUAL(ParseNetwork("TOR"), NET_ONION);
316+
317+
BOOST_CHECK_EQUAL(ParseNetwork(":)"), NET_UNROUTABLE);
318+
BOOST_CHECK_EQUAL(ParseNetwork("tÖr"), NET_UNROUTABLE);
319+
BOOST_CHECK_EQUAL(ParseNetwork("\xfe\xff"), NET_UNROUTABLE);
320+
BOOST_CHECK_EQUAL(ParseNetwork(""), NET_UNROUTABLE);
321+
}
322+
305323
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)