// // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.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 #include #include #include #include #include "test_suite.hpp" #include #include namespace boost { namespace urls { namespace grammar { struct range_rule_test { template static void check( string_view s, std::initializer_list< string_view> init, R const& r) { auto rv = parse(s, r); if(! BOOST_TEST(rv.has_value())) return; if(! BOOST_TEST_EQ( rv->size(), init.size())) return; BOOST_TEST( std::equal( rv->begin(), rv->end(), init.begin())); } void run() { // constexpr { constexpr auto r = range_rule( token_rule(alpha_chars), sequence_rule( squelch( delim_rule('+')), token_rule(alpha_chars))); check("", {}, r); check("x", {"x"}, r); } // javadoc { result< range > rv = parse( ";alpha;xray;charlie", range_rule( sequence_rule( squelch( delim_rule( ';' ) ), token_rule( alpha_chars ) ), 1 ) ); (void)rv; } // javadoc { result< range< string_view > > rv = parse( "whiskey,tango,foxtrot", range_rule( token_rule( alpha_chars ), // first sequence_rule( // next squelch( delim_rule(',') ), token_rule( alpha_chars ) ) ) ); (void)rv; } // default construction { range v; } } }; TEST_SUITE( range_rule_test, "boost.url.grammar.range_rule"); } // grammar } // urls } // boost