mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
p2p, refactor: pass and use uint16_t CService::port as uint16_t
This commit is contained in:
@@ -83,31 +83,31 @@ BOOST_AUTO_TEST_CASE(netbase_properties)
|
||||
|
||||
}
|
||||
|
||||
bool static TestSplitHost(std::string test, std::string host, int port)
|
||||
bool static TestSplitHost(const std::string& test, const std::string& host, uint16_t port)
|
||||
{
|
||||
std::string hostOut;
|
||||
int portOut = -1;
|
||||
uint16_t portOut{0};
|
||||
SplitHostPort(test, portOut, hostOut);
|
||||
return hostOut == host && port == portOut;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(netbase_splithost)
|
||||
{
|
||||
BOOST_CHECK(TestSplitHost("www.bitcoincore.org", "www.bitcoincore.org", -1));
|
||||
BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]", "www.bitcoincore.org", -1));
|
||||
BOOST_CHECK(TestSplitHost("www.bitcoincore.org", "www.bitcoincore.org", 0));
|
||||
BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]", "www.bitcoincore.org", 0));
|
||||
BOOST_CHECK(TestSplitHost("www.bitcoincore.org:80", "www.bitcoincore.org", 80));
|
||||
BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]:80", "www.bitcoincore.org", 80));
|
||||
BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", -1));
|
||||
BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", 0));
|
||||
BOOST_CHECK(TestSplitHost("127.0.0.1:8333", "127.0.0.1", 8333));
|
||||
BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", -1));
|
||||
BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", 0));
|
||||
BOOST_CHECK(TestSplitHost("[127.0.0.1]:8333", "127.0.0.1", 8333));
|
||||
BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", -1));
|
||||
BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", 0));
|
||||
BOOST_CHECK(TestSplitHost("[::ffff:127.0.0.1]:8333", "::ffff:127.0.0.1", 8333));
|
||||
BOOST_CHECK(TestSplitHost("[::]:8333", "::", 8333));
|
||||
BOOST_CHECK(TestSplitHost("::8333", "::8333", -1));
|
||||
BOOST_CHECK(TestSplitHost("::8333", "::8333", 0));
|
||||
BOOST_CHECK(TestSplitHost(":8333", "", 8333));
|
||||
BOOST_CHECK(TestSplitHost("[]:8333", "", 8333));
|
||||
BOOST_CHECK(TestSplitHost("", "", -1));
|
||||
BOOST_CHECK(TestSplitHost("", "", 0));
|
||||
}
|
||||
|
||||
bool static TestParse(std::string src, std::string canon)
|
||||
|
||||
Reference in New Issue
Block a user