1//
2// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// Official repository: https://github.com/boostorg/url
8//
9
10// Test that header file is self-contained.
11#include <boost/url/rfc/absolute_uri_rule.hpp>
12
13#include "test_rule.hpp"
14
15#include <iostream>
16
17namespace boost {
18namespace urls {
19
20class absolute_uri_rule_test
21{
22public:
23 void
24 run()
25 {
26 // javadoc
27 {
28 system::result< url_view > rv = grammar::parse( s: "http://example.com/index.htm?id=1", r: absolute_uri_rule );
29 (void)rv;
30 }
31
32 auto const& t = absolute_uri_rule;
33
34 bad(r: t, s: "");
35 bad(r: t, s: ":");
36 bad(r: t, s: "http://#");
37 bad(r: t, s: "http://x.y.z/?a=b&c=d&#");
38 bad(r: t, s: "http://x.y.z/?a=b&c=d&#frag");
39 bad(r: t, s: "http://x.y.z/#frag");
40 bad(r: t, s: "http://%");
41 bad(r: t, s: "http://?%");
42
43 ok(r: t, s: "http:");
44 ok(r: t, s: "http:x");
45 ok(r: t, s: "http:x/");
46 ok(r: t, s: "http:x/x");
47 ok(r: t, s: "http:x//");
48 ok(r: t, s: "http://");
49 ok(r: t, s: "http://x");
50 ok(r: t, s: "http://x.y.z");
51 ok(r: t, s: "http://x.y.z/");
52 ok(r: t, s: "http://x.y.z/?");
53 ok(r: t, s: "http://x.y.z/?a");
54 ok(r: t, s: "http://x.y.z/?a=");
55 ok(r: t, s: "http://x.y.z/?a=b");
56 ok(r: t, s: "http://x.y.z/?a=b&c=d");
57 ok(r: t, s: "http://x.y.z/?a=b&c=d&");
58
59 // magnet link
60 ok(r: t, s: "magnet:?xt=urn:btih:d2474e86c");
61
62 // reg-name might have ipv4 prefix
63 ok(r: t, s: "http://192.168.0.1.3.a");
64 }
65};
66
67TEST_SUITE(
68 absolute_uri_rule_test,
69 "boost.url.absolute_uri_rule");
70
71} // urls
72} // boost
73

source code of boost/libs/url/test/unit/rfc/absolute_uri_rule.cpp