-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri-test.cpp
656 lines (518 loc) · 20.1 KB
/
uri-test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
#include "uri.hpp"
#include <glog/logging.h>
#include <gflags/gflags.h>
namespace gflags {
// in case we didn't have one
}
bool operator==(uri::components const& lhs, uri::components const& rhs)
{
return (lhs.scheme == rhs.scheme) && (lhs.authority == rhs.authority)
&& (lhs.userinfo == rhs.userinfo) && (lhs.host == rhs.host)
&& (lhs.port == rhs.port) && (lhs.path == rhs.path)
&& (lhs.query == rhs.query) && (lhs.fragment == rhs.fragment);
}
bool operator!=(uri::components const& lhs, uri::components const& rhs)
{
return !(lhs == rhs);
}
int test_good()
{
struct test_case {
char const* uri;
uri::components parts;
};
// clang-format off
test_case tests[] = {
{"foo://dude@example.com:8042/over/there?name=ferret#nose",
{"foo", "dude@example.com:8042", "dude", "example.com", "8042", "/over/there", "name=ferret", "nose", }, },
{"foo://example.com:8042/over/there?name=ferret#nose",
{"foo", "example.com:8042", {}, "example.com", "8042", "/over/there", "name=ferret", "nose", }, },
{"ftp://cnn.example.com&story=breaking_news@10.0.0.1/top_story.htm",
{"ftp", "cnn.example.com&story=breaking_news@10.0.0.1", "cnn.example.com&story=breaking_news", "10.0.0.1", {}, "/top_story.htm", {}, {}, }, },
{"ftp://foo.bar/baz",
{"ftp", "foo.bar", {}, "foo.bar", {}, "/baz", {}, {}, }, },
{"ftp://ftp.is.co.za/rfc/rfc1808.txt",
{"ftp", "ftp.is.co.za", {}, "ftp.is.co.za", {}, "/rfc/rfc1808.txt", {}, {}, }, },
{"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
{"http", "-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", "-.~_!$&'()*+,;=:%40:80%2f::::::", "example.com", {}, "", {}, {}, }, },
{"http://1337.net",
{"http", "1337.net", {}, "1337.net", {}, "", {}, {}, }, },
{"http://142.42.1.1/",
{"http", "142.42.1.1", {}, "142.42.1.1", {}, "/", {}, {}, }, },
{"http://142.42.1.1:8080/",
{"http", "142.42.1.1:8080", {}, "142.42.1.1", "8080", "/", {}, {}, }, },
{"http://223.255.255.254",
{"http", "223.255.255.254", {}, "223.255.255.254", {}, "", {}, {}, }, },
{"http://a.b-c.de",
{"http", "a.b-c.de", {}, "a.b-c.de", {}, "", {}, {}, }, },
{"http://code.google.com/events/#&product=browser",
{"http", "code.google.com", {}, "code.google.com", {}, "/events/", {}, "&product=browser", }, },
{"http://example.com",
{"http", "example.com", {}, "example.com", {}, "", {}, {}, }, },
{"http://example.com/",
{"http", "example.com", {}, "example.com", {}, "/", {}, {}, }, },
{"http://example.com:",
{"http", "example.com:", {}, "example.com", "", "", {}, {}, }, },
{"http://example.com:/",
{"http", "example.com:", {}, "example.com", "", "/", {}, {}, }, },
{"http://example.com:80",
{"http", "example.com:80", {}, "example.com", "80", "", {}, {}, }, },
{"http://example.com:80/",
{"http", "example.com:80", {}, "example.com", "80", "/", {}, {}, }, },
{"http://foo.bar/?q=Test%20URL-encoded%20stuff",
{"http", "foo.bar", {}, "foo.bar", {}, "/", "q=Test%20URL-encoded%20stuff", {}, }, },
{"http://foo.com/(something)?after=parens",
{"http", "foo.com", {}, "foo.com", {}, "/(something)", "after=parens", {}, }, },
{"http://foo.com/blah_(wikipedia)#cite-1",
{"http", "foo.com", {}, "foo.com", {}, "/blah_(wikipedia)", {}, "cite-1", }, },
{"http://foo.com/blah_(wikipedia)_blah#cite-1",
{"http", "foo.com", {}, "foo.com", {}, "/blah_(wikipedia)_blah", {}, "cite-1", }, },
{"http://foo.com/blah_blah",
{"http", "foo.com", {}, "foo.com", {}, "/blah_blah", {}, {}, }, },
{"http://foo.com/blah_blah/",
{"http", "foo.com", {}, "foo.com", {}, "/blah_blah/", {}, {}, }, },
{"http://foo.com/blah_blah_(wikipedia)",
{"http", "foo.com", {}, "foo.com", {}, "/blah_blah_(wikipedia)", {}, {}, }, },
{"http://foo.com/blah_blah_(wikipedia)_(again)",
{"http", "foo.com", {}, "foo.com", {}, "/blah_blah_(wikipedia)_(again)", {}, {}, }, },
{"http://foo.com/unicode_(✪)_in_parens",
{"http", "foo.com", {}, "foo.com", {}, "/unicode_(✪)_in_parens", {}, {}, }, },
{"http://j.mp",
{"http", "j.mp", {}, "j.mp", {}, "", {}, {}, }, },
{"http://userid:password@example.com",
{"http", "userid:password@example.com", "userid:password", "example.com", {}, "", {}, {}, }, },
{"http://userid:password@example.com/",
{"http", "userid:password@example.com", "userid:password", "example.com", {}, "/", {}, {}, }, },
{"http://userid:password@example.com:8080",
{"http", "userid:password@example.com:8080", "userid:password", "example.com", "8080", "", {}, {}, }, },
{"http://userid:password@example.com:8080/",
{"http", "userid:password@example.com:8080", "userid:password", "example.com", "8080", "/", {}, {}, }, },
{"http://userid@example.com",
{"http", "userid@example.com", "userid", "example.com", {}, "", {}, {}, }, },
{"http://userid@example.com/",
{"http", "userid@example.com", "userid", "example.com", {}, "/", {}, {}, }, },
{"http://userid@example.com:8080",
{"http", "userid@example.com:8080", "userid", "example.com", "8080", "", {}, {}, }, },
{"http://userid@example.com:8080/",
{"http", "userid@example.com:8080", "userid", "example.com", "8080", "/", {}, {}, }, },
{"http://www.example.com/wpstyle/?p=364",
{"http", "www.example.com", {}, "www.example.com", {}, "/wpstyle/", "p=364", {}, }, },
{"http://www.ics.uci.edu/pub/ietf/uri/#Related",
{"http", "www.ics.uci.edu", {}, "www.ics.uci.edu", {}, "/pub/ietf/uri/", {}, "Related", }, },
{"http://www.ietf.org/rfc/rfc2396.txt",
{"http", "www.ietf.org", {}, "www.ietf.org", {}, "/rfc/rfc2396.txt", {}, {}, }, },
{"http://مثال.إختبار",
{"http", "مثال.إختبار", {}, "مثال.إختبار", {}, "", {}, {}, }, },
{"http://उदाहरण.परीक्षा",
{"http", "उदाहरण.परीक्षा", {}, "उदाहरण.परीक्षा", {}, "", {}, {}, }, },
{"http://⌘.ws",
{"http", "⌘.ws", {}, "⌘.ws", {}, "", {}, {}, }, },
{"http://⌘.ws/",
{"http", "⌘.ws", {}, "⌘.ws", {}, "/", {}, {}, }, },
{"http://☺.damowmow.com/",
{"http", "☺.damowmow.com", {}, "☺.damowmow.com", {}, "/", {}, {}, }, },
{"http://✪df.ws/123",
{"http", "✪df.ws", {}, "✪df.ws", {}, "/123", {}, {}, }, },
{"http://➡.ws/䨹",
{"http", "➡.ws", {}, "➡.ws", {}, "/䨹", {}, {}, }, },
{"http://例子.测试",
{"http", "例子.测试", {}, "例子.测试", {}, "", {}, {}, }, },
{"https://tools.ietf.org/html/rfc3986#appendix-B",
{"https", "tools.ietf.org", {}, "tools.ietf.org", {}, "/html/rfc3986", {}, "appendix-B", }, },
{"https://www.example.com/foo/?bar=baz&inga=42&quux",
{"https", "www.example.com", {}, "www.example.com", {}, "/foo/", "bar=baz&inga=42&quux", {}, }, },
{"https://xn%2D%2Dui8h%2Edigilicious%2Ecom/",
{"https", "xn%2D%2Dui8h%2Edigilicious%2Ecom", {}, "xn%2D%2Dui8h%2Edigilicious%2Ecom", {}, "/", {}, {}, }, },
{"https://xn--ui8h%2Edigilicious%2Ecom/",
{"https", "xn--ui8h%2Edigilicious%2Ecom", {}, "xn--ui8h%2Edigilicious%2Ecom", {}, "/", {}, {}, }, },
{"https://xn--ui8h.digilicious.com/",
{"https", "xn--ui8h.digilicious.com", {}, "xn--ui8h.digilicious.com", {}, "/", {}, {}, }, },
{"https://🍔.digilicious.com/",
{"https", "🍔.digilicious.com", {}, "🍔.digilicious.com", {}, "/", {}, {}, }, },
{"ldap://[2001:db8::7]/c=GB?objectClass?one",
{"ldap", "[2001:db8::7]", {}, "[2001:db8::7]", {}, "/c=GB", "objectClass?one", {}, }, },
{"mailto:John.Doe@example.com",
{"mailto", {}, {}, {}, {}, "John.Doe@example.com", {}, {}, }, },
{ "mailto:%22not%40me%22@example.org",
{
/* scheme*/ "mailto",
/* auth*/ {},
/*userinfo*/ {},
/* host*/ {},
/* port*/ {},
/* path*/ "%22not%40me%22@example.org",
/* query*/ {},
/*fragment*/ {},
},
},
{"news:comp.infosystems.www.servers.unix",
{"news", {}, {}, {}, {}, "comp.infosystems.www.servers.unix", {}, {}, }, },
{"tel:+1-816-555-1212",
{"tel", {}, {}, {}, {}, "+1-816-555-1212", {}, {}, }, },
{"telnet://192.0.2.16:80/",
{"telnet", "192.0.2.16:80", {}, "192.0.2.16", "80", "/", {}, {}, }, },
{"urn:example:animal:ferret:nose",
{"urn", {}, {}, {}, {}, "example:animal:ferret:nose", {}, {}, }, },
{"urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
{"urn", {}, {}, {}, {}, "oasis:names:specification:docbook:dtd:xml:4.1.2", {}, {}, }, },
};
// clang-format on
auto failures = 0;
for (auto&& test : tests) {
uri::generic u{test.uri};
if (test.parts != u.parts()) {
std::cerr << test.uri << " failed to check\n";
std::cout << "URL:\n";
if (u.scheme())
std::cout << "scheme() == " << *u.scheme() << '\n';
if (u.authority())
std::cout << "authority() == " << *u.authority() << '\n';
if (u.userinfo())
std::cout << "userinfo() == " << *u.userinfo() << '\n';
if (u.host())
std::cout << "host() == " << *u.host() << '\n';
if (u.port())
std::cout << "port() == " << *u.port() << '\n';
if (u.path())
std::cout << "path() == " << *u.path() << '\n';
if (u.query())
std::cout << "query() == " << *u.query() << '\n';
if (u.fragment())
std::cout << "fragment() == " << *u.fragment() << '\n';
std::cout << "\ntest:\n";
if (test.parts.scheme)
std::cout << "scheme == " << *test.parts.scheme << '\n';
if (test.parts.authority)
std::cout << "authority == " << *test.parts.authority << '\n';
if (test.parts.userinfo)
std::cout << "userinfo == " << *test.parts.userinfo << '\n';
if (test.parts.host)
std::cout << "host == " << *test.parts.host << '\n';
if (test.parts.port)
std::cout << "port == " << *test.parts.port << '\n';
if (test.parts.path)
std::cout << "path == " << *test.parts.path << '\n';
if (test.parts.query)
std::cout << "query == " << *test.parts.query << '\n';
if (test.parts.fragment)
std::cout << "fragment == " << *test.parts.fragment << '\n';
std::cout << "\n";
++failures;
}
}
return failures;
}
int test_bad()
{
// Verify a bunch of bad URIs all throw exceptions.
auto failures = 0;
constexpr char const* bad_uris[]{
"http://",
"http://.",
"http://..",
"http://../",
"http://?",
"http://?\?",
"http://?\?/",
"http://#",
"http://##",
"http://##/",
"http://foo.bar?q=Spaces should be encoded",
"//",
"//a",
"///a",
"///",
"http:///a",
"foo.com",
"http:// shouldfail.com",
":// should fail",
"http://foo.bar/foo(bar)baz quux",
"http://-error-.invalid/",
"http://-a.b.co",
"http://a.b-.co",
"http://1.1.1.1.1",
"http://.www.foo.bar/",
"http://.www.foo.bar./",
};
// I have to confess, I don't know what's wrong with these:
// "ftps://foo.bar/",
// "http://a.b--c.de/",
// "rdar://1234",
// "h://test",
// "http://0.0.0.0",
// "http://10.1.1.0",
// "http://10.1.1.255",
// "http://224.1.1.1",
// "http://123.123.123",
// "http://3628126748",
// "http://10.1.1.1",
// "http://10.1.1.254",
// "http://www.foo.bar./",
for (auto uri : bad_uris) {
try {
uri::generic u{uri};
LOG(ERROR) << "should not parse \"" << uri << "\" as \"" << u << "\"\n";
++failures;
}
catch (uri::syntax_error const& e) {
// all good
}
catch (std::exception const& e) {
LOG(FATAL) << "unexpected exception " << e.what() << '\n';
}
}
return failures;
}
int test_resolution()
{
struct test_case {
char const* ref;
char const* resolved;
};
// clang-format off
constexpr test_case tests[] = {
// 5.4.1. Normal Examples
{"g:h", "g:h"},
{"g", "http://a/b/c/g"},
{"./g", "http://a/b/c/g"},
{"g/", "http://a/b/c/g/"},
{"/g", "http://a/g"},
{"//g", "http://g"},
{"?y", "http://a/b/c/d;p?y"},
{"g?y", "http://a/b/c/g?y"},
{"#s", "http://a/b/c/d;p?q#s"},
{"g#s", "http://a/b/c/g#s"},
{"g?y#s", "http://a/b/c/g?y#s"},
{";x", "http://a/b/c/;x"},
{"g;x", "http://a/b/c/g;x"},
{"g;x?y#s", "http://a/b/c/g;x?y#s"},
{"", "http://a/b/c/d;p?q"},
{".", "http://a/b/c/"},
{"./", "http://a/b/c/"},
{"..", "http://a/b/"},
{"../", "http://a/b/"},
{"../g", "http://a/b/g"},
{"../..", "http://a/"},
{"../../", "http://a/"},
{"../../g", "http://a/g"},
// 5.4.2. Abnormal Examples
{"../../../g", "http://a/g"},
{"../../../../g", "http://a/g"},
{"/./g", "http://a/g"},
{"/../g", "http://a/g"},
{"g.", "http://a/b/c/g."},
{".g", "http://a/b/c/.g"},
{"g..", "http://a/b/c/g.."},
{"..g", "http://a/b/c/..g"},
{"./../g", "http://a/b/g"},
{"./g/.", "http://a/b/c/g/"},
{"g/./h", "http://a/b/c/g/h"},
{"g/../h", "http://a/b/c/h"},
{"g;x=1/./y", "http://a/b/c/g;x=1/y"},
{"g;x=1/../y", "http://a/b/c/y"},
{"g?y/./x", "http://a/b/c/g?y/./x"},
{"g?y/../x", "http://a/b/c/g?y/../x"},
{"g#s/./x", "http://a/b/c/g#s/./x"},
{"g#s/../x", "http://a/b/c/g#s/../x"},
{"http:g", "http:g"}, // for strict parsers
};
// clang-format on
// 5.4. Reference Resolution Examples
uri::absolute base("http://a/b/c/d;p?q");
auto failures = 0;
for (auto&& test : tests) {
uri::reference ref(test.ref);
auto const resolved = uri::resolve_ref(base, ref);
auto resolved_s = resolved.string();
if (resolved_s != test.resolved) {
LOG(ERROR) << "##### Failure #####";
LOG(ERROR) << "for input == " << test.ref << '\n';
LOG(ERROR) << "ref == " << ref;
LOG(ERROR) << "resolved == " << resolved;
LOG(ERROR) << "should match == " << test.resolved;
++failures;
}
}
return failures;
}
int test_comparison()
{
auto failures = 0;
struct test_case {
char const* lhs;
char const* rhs;
};
// clang-format off
constexpr test_case tests[] = {
// basic parts
{"http://www.example.com/", "http://www.example.com/"},
{"http://www.example.com/p", "http://www.example.com/p"},
{"http://www.example.com/p?q", "http://www.example.com/p?q"},
{"http://www.example.com/p?q#f", "http://www.example.com/p?q#f"},
// 6.2.2. Syntax-Based Normalization
{"eXAMPLE://a/./b/../b/%63/%7bfoo%7d", "example://a/b/c/%7Bfoo%7D"},
{"example://a/b/c/%7Bfoo%7D", "example://a/b/c/%7Bfoo%7D"},
// 6.2.3. Scheme-Based Normalization
{"http://www.example.com", "http://www.example.com/"},
{"http://www.example.com/", "http://www.example.com/"},
{"http://www.example.com:/", "http://www.example.com/"},
{"http://www.example.com:80/", "http://www.example.com/"},
// leading zeros
{"http://www.example.com:0080/", "http://www.example.com/"},
{"http://www.example.com:0090/", "http://www.example.com:90/"},
// Unicode /
{"https://xn--g6h.digilicious.com/♥", "https://♥.digilicious.com/♥"},
};
// clang-format on
for (auto&& test : tests) {
uri::generic const lhs{test.lhs, true}; // with normalization
uri::generic const rhs{test.rhs, true}; // with normalization
if (lhs != rhs) {
LOG(ERROR) << lhs << " != " << rhs;
++failures;
}
if (lhs.string() != test.rhs) {
LOG(ERROR) << lhs.string() << " != " << test.rhs;
LOG(ERROR) << lhs << " != " << test.rhs;
++failures;
}
}
return failures;
}
namespace {
template <typename CharT>
bool is_small(std::basic_string<CharT> const& str)
{
auto const b = reinterpret_cast<CharT const*>(&str);
auto const e = reinterpret_cast<CharT const*>(&str + 1);
auto const d = str.data();
return (b <= d) && (d <= e);
}
} // namespace
int test_ctors()
{
auto failures = 0;
uri::generic uri_small("s://a/b");
if (!is_small(uri_small.string())) {
LOG(WARNING) << "uri_small is tall";
++failures;
}
uri::generic uri_tall("http://"
"user@very.very.very.very.very.very.very.very.very."
"very.very.very.long.example.com:22222/"
"very/very/very/very/very/very/very/very/very/very/"
"long/path;parap?query#fragment");
if (is_small(uri_tall.string())) {
LOG(WARNING) << "uri_tall is small";
++failures;
}
auto uri_small_copy(uri_small);
auto uri_tall_copy(uri_tall);
if (uri_small != uri_small_copy) {
LOG(WARNING) << "uri_small is equal to uri_small_copy";
++failures;
}
if (uri_tall != uri_tall_copy) {
LOG(WARNING) << "uri_tall is equal to uri_tall_copy";
++failures;
}
return failures;
}
DEFINE_string(base, "", "base URI");
DEFINE_bool(testcase, false, "print a test case for each URI");
DEFINE_bool(normalize, true, "normalize each URI");
int main(int argc, char* argv[])
{
{ // Need to work with either namespace.
using namespace gflags;
using namespace google;
ParseCommandLineFlags(&argc, &argv, true);
}
auto failures = 0;
failures += test_comparison();
failures += test_good();
failures += test_bad();
failures += test_resolution();
failures += test_ctors();
{
// 5.2.4. Remove Dot Segments
uri::components parts;
// The two explicit tests from RFC 3986, page 34:
parts.path = "/a/b/c/./../../g";
CHECK_EQ(uri::normalize(parts), "/a/g");
parts.path = "mid/content=5/../6";
CHECK_EQ(uri::normalize(parts), "mid/6");
}
// Parse command line args as URIs.
for (auto i = 1; i < argc; ++i) {
uri::reference u{argv[i]};
if (!FLAGS_base.empty()) {
uri::absolute base(FLAGS_base);
u = uri::reference(uri::resolve_ref(base, u).string());
}
if (FLAGS_normalize) {
u = uri::reference(uri::normalize(u.parts()));
}
if (!FLAGS_testcase) {
std::cout << "uri == <" << u << ">\n"
<< "scheme == " << (u.scheme() ? *u.scheme() : "{}") << '\n'
<< "auth == " << (u.authority() ? *u.authority() : "{}")
<< '\n'
<< "user == " << (u.userinfo() ? *u.userinfo() : "{}") << '\n'
<< "host == " << (u.host() ? *u.host() : "{}") << '\n'
<< "port == " << (u.port() ? *u.port() : "{}") << '\n'
<< "path == " << (u.path() ? *u.path() : "{}") << '\n'
<< "query == " << (u.query() ? *u.query() : "{}") << '\n'
<< "frag == " << (u.fragment() ? *u.fragment() : "{}")
<< '\n';
}
if (FLAGS_testcase) {
std::cout << " { \"" << argv[i] << "\",\n"
<< " {";
std::cout << "\n /* scheme*/ ";
if (u.scheme())
std::cout << "\"" << *u.scheme() << "\",";
else
std::cout << "{},";
std::cout << "\n /* auth*/ ";
if (u.authority())
std::cout << "\"" << *u.authority() << "\",";
else
std::cout << "{},";
std::cout << "\n /*userinfo*/ ";
if (u.userinfo())
std::cout << "\"" << *u.userinfo() << "\",";
else
std::cout << "{},";
std::cout << "\n /* host*/ ";
if (u.host())
std::cout << "\"" << *u.host() << "\",";
else
std::cout << "{},";
std::cout << "\n /* port*/ ";
if (u.port())
std::cout << "\"" << *u.port() << "\",";
else
std::cout << "{},";
std::cout << "\n /* path*/ ";
if (u.path())
std::cout << "\"" << *u.path() << "\",";
else
std::cout << "{},";
std::cout << "\n /* query*/ ";
if (u.query())
std::cout << "\"" << *u.query() << "\",";
else
std::cout << "{},";
std::cout << "\n /*fragment*/ ";
if (u.fragment())
std::cout << "\"" << *u.fragment() << "\",";
else
std::cout << "{},";
std::cout << "\n }, \n },\n";
}
}
std::cout << "sizeof(uri::absolute) == " << sizeof(uri::absolute) << '\n';
if (failures)
LOG(FATAL) << "one or more tests failed";
}