// // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/CPPAlliance/url // // Test that header file is self-contained. #include #include "test_suite.hpp" #include "test_bnf.hpp" namespace boost { namespace urls { class ip_v4address_bnf_test { public: void check(string_view s, std::uint32_t v) { error_code ec; ipv4_address a; BOOST_TEST( bnf::parse_string(s, ec, ipv4_address_bnf{a})); if(! BOOST_TEST(! ec)) return; BOOST_TEST(a.to_uint() == v); } void run() { using T = test_ref< ipv4_address_bnf, ipv4_address>; bad("0"); bad("0."); bad("0.0"); bad("0.0."); bad("0.0.0"); bad("0.0.0."); bad("0.0.0.256"); bad("00.0.0.0"); bad("1.2.3.4."); bad("1.2.3.4x"); bad("1.2.3.300"); good("0.0.0.0"); good("1.2.3.4"); good("1.2.3.42"); check("0.0.0.0", 0x00000000); check("1.2.3.4", 0x01020304); check("32.64.128.1", 0x20408001); check("255.255.255.255", 0xffffffff); } }; TEST_SUITE( ip_v4address_bnf_test, "boost.url.ipv4_address_bnf"); } // urls } // boost