File: IriTest.php

package info (click to toggle)
php-ml-iri 1.1.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 532 kB
  • sloc: php: 1,230; makefile: 16
file content (1071 lines) | stat: -rw-r--r-- 74,841 bytes parent folder | download
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
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
<?php

/*
 * (c) Markus Lanthaler <mail@markus-lanthaler.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ML\IRI\Test;

use ML\IRI\IRI;
use PHPUnit\Framework\Attributes\DataProvider;

/**
 * The IRI test suite.
 *
 * @author Markus Lanthaler <mail@markus-lanthaler.com>
 */
class IriTest extends \PHPUnit\Framework\TestCase
{
    /**
     * Test parsing
     *
     * This test checks whether decomposing IRIs in their subcomponents works.
     *
     * @param string $iri           The IRI to decompose.
     * @param string|null $scheme   The scheme.
     * @param string|null $userinfo The user information.
     * @param string|null $host     The host.
     * @param string|null $port     The port.
     * @param string|null $path     The path.
     * @param string|null $query    The query component.
     * @param string|null $fragment The fragment identifier.
     */
    #[DataProvider('decompositionProvider')]
    public function testDecomposition($iri, $scheme, $userinfo, $host, $port, $path, $query, $fragment)
    {
        $iri = new IRI($iri);
        $test = new IRI($iri);  // test copy-constructor

        $this->assertEquals($scheme, $test->getScheme(), 'Scheme of ' . $iri);
        $this->assertEquals($userinfo, $test->getUserInfo(), 'User info of ' . $iri);
        $this->assertEquals($host, $test->getHost(), 'Host of ' . $iri);
        $this->assertEquals($port, $test->getPort(), 'Port of ' . $iri);
        $this->assertEquals($path, $test->getPath(), 'Path of ' . $iri);
        $this->assertEquals($query, $test->getQuery(), 'Query component of ' . $iri);
        $this->assertEquals($fragment, $test->getFragment(), 'Fragment of ' . $iri);
        $this->assertEquals($iri, $test->__toString(), 'Recomposition of ' . $iri);
        $this->assertTrue($test->equals($iri), 'Test equality of parsed ' . $iri);
    }

    /**
     * Decomposition test cases
     *
     * These test cases were taken from the
     * {@link http://tools.ietf.org/html/rfc3986#section-1.1.2 URI specification}
     * and from {@link http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html}.
     *
     * @return array The decomposition test cases.
     */
    public static function decompositionProvider()
    {
        return array(  //$iri, $scheme, $userinfo, $host, $port, $path, $query, $fragment
            // http://tools.ietf.org/html/rfc3986#section-1.1.2
            array('ftp://ftp.is.co.za/rfc/rfc1808.txt', 'ftp', null, 'ftp.is.co.za', null, '/rfc/rfc1808.txt', null, null),
            array('http://www.ietf.org/rfc/rfc2396.txt#frag', 'http', null, 'www.ietf.org', null, '/rfc/rfc2396.txt', null, 'frag'),
            array('ldap://[2001:db8::7]/c=GB?objectClass?one', 'ldap', null, '[2001:db8::7]', null, '/c=GB', 'objectClass?one', null),
            array('mailto:John.Doe@example.com', 'mailto', null, null, null, 'John.Doe@example.com', null, null),
            array('news:comp.infosystems.www.servers.unix', 'news', null, null, null, 'comp.infosystems.www.servers.unix', null, null),
            array('tel:+1-816-555-1212', 'tel', null, null, null, '+1-816-555-1212', null, null),
            array('telnet://192.0.2.16:80/', 'telnet', null, '192.0.2.16', '80', '/', null, null),
            array('urn:oasis:names:specification:docbook:dtd:xml:4.1.2', 'urn', null, null, null, 'oasis:names:specification:docbook:dtd:xml:4.1.2', null, null),
            // http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html
            array('http://user:pass@example.org:99/aaa/bbb?qqq#fff', 'http', 'user:pass', 'example.org', '99', '/aaa/bbb' , 'qqq', 'fff'),
            // INVALID IRI array('http://user:pass@example.org:99aaa/bbb'),
            array('http://user:pass@example.org:99?aaa/bbb', 'http', 'user:pass', 'example.org', '99', '', 'aaa/bbb', null),
            array('http://user:pass@example.org:99#aaa/bbb', 'http', 'user:pass', 'example.org', '99' , '', null, 'aaa/bbb'),
            array('http://example.com?query', 'http', null, 'example.com', null, '', 'query', null)
        );
    }

    /**
     * Test whether parsing invalid values leads to an exception
     */
    public function testParseInvalidValue()
    {
        $this->expectException('InvalidArgumentException');
        new IRI(2);
    }

    /**
     * Test whether an IRI is an absolute IRI or a relative one
     *
     * @param string $iri        The IRI to test.
     * @param bool   $isAbsolute True if the IRI is absolute, false otherwise.
     */
    #[DataProvider('isAbsoluteProvider')]
    public function testIsAbsolute($iri, $isAbsolute)
    {
        $iri = new IRI($iri);
        $this->assertEquals($isAbsolute, $iri->isAbsolute());
    }


    /**
     * Absolute/relative IRI test cases
     *
     * These tests were taken from the
     * {@link http://tools.ietf.org/html/rfc3986#section-5.4 URI specification} and from
     * {@link http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html}.
     *
     * @return array The absolute/relative IRI test cases.
     */
    public static function isAbsoluteProvider()
    {
        return array(
            // http://tools.ietf.org/html/rfc3986#section-5.4
            array('http:g', true),
            array('g:h', true),
            array('g', false),
            array('./g', false),
            array('g/', false),
            array('/g', false),
            array('//g', false),
            array('?y', false),
            array('g?y', false),
            array('#s', false),
            array('g#s', false),
            array('g?y#s', false),
            array(';x', false),
            array('g;x', false),
            array('g;x?y#s', false),
            array('', false),
            array('.', false),
            array('./', false),
            array('..', false),
            array('../', false),
            array('../g', false),
            array('../..', false),
            array('../../', false),
            array('../../g', false),
            array('../../../g', false),
            array('../../../../g', false),
            array('/./g', false),
            array('/../g', false),
            array('g.', false),
            array('.g', false),
            array('g..', false),
            array('..g', false),
            array('./../g', false),
            array('./g/.', false),
            array('g/./h', false),
            array('g/../h', false),
            array('g;x=1/./y', false),
            array('g;x=1/../y', false),
            array('g?y/./x', false),
            array('g?y/../x', false),
            array('g#s/./x', false),
            array('g#s/../x', false),
            // http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html
            array('http://example.org/aaa/bbb#ccc', true),
            array('mailto:local@domain.org', true),
            array('mailto:local@domain.org#frag', true),
            array('HTTP://EXAMPLE.ORG/AAA/BBB#CCC', true),
            array('http://example.org/aaa%2fbbb#ccc', true),
            array('http://example.org/aaa%2Fbbb#ccc', true),
            array('http://example.org:80/aaa/bbb#ccc', true),
            array('http://example.org:/aaa/bbb#ccc', true),
            array('http://example.org./aaa/bbb#ccc', true),
            array('http://example.123./aaa/bbb#ccc', true),
            array('http://example.org', true),
            array('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html', true),
            array('http://[1080:0:0:0:8:800:200C:417A]/index.html', true),
            array('http://[3ffe:2a00:100:7031::1]', true),
            array('http://[1080::8:800:200C:417A]/foo', true),
            array('http://[::192.9.5.5]/ipng', true),
            array('http://[::FFFF:129.144.52.38]:80/index.html', true),
            array('http://[2010:836B:4179::836B:4179]', true),
            array('http://example/Andr&#567;', true),
            array('file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/', true),
            array('http://46229EFFE16A9BD60B9F1BE88B2DB047ADDED785/demo.mp3', true),
            array('//example.org/aaa/bbb#ccc', false),
            array('/aaa/bbb#ccc', false),
            array('bbb#ccc', false),
            array('#ccc', false),
            array('#', false),
            array('/', false),
            array('%2F', false),
            array('aaa%2Fbbb', false),
            array('//[2010:836B:4179::836B:4179]', false),
            array("A'C", false),
            array('A$C', false),
            array('A@C', false),
            array('"A,C"', false)
        );
    }

    /**
     * Test conversion to absolute IRI, i.e., removal of the fragment
     */
    public function testGetAbsoluteIri()
    {
        $iri = new IRI('http://example.org/aaa%2fbbb#ccc');
        $this->assertEquals('http://example.org/aaa%2fbbb', (string) $iri->getAbsoluteIri());

        $iri = new IRI('http://example.org/iri#with-fragment/looking/like/a/path?and&query');
        $this->assertEquals('http://example.org/iri', (string) $iri->getAbsoluteIri());
    }

    /**
     * Test conversion to absolute IRI for a relative IRI
     */
    public function testGetAbsoluteIriOnRelativeIri()
    {
        $this->expectException('UnexpectedValueException');
        $iri = new IRI('/relative#with-fragment');
        $iri->getAbsoluteIri();
    }

    /**
     * Test relative reference resolution
     *
     * @param string $base      The base IRI.
     * @param string $reference The reference to resolve.
     * @param string $expected  The expected absolute IRI.
     */
    #[DataProvider('referenceResolutionProvider')]
    public function testReferenceResolution($base, $reference, $expected)
    {
        $base = new IRI($base);
        $this->assertEquals($expected, (string)$base->resolve($reference));
    }

    /**
     * Reference resolution test cases
     *
     * These test cases were taken from the
     * {@link http://tools.ietf.org/html/rfc3986#section-5.4 URI specification},
     * from {@link http://www.w3.org/2004/04/uri-rel-test.html},
     * {@link http://dig.csail.mit.edu/2005/ajar/ajaw/test/uri-test-doc.html},
     * {@link http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html},
     * and {@link http://greenbytes.de/tech/tc/uris/}.
     *
     * @return array The reference resolution test cases.
     */
    public static function referenceResolutionProvider()
    {
        return array(  // $base, $relative, $absolute
            array('', '../a/b', '/a/b'),
            array('', '/.', '/'),
            array(null, '', ''),
            array('', null, ''),
            array(null, null, ''),
            // http://tools.ietf.org/html/rfc3986#section-5.4
            array('http://a/b/c/d;p?q', 'g:h', 'g:h'),
            array('http://a/b/c/d;p?q', 'g', 'http://a/b/c/g'),
            array('http://a/b/c/d;p?q', './g', 'http://a/b/c/g'),
            array('http://a/b/c/d;p?q', 'g/', 'http://a/b/c/g/'),
            array('http://a/b/c/d;p?q', '/g', 'http://a/g'),
            array('http://a/b/c/d;p?q', '//g', 'http://g'),
            array('http://a/b/c/d;p?q', '?y', 'http://a/b/c/d;p?y'),
            array('http://a/b/c/d;p?q', 'g?y', 'http://a/b/c/g?y'),
            array('http://a/b/c/d;p?q', '#s', 'http://a/b/c/d;p?q#s'),
            array('http://a/b/c/d;p?q', 'g#s', 'http://a/b/c/g#s'),
            array('http://a/b/c/d;p?q', 'g?y#s', 'http://a/b/c/g?y#s'),
            array('http://a/b/c/d;p?q', ';x', 'http://a/b/c/;x'),
            array('http://a/b/c/d;p?q', 'g;x', 'http://a/b/c/g;x'),
            array('http://a/b/c/d;p?q', 'g;x?y#s', 'http://a/b/c/g;x?y#s'),
            array('http://a/b/c/d;p?q', '', 'http://a/b/c/d;p?q'),
            array('http://a/b/c/d;p?q', '.', 'http://a/b/c/'),
            array('http://a/b/c/d;p?q', './', 'http://a/b/c/'),
            array('http://a/b/c/d;p?q', '..', 'http://a/b/'),
            array('http://a/b/c/d;p?q', '../', 'http://a/b/'),
            array('http://a/b/c/d;p?q', '../g', 'http://a/b/g'),
            array('http://a/b/c/d;p?q', '../..', 'http://a/'),
            array('http://a/b/c/d;p?q', '../../', 'http://a/'),
            array('http://a/b/c/d;p?q', '../../g', 'http://a/g'),
            array('http://a/b/c/d;p?q', '../../../g', 'http://a/g'),
            array('http://a/b/c/d;p?q', '../../../../g', 'http://a/g'),
            array('http://a/b/c/d;p?q', '/./g', 'http://a/g'),
            array('http://a/b/c/d;p?q', '/../g', 'http://a/g'),
            array('http://a/b/c/d;p?q', 'g.', 'http://a/b/c/g.'),
            array('http://a/b/c/d;p?q', '.g', 'http://a/b/c/.g'),
            array('http://a/b/c/d;p?q', 'g..', 'http://a/b/c/g..'),
            array('http://a/b/c/d;p?q', '..g', 'http://a/b/c/..g'),
            array('http://a/b/c/d;p?q', './../g', 'http://a/b/g'),
            array('http://a/b/c/d;p?q', './g/.', 'http://a/b/c/g/'),
            array('http://a/b/c/d;p?q', 'g/./h', 'http://a/b/c/g/h'),
            array('http://a/b/c/d;p?q', 'g/../h', 'http://a/b/c/h'),
            array('http://a/b/c/d;p?q', 'g;x=1/./y', 'http://a/b/c/g;x=1/y'),
            array('http://a/b/c/d;p?q', 'g;x=1/../y', 'http://a/b/c/y'),
            array('http://a/b/c/d;p?q', 'g?y/./x', 'http://a/b/c/g?y/./x'),
            array('http://a/b/c/d;p?q', 'g?y/../x', 'http://a/b/c/g?y/../x'),
            array('http://a/b/c/d;p?q', 'g#s/./x', 'http://a/b/c/g#s/./x'),
            array('http://a/b/c/d;p?q', 'g#s/../x', 'http://a/b/c/g#s/../x'),
            array('http://a/b/c/d;p?q', 'http:g', 'http:g'),
            // http://www.w3.org/2004/04/uri-rel-test.html
            array('http://a/b/c/d;p?q', './g:h', 'http://a/b/c/g:h'),
            // http://dig.csail.mit.edu/2005/ajar/ajaw/test/uri-test-doc.html},
            // http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html}.
            array('foo:xyz', 'bar:abc', 'bar:abc'),
            array('http://example/x/y/z', '../abc', 'http://example/x/abc'),
            array('http://example2/x/y/z', '//example/x/abc', 'http://example/x/abc'),
            array('http://example2/x/y/z', 'http://example/x/abc', 'http://example/x/abc'),
            array('http://ex/x/y/z', '../r', 'http://ex/x/r'),
            array('http://ex/x/y/z', '/r', 'http://ex/r'),
            array('http://ex/x/y/z', 'q/r', 'http://ex/x/y/q/r'),
            array('http://ex/x/y', 'q/r#s', 'http://ex/x/q/r#s'),
            array('http://ex/x/y', 'q/r#s/t', 'http://ex/x/q/r#s/t'),
            array('http://ex/x/y', 'ftp://ex/x/q/r', 'ftp://ex/x/q/r'),
            array('http://ex/x/y', '', 'http://ex/x/y'),
            array('http://ex/x/y/', '', 'http://ex/x/y/'),
            array('http://ex/x/y/pdq', '', 'http://ex/x/y/pdq'),
            array('http://ex/x/y/', 'z/', 'http://ex/x/y/z/'),
            array('file:/swap/test/animal.rdf', '#Animal', 'file:/swap/test/animal.rdf#Animal'),
            array('file:/e/x/y/z', '../abc', 'file:/e/x/abc'),
            array('file:/example2/x/y/z', '/example/x/abc', 'file:/example/x/abc'),
            array('file:/ex/x/y/z', '../r', 'file:/ex/x/r'),
            array('file:/ex/x/y/z', '/r', 'file:/r'),
            array('file:/ex/x/y', 'q/r', 'file:/ex/x/q/r'),
            array('file:/ex/x/y', 'q/r#s', 'file:/ex/x/q/r#s'),
            array('file:/ex/x/y', 'q/r#', 'file:/ex/x/q/r#'),
            array('file:/ex/x/y', 'q/r#s/t', 'file:/ex/x/q/r#s/t'),
            array('file:/ex/x/y', 'ftp://ex/x/q/r', 'ftp://ex/x/q/r'),
            array('file:/ex/x/y', '', 'file:/ex/x/y'),
            array('file:/ex/x/y/', '', 'file:/ex/x/y/'),
            array('file:/ex/x/y/pdq', '', 'file:/ex/x/y/pdq'),
            array('file:/ex/x/y/', 'z/', 'file:/ex/x/y/z/'),
            array('file:/devel/WWW/2000/10/swap/test/reluri-1.n3', '//meetings.example.com/cal#m1', 'file://meetings.example.com/cal#m1'),
            array('file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3', '//meetings.example.com/cal#m1', 'file://meetings.example.com/cal#m1'),
            array('file:/some/dir/foo', './#blort', 'file:/some/dir/#blort'),
            array('file:/some/dir/foo', './#', 'file:/some/dir/#'),
            array('http://ex/x/y', './q:r', 'http://ex/x/q:r'),
            array('http://ex/x/y', './p=q:r', 'http://ex/x/p=q:r'),
            array('http://ex/x/y?pp/qq', '?pp/rr', 'http://ex/x/y?pp/rr'),
            array('http://ex/x/y?pp/qq', 'y/z', 'http://ex/x/y/z'),
            array('mailto:local', 'local/qual@domain.org#frag', 'mailto:local/qual@domain.org#frag'),
            array('mailto:local/qual1@domain1.org', 'more/qual2@domain2.org#frag', 'mailto:local/more/qual2@domain2.org#frag'),
            array('http://ex/x/z?q', 'y?q', 'http://ex/x/y?q'),
            array('http://ex?p', '/x/y?q', 'http://ex/x/y?q'),
            array('foo:a/b', 'c/d', 'foo:a/c/d'),
            array('foo:a/b', '/c/d', 'foo:/c/d'),
            array('foo:a/b?c#d', '', 'foo:a/b?c'),
            array('foo:a', 'b/c', 'foo:b/c'),
            array('foo:/a/y/z', '../b/c', 'foo:/a/b/c'),
            // TODO Check this test, shouldn't the result be foo:/b/c? array('foo:a', './b/c', 'foo:b/c'),
            array('foo:a', '/./b/c', 'foo:/b/c'),
            array('foo://a//b/c', '../../d', 'foo://a/d'),
            array('foo:a', '.', 'foo:'),
            array('foo:a', '..', 'foo:'),
            array('http://example/x/y%2Fz', 'abc', 'http://example/x/abc'),
            array('http://example/a/x/y/z', '../../x%2Fabc', 'http://example/a/x%2Fabc'),
            array('http://example/a/x/y%2Fz', '../x%2Fabc', 'http://example/a/x%2Fabc'),
            array('http://example/x%2Fy/z', 'abc', 'http://example/x%2Fy/abc'),
            array('http://ex/x/y', 'q%3Ar', 'http://ex/x/q%3Ar'),
            array('http://example/x/y%2Fz', '/x%2Fabc', 'http://example/x%2Fabc'),
            array('http://example/x/y/z', '/x%2Fabc', 'http://example/x%2Fabc'),
            array('http://example/x/y%2Fz', '/x%2Fabc', 'http://example/x%2Fabc'),
            array('ftp://example/x/y', 'http://example/a/b/../../c', 'http://example/c'),
            array('ftp://example/x/y', 'http://example/a/b/c/../../', 'http://example/a/'),
            array('ftp://example/x/y', 'http://example/a/b/c/./', 'http://example/a/b/c/'),
            array('ftp://example/x/y', 'http://example/a/b/c/.././', 'http://example/a/b/'),
            array('ftp://example/x/y', 'http://example/a/b/c/d/../../../../e', 'http://example/e'),
            array('ftp://example/x/y', 'http://example/a/b/c/d/../.././../../e', 'http://example/e'),
            array('mailto:local1@domain1?query1', 'local2@domain2', 'mailto:local2@domain2'),
            array('mailto:local1@domain1', 'local2@domain2?query2', 'mailto:local2@domain2?query2'),
            array('mailto:local1@domain1?query1', 'local2@domain2?query2', 'mailto:local2@domain2?query2'),
            array('mailto:local@domain?query1', '?query2', 'mailto:local@domain?query2'),
            array('mailto:?query1', 'local@domain?query2', 'mailto:local@domain?query2'),
            array('mailto:local@domain?query1', '?query2', 'mailto:local@domain?query2'),
            array('foo:bar', 'http://example/a/b?c/../d', 'http://example/a/b?c/../d'),
            array('foo:bar', 'http://example/a/b#c/../d', 'http://example/a/b#c/../d'),
            array('http://example.org/base/uri', 'this', 'http://example.org/base/this'),  // Fixed absolute from http:this
            array('http://example.org/base/uri', 'http:this', 'http:this'),
            array('http:base', 'http:this', 'http:this'),
            array('f:/a', './/g', 'f://g'),
            array('f://example.org/base/a', 'b/c//d/e', 'f://example.org/base/b/c//d/e'),
            array('mid:m@example.ord/c@example.org', 'm2@example.ord/c2@example.org', 'mid:m@example.ord/m2@example.ord/c2@example.org'),
            array('file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/', 'mini1.xml', 'file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/mini1.xml'),
            array('foo:a/y/z', '../b/c', 'foo:a/b/c'),
            array('http://ex', '/x/y?q', 'http://ex/x/y?q'),
            array('http://ex', 'x/y?q', 'http://ex/x/y?q'),
            array('http://ex?p', '/x/y?q', 'http://ex/x/y?q'),
            array('http://ex?p', 'x/y?q', 'http://ex/x/y?q'),
            array('http://ex#f', '/x/y?q', 'http://ex/x/y?q'),
            array('http://ex#f', 'x/y?q', 'http://ex/x/y?q'),
            array('http://ex?p', '/x/y#g', 'http://ex/x/y#g'),
            array('http://ex?p', 'x/y#g', 'http://ex/x/y#g'),
            array('http://ex', '/', 'http://ex/'),
            array('http://ex', './', 'http://ex/'),
            array('http://ex', '/a/b', 'http://ex/a/b'),
            array('http://ex/a/b', './', 'http://ex/a/'),
            array('mailto:local/option@domain.org?notaquery#frag', 'more@domain', 'mailto:local/more@domain'),
            array('mailto:local/option@domain.org?notaquery#frag', '#newfrag', 'mailto:local/option@domain.org?notaquery#newfrag'),
            array('mailto:local/option@domain.org?notaquery#frag', 'l1/q1@domain', 'mailto:local/l1/q1@domain'),
            array('mailto:local1@domain1?query1', 'mailto:local2@domain2', 'mailto:local2@domain2'),
            array('mailto:local1@domain1', 'mailto:local2@domain2?query2', 'mailto:local2@domain2?query2'),
            array('mailto:local1@domain1?query1', 'mailto:local2@domain2?query2', 'mailto:local2@domain2?query2'),
            array('mailto:local@domain?query1', 'mailto:local@domain?query2', 'mailto:local@domain?query2'),
            array('mailto:?query1', 'mailto:local@domain?query2', 'mailto:local@domain?query2'),
            array('mailto:local@domain?query1', '?query2', 'mailto:local@domain?query2'),
            array('info:name/1234/../567', 'name/9876/../543', 'info:name/name/543'),
            array('info:/name/1234/../567', 'name/9876/../543', 'info:/name/name/543'),
            array('http://ex/x/y', 'q/r', 'http://ex/x/q/r'),
            array('file:/devel/WWW/2000/10/swap/test/reluri-1.n3', 'file://meetings.example.com/cal#m1', 'file://meetings.example.com/cal#m1'),
            array('file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3', 'file://meetings.example.com/cal#m1', 'file://meetings.example.com/cal#m1'),
            array('http://example/x/abc.efg', './', 'http://example/x/'),
            array('http://www.w3.org/People/Berners-Lee/card.rdf', '../../2002/01/tr-automation/tr.rdf', 'http://www.w3.org/2002/01/tr-automation/tr.rdf'),
            array('http://example.com/', '.', 'http://example.com/'),
            array('http://example.com/.meta.n3', '.meta.n3', 'http://example.com/.meta.n3'),
            // http://greenbytes.de/tech/tc/uris/
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'http://a/b/c/d;p?q', 'http://a/b/c/d;p?q'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g:h', 'g:h'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '', 'data:text/plain;charset=iso-8859-7,%be%fg%be'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g', 'data:text/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', './g', 'data:text/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g/', 'data:text/g/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '/g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '//g', 'data://g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '?y', 'data:text/plain;charset=iso-8859-7,%be%fg%be?y'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g?y', 'data:text/g?y'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '#s', 'data:text/plain;charset=iso-8859-7,%be%fg%be#s'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g#s', 'data:text/g#s'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g?y#s', 'data:text/g?y#s'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', ';x', 'data:text/;x'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g;x', 'data:text/g;x'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g;x?y#s', 'data:text/g;x?y#s'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '', 'data:text/plain;charset=iso-8859-7,%be%fg%be'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '.', 'data:text/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', './', 'data:text/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '..', 'data:/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../', 'data:/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../..', 'data:/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../../', 'data:/'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../../g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../../../g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '../../../../g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '/./g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '/../g', 'data:/g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g.', 'data:text/g.'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '.g', 'data:text/.g'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'g..', 'data:text/g..'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', '..g', 'data:text/..g'),
            array('http://a/b/c/d;p?q', 'data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7', 'data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7', 'data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'),
            array('http://a/b/c/d;p?q', 'data:text/plain;charset=iso-8859-7,%be%fg%be', 'data:text/plain;charset=iso-8859-7,%be%fg%be'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'data:text/plain;charset=iso-8859-7,%be%fg%be', 'data:text/plain;charset=iso-8859-7,%be%fg%be'),
            array('http://a/b/c/d;p?q', 'http://www.example.org/Dürst', 'http://www.example.org/Dürst'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'http://www.example.org/Dürst', 'http://www.example.org/Dürst'),
            array('http://a/b/c/d;p?q', 'http://www.example.org/foo bar/qux<>?\^`{|}', 'http://www.example.org/foo bar/qux<>?\^`{|}'),
            array('data:text/plain;charset=iso-8859-7,%be%fg%be', 'http://www.example.org/foo bar/qux<>?\^`{|}', 'http://www.example.org/foo bar/qux<>?\^`{|}'),
            array('http://example.com/b;bar', ';foo', 'http://example.com/;foo'),
            array('http://1.example.org/path1/file1.ext', 'http://2.example.org#frag2', 'http://2.example.org#frag2'),
            array('http://example.org/a/b', '?x', 'http://example.org/a/b?x'),
            array('http://example.org/foo/bar', 'http:test', 'http:test'),
            array('http://www.example.com/#', 'hello, world', 'http://www.example.com/hello, world'),
            array('http://www.example.com/#', '%c2%a9', 'http://www.example.com/%c2%a9'),
            array('http://www.example.com/#', '%41%a', 'http://www.example.com/%41%a'),
            array('http://www.example.com/#', 'asdf#qwer', 'http://www.example.com/asdf#qwer'),
            array('http://www.example.com/#', '#asdf', 'http://www.example.com/#asdf'),
            array('http://www.example.com/foo/bar', 'file:c:\\\\foo\\\\bar.html', 'file:c:\\\\foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', 'File:c|////foo\\\\bar.html', 'File:c|////foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', 'file:', 'file:'),
            array('http://www.example.com/foo/bar', 'file:UNChost/path', 'file:UNChost/path'),
            array('http://www.example.com/foo/bar', 'c:\\\\foo\\\\bar', 'c:\\\\foo\\\\bar'),
            array('http://www.example.com/foo/bar', 'C|/foo/bar', 'http://www.example.com/foo/C|/foo/bar'),
            array('http://www.example.com/foo/bar', '/C|\\\\foo\\\\bar', 'http://www.example.com/C|\\\\foo\\\\bar'),
            array('http://www.example.com/foo/bar', '//C|/foo/bar', 'http://C|/foo/bar'),
            array('http://www.example.com/foo/bar', '//server/file', 'http://server/file'),
            array('http://www.example.com/foo/bar', '\\\\\\\\server\\\\file', 'http://www.example.com/foo/\\\\\\\\server\\\\file'),
            array('http://www.example.com/foo/bar', '/\\\\server/file', 'http://www.example.com/\\\\server/file'),
            array('http://www.example.com/foo/bar', 'file:c:foo/bar.html', 'file:c:foo/bar.html'),
            array('http://www.example.com/foo/bar', 'file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html', 'file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', 'file:///foo/bar.txt', 'file:///foo/bar.txt'),
            array('http://www.example.com/foo/bar', 'FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html', 'FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', 'file:filer/home\\\\me', 'file:filer/home\\\\me'),
            array('http://www.example.com/foo/bar', 'file:///C:/foo/../../../bar.html', 'file:///bar.html'),
            array('http://www.example.com/foo/bar', 'file:///C:/asdf#\\%c2', 'file:///C:/asdf#\\%c2'),
            array('http://www.example.com/foo/bar', 'file:///home/me', 'file:///home/me'),
            array('http://www.example.com/foo/bar', 'file:c:\\\\foo\\\\bar.html', 'file:c:\\\\foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', 'file:c|//foo\\\\bar.html', 'file:c|//foo\\\\bar.html'),
            array('http://www.example.com/foo/bar', '//', 'http://'),
            array('http://www.example.com/foo/bar', '///', 'http:///'),
            array('http://www.example.com/foo/bar', '///test', 'http:///test'),
            array('http://www.example.com/foo/bar', 'file://test', 'file://test'),
            array('http://www.example.com/foo/bar', 'file://localhost/', 'file://localhost/'),
            array('http://www.example.com/foo/bar', 'file://localhost/test', 'file://localhost/test'),
            array('file:///tmp/mock/path', 'file:c:\\\\foo\\\\bar.html', 'file:c:\\\\foo\\\\bar.html'),
            array('file:///tmp/mock/path', 'File:c|////foo\\\\bar.html', 'File:c|////foo\\\\bar.html'),
            array('file:///tmp/mock/path', 'file:', 'file:'),
            array('file:///tmp/mock/path', 'file:UNChost/path', 'file:UNChost/path'),
            array('file:///tmp/mock/path', 'c:\\\\foo\\\\bar', 'c:\\\\foo\\\\bar'),
            array('file:///tmp/mock/path', 'C|/foo/bar', 'file:///tmp/mock/C|/foo/bar'),
            array('file:///tmp/mock/path', '/C|\\\\foo\\\\bar', 'file:///C|\\\\foo\\\\bar'),
            array('file:///tmp/mock/path', '//C|/foo/bar', 'file://C|/foo/bar'),
            array('file:///tmp/mock/path', '//server/file', 'file://server/file'),
            array('file:///tmp/mock/path', '\\\\\\\\server\\\\file', 'file:///tmp/mock/\\\\\\\\server\\\\file'),
            array('file:///tmp/mock/path', '/\\\\server/file', 'file:///\\\\server/file'),
            array('file:///tmp/mock/path', 'file:c:foo/bar.html', 'file:c:foo/bar.html'),
            array('file:///tmp/mock/path', 'file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html', 'file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html'),
            array('file:///tmp/mock/path', 'file:///foo/bar.txt', 'file:///foo/bar.txt'),
            array('file:///tmp/mock/path', 'FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html', 'FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html'),
            array('file:///tmp/mock/path', 'file:filer/home\\\\me', 'file:filer/home\\\\me'),
            array('file:///tmp/mock/path', 'file:///C:/foo/../../../bar.html', 'file:///bar.html'),
            array('file:///tmp/mock/path', 'file:///C:/asdf#\\%c2', 'file:///C:/asdf#\\%c2'),
            array('file:///tmp/mock/path', 'file:///home/me', 'file:///home/me'),
            array('file:///tmp/mock/path', 'file:c:\\\\foo\\\\bar.html', 'file:c:\\\\foo\\\\bar.html'),
            array('file:///tmp/mock/path', 'file:c|//foo\\\\bar.html', 'file:c|//foo\\\\bar.html'),
            array('file:///tmp/mock/path', '//', 'file://'),
            array('file:///tmp/mock/path', '///', 'file:///'),
            array('file:///tmp/mock/path', '///test', 'file:///test'),
            array('file:///tmp/mock/path', 'file://test', 'file://test'),
            array('file:///tmp/mock/path', 'file://localhost/', 'file://localhost/'),
            array('file:///tmp/mock/path', 'file://localhost/test', 'file://localhost/test'),
            array('http://', 'GoOgLe.CoM', 'http:///GoOgLe.CoM'),
            array('http://', 'Goo%20 goo%7C|.com', 'http:///Goo%20 goo%7C|.com'),
            array('http://', '%ef%b7%90zyx.com', 'http:///%ef%b7%90zyx.com'),
            array('http://', '%ef%bc%85%ef%bc%94%ef%bc%91.com', 'http:///%ef%bc%85%ef%bc%94%ef%bc%91.com'),
            array('http://', '%ef%bc%85%ef%bc%90%ef%bc%90.com', 'http:///%ef%bc%85%ef%bc%90%ef%bc%90.com'),
            array('http://', '%zz%66%a', 'http:///%zz%66%a'),
            array('http://', '%25', 'http:///%25'),
            array('http://', 'hello%00', 'http:///hello%00'),
            array('http://', '%30%78%63%30%2e%30%32%35%30.01', 'http:///%30%78%63%30%2e%30%32%35%30.01'),
            array('http://', '%30%78%63%30%2e%30%32%35%30.01%2e', 'http:///%30%78%63%30%2e%30%32%35%30.01%2e'),
            array('http://', '%3g%78%63%30%2e%30%32%35%30%2E.01', 'http:///%3g%78%63%30%2e%30%32%35%30%2E.01'),
            array('http://', '192.168.0.1 hello', 'http:///192.168.0.1 hello'),
            array('http://', '192.168.0.257', 'http:///192.168.0.257'),
            array('http://', '[google.com]', 'http:///[google.com]'),
            array('http://', 'go\\@ogle.com', 'http:///go\\@ogle.com'),
            array('http://', 'go/@ogle.com', 'http:///go/@ogle.com'),
            array('http://', 'www.lookout.net::==80::==443::', 'www.lookout.net::==80::==443::'),
            array('http://', 'www.lookout.net::80::443', 'www.lookout.net::80::443'),
            array('http://', '\\\\', 'http:///\\\\'),
            array('http://', '\\\\\\/', 'http:///\\\\\\/'),
            array('http://', '\\\\./', 'http:///\\\\./'),
            array('http://', '///:@/', 'http:///:@/'),
            array('http://', '\\google.com/foo', 'http:///\\google.com/foo'),
            array('http://', '\\\\google.com/foo', 'http:///\\\\google.com/foo'),
            array('http://', '///asdf@/', 'http:///asdf@/'),
            array('http://', '//:81', 'http://:81'),
            array('http://', '://', 'http:///://'),
            array('http://', 'c:', 'c:'),
            array('http://', 'xxxx:', 'xxxx:'),
            array('http://', '.:.', '.:'),
            array('http://', '////@google.com/', 'http:////@google.com/'),
            array('http://', '@google.com', 'http:///@google.com'),
            array('http://', 'gOoGle.com', 'http:///gOoGle.com'),
            array('http://', '-foo.bar.com', 'http:///-foo.bar.com'),
            array('http://', 'foo-.bar.com', 'http:///foo-.bar.com'),
            array('http://', 'ab--cd.com', 'http:///ab--cd.com'),
            array('http://', 'xn--0.com', 'http:///xn--0.com'),
            array('http://', '.', 'http:///'),
            array('http://', '192.168.0.1', 'http:///192.168.0.1'),
            array('http://', '0300.0250.00.01', 'http:///0300.0250.00.01'),
            array('http://', '0xC0.0Xa8.0x0.0x1', 'http:///0xC0.0Xa8.0x0.0x1'),
            array('http://', '192.168.9.com', 'http:///192.168.9.com'),
            array('http://', '19a.168.0.1', 'http:///19a.168.0.1'),
            array('http://', '0308.0250.00.01', 'http:///0308.0250.00.01'),
            array('http://', '0xCG.0xA8.0x0.0x1', 'http:///0xCG.0xA8.0x0.0x1'),
            array('http://', '192', 'http:///192'),
            array('http://', '0xC0a80001', 'http:///0xC0a80001'),
            array('http://', '030052000001', 'http:///030052000001'),
            array('http://', '000030052000001', 'http:///000030052000001'),
            array('http://', '192.168', 'http:///192.168'),
            array('http://', '192.0x00A80001', 'http:///192.0x00A80001'),
            array('http://', '0xc0.052000001', 'http:///0xc0.052000001'),
            array('http://', '192.168.1', 'http:///192.168.1'),
            array('http://', '192.168.0.0.1', 'http:///192.168.0.0.1'),
            array('http://', '192.168.0.1.', 'http:///192.168.0.1.'),
            array('http://', '192.168.0.1. hello', 'http:///192.168.0.1. hello'),
            array('http://', '192.168.0.1..', 'http:///192.168.0.1..'),
            array('http://', '192.168..1', 'http:///192.168..1'),
            array('http://', '0x100.0', 'http:///0x100.0'),
            array('http://', '0x100.0.0', 'http:///0x100.0.0'),
            array('http://', '0x100.0.0.0', 'http:///0x100.0.0.0'),
            array('http://', '0.0x100.0.0', 'http:///0.0x100.0.0'),
            array('http://', '0.0.0x100.0', 'http:///0.0.0x100.0'),
            array('http://', '0.0.0.0x100', 'http:///0.0.0.0x100'),
            array('http://', '0.0.0x10000', 'http:///0.0.0x10000'),
            array('http://', '0.0x1000000', 'http:///0.0x1000000'),
            array('http://', '0x100000000', 'http:///0x100000000'),
            array('http://', '0xFF.0', 'http:///0xFF.0'),
            array('http://', '0xFF.0.0', 'http:///0xFF.0.0'),
            array('http://', '0xFF.0.0.0', 'http:///0xFF.0.0.0'),
            array('http://', '0.0xFF.0.0', 'http:///0.0xFF.0.0'),
            array('http://', '0.0.0xFF.0', 'http:///0.0.0xFF.0'),
            array('http://', '0.0.0.0xFF', 'http:///0.0.0.0xFF'),
            array('http://', '0.0.0xFFFF', 'http:///0.0.0xFFFF'),
            array('http://', '0.0xFFFFFF', 'http:///0.0xFFFFFF'),
            array('http://', '0xFFFFFFFF', 'http:///0xFFFFFFFF'),
            array('http://', '276.256.0xf1a2.077777', 'http:///276.256.0xf1a2.077777'),
            array('http://', '192.168.0.257', 'http:///192.168.0.257'),
            array('http://', '192.168.0xa20001', 'http:///192.168.0xa20001'),
            array('http://', '192.015052000001', 'http:///192.015052000001'),
            array('http://', '0X12C0a80001', 'http:///0X12C0a80001'),
            array('http://', '276.1.2', 'http:///276.1.2'),
            array('http://', '192.168.0.1 hello', 'http:///192.168.0.1 hello'),
            array('http://', '0000000000000300.0x00000000000000fF.00000000000000001', 'http:///0000000000000300.0x00000000000000fF.00000000000000001'),
            array('http://', '0000000000000300.0xffffffffFFFFFFFF.3022415481470977', 'http:///0000000000000300.0xffffffffFFFFFFFF.3022415481470977'),
            array('http://', '00000000000000000001', 'http:///00000000000000000001'),
            array('http://', '0000000000000000100000000000000001', 'http:///0000000000000000100000000000000001'),
            array('http://', '0.0.0.000000000000000000z', 'http:///0.0.0.000000000000000000z'),
            array('http://', '0.0.0.100000000000000000z', 'http:///0.0.0.100000000000000000z'),
            array('http://', '0.00.0x.0x0', 'http:///0.00.0x.0x0'),
            array('http://', '[', 'http:///['),
            array('http://', '[:', '[:'),
            array('http://', ']', 'http:///]'),
            array('http://', ':]', 'http:///:]'),
            array('http://', '[]', 'http:///[]'),
            array('http://', '[:]', '[:]'),
            array('http://', '2001:db8::1', '2001:db8::1'),
            array('http://', '[2001:db8::1', '[2001:db8::1'),
            array('http://', '2001:db8::1]', '2001:db8::1]'),
            array('http://', '[::]', '[::]'),
            array('http://', '[::1]', '[::1]'),
            array('http://', '[1::]', '[1::]'),
            array('http://', '[::192.168.0.1]', '[::192.168.0.1]'),
            array('http://', '[::ffff:192.168.0.1]', '[::ffff:192.168.0.1]'),
            array('http://', '[000:01:02:003:004:5:6:007]', '[000:01:02:003:004:5:6:007]'),
            array('http://', '[A:b:c:DE:fF:0:1:aC]', '[A:b:c:DE:fF:0:1:aC]'),
            array('http://', '[1:0:0:2::3:0]', '[1:0:0:2::3:0]'),
            array('http://', '[1::2:0:0:3:0]', '[1::2:0:0:3:0]'),
            array('http://', '[::eeee:192.168.0.1]', '[::eeee:192.168.0.1]'),
            array('http://', '[2001::192.168.0.1]', '[2001::192.168.0.1]'),
            array('http://', '[1:2:192.168.0.1:5:6]', '[1:2:192.168.0.1:5:6]'),
            array('http://', '[::ffff:192.1.2]', '[::ffff:192.1.2]'),
            array('http://', '[::ffff:0xC0.0Xa8.0x0.0x1]', '[::ffff:0xC0.0Xa8.0x0.0x1]'),
            array('http://', '[0:0::0:0:8]', '[0:0::0:0:8]'),
            array('http://', '[2001:db8::1]', '[2001:db8::1]'),
            array('http://', '[2001::db8::1]', '[2001::db8::1]'),
            array('http://', '[2001:db8:::1]', '[2001:db8:::1]'),
            array('http://', '[:::]', '[:::]'),
            array('http://', '[2001::.com]', '[2001::.com]'),
            array('http://', '[::192.168.0.0.1]', '[::192.168.0.0.1]'),
            array('http://', '[::ffff:192.168.0.0.1]', '[::ffff:192.168.0.0.1]'),
            array('http://', '[1:2:3:4:5:6:7:8:9]', '[1:2:3:4:5:6:7:8:9]'),
            array('http://', '[0:0:0:0:0:0:0:192.168.0.1]', '[0:0:0:0:0:0:0:192.168.0.1]'),
            array('http://', '[1:2:3:4:5:6::192.168.0.1]', '[1:2:3:4:5:6::192.168.0.1]'),
            array('http://', '[1:2:3:4:5:6::8]', '[1:2:3:4:5:6::8]'),
            array('http://', '[1:2:3:4:5:6:7:8:]', '[1:2:3:4:5:6:7:8:]'),
            array('http://', '[1:2:3:4:5:6:192.168.0.1:]', '[1:2:3:4:5:6:192.168.0.1:]'),
            array('http://', '[-1:2:3:4:5:6:7:8]', '[-1:2:3:4:5:6:7:8]'),
            array('http://', '[1::%1]', '[1::%1]'),
            array('http://', '[1::%eth0]', '[1::%eth0]'),
            array('http://', '[1::%]', '[1::%]'),
            array('http://', '[%]', 'http:///[%]'),
            array('http://', '[::%:]', '[::%:]'),
            array('http://', '[:0:0::0:0:8]', '[:0:0::0:0:8]'),
            array('http://', '[0:0::0:0:8:]', '[0:0::0:0:8:]'),
            array('http://', '[:0:0::0:0:8:]', '[:0:0::0:0:8:]'),
            array('http://', '[::192.168..1]', '[::192.168..1]'),
            array('http://', '[::1 hello]', '[::1 hello]'),
            array('mailto:', 'addr1', 'mailto:addr1'),
            array('mailto:', 'addr1@foo.com', 'mailto:addr1@foo.com'),
            array('mailto:', 'addr1 \\t', 'mailto:addr1 \\t'),
            array('mailto:', 'addr1?to=jon', 'mailto:addr1?to=jon'),
            array('mailto:', 'addr1,addr2', 'mailto:addr1,addr2'),
            array('mailto:', 'addr1, addr2', 'mailto:addr1, addr2'),
            array('mailto:', 'addr1%2caddr2', 'mailto:addr1%2caddr2'),
            array('mailto:', 'addr1?', 'mailto:addr1?'),
            array('http://www.example.com', '/././foo', 'http://www.example.com/foo'),
            array('http://www.example.com', '/./.foo', 'http://www.example.com/.foo'),
            array('http://www.example.com', '/foo/.', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo/./', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo/bar/..', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo/bar/../', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo/..bar', 'http://www.example.com/foo/..bar'),
            array('http://www.example.com', '/foo/bar/../ton', 'http://www.example.com/foo/ton'),
            array('http://www.example.com', '/foo/bar/../ton/../../a', 'http://www.example.com/a'),
            array('http://www.example.com', '/foo/../../..', 'http://www.example.com/'),
            array('http://www.example.com', '/foo/../../../ton', 'http://www.example.com/ton'),
            array('http://www.example.com', '/foo/%2e', 'http://www.example.com/foo/%2e'),
            array('http://www.example.com', '/foo/%2e%2', 'http://www.example.com/foo/%2e%2'),
            array('http://www.example.com', '/foo/%2e./%2e%2e/.%2e/%2e.bar', 'http://www.example.com/foo/%2e./%2e%2e/.%2e/%2e.bar'),
            array('http://www.example.com', '////../..', 'http:///'),
            array('http://www.example.com', '/foo/bar//../..', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo/bar//..', 'http://www.example.com/foo/bar/'),
            array('http://www.example.com', '/foo/bar/..', 'http://www.example.com/foo/'),
            array('http://www.example.com', '/foo', 'http://www.example.com/foo'),
            array('http://www.example.com', '/%20foo', 'http://www.example.com/%20foo'),
            array('http://www.example.com', '/foo%', 'http://www.example.com/foo%'),
            array('http://www.example.com', '/foo%2', 'http://www.example.com/foo%2'),
            array('http://www.example.com', '/foo%2zbar', 'http://www.example.com/foo%2zbar'),
            array('http://www.example.com', '/foo%41%7a', 'http://www.example.com/foo%41%7a'),
            array('http://www.example.com', '/foo%00%51', 'http://www.example.com/foo%00%51'),
            array('http://www.example.com', '/(%28:%3A%29)', 'http://www.example.com/(%28:%3A%29)'),
            array('http://www.example.com', '/%3A%3a%3C%3c', 'http://www.example.com/%3A%3a%3C%3c'),
            array('http://www.example.com', '/foo\\tbar', 'http://www.example.com/foo\\tbar'),
            array('http://www.example.com', '\\\\foo\\\\bar', 'http://www.example.com/\\\\foo\\\\bar'),
            array('http://www.example.com', '/%7Ffp3%3Eju%3Dduvgw%3Dd', 'http://www.example.com/%7Ffp3%3Eju%3Dduvgw%3Dd'),
            array('http://www.example.com', '/@asdf%40', 'http://www.example.com/@asdf%40'),
            array('http://www.example.com:', 'as df', 'http://www.example.com:/as df'),
            array('http://www.example.com:', '-2', 'http://www.example.com:/-2'),
            array('http://www.example.com:', '80', 'http://www.example.com:/80'),
            array('http://www.example.com:', '8080', 'http://www.example.com:/8080'),
            array('http://www.example.com:', '', 'http://www.example.com:'),
            array('http://www.example.com/?', 'foo=bar', 'http://www.example.com/foo=bar'),
            array('http://www.example.com/?', 'as?df', 'http://www.example.com/as?df'),
            array('http://www.example.com/?', '\\%02hello%7f bye', 'http://www.example.com/\\%02hello%7f bye'),
            array('http://www.example.com/?', '%40%41123', 'http://www.example.com/%40%41123'),
            array('http://www.example.com/?', 'q=&lt;asdf&gt;', 'http://www.example.com/q=&lt;asdf&gt;'),
            array('http://www.example.com/?', 'q=\\"asdf\\"', 'http://www.example.com/q=\\"asdf\\"'),
            array('http://host/a', '\\\\\\\\Another\\\\path', 'http://host/\\\\\\\\Another\\\\path'),
            array('http://host/a', '/c:\\\\foo', 'http://host/c:\\\\foo'),
            array('http://host/a', '//c:\\\\foo', 'http://c:\\\\foo'),
            array('file:///C:/foo', 'http://host/', 'http://host/'),
            array('file:///C:/foo', 'bar', 'file:///C:/bar'),
            array('file:///C:/foo', '../../../bar.html', 'file:///bar.html'),
            array('file:///C:/foo', '/../bar.html', 'file:///bar.html'),
            array('http://host/a', '\\\\\\\\another\\\\path', 'http://host/\\\\\\\\another\\\\path'),
            array('file:///C:/something', '//c:/foo', 'file://c:/foo'),
            array('file:///C:/something', '//localhost/c:/foo', 'file://localhost/c:/foo'),
            array('file:///C:/foo', 'c:', 'c:'),
            array('file:///C:/foo', 'c:/foo', 'c:/foo'),
            array('http://host/a', 'c:\\\\foo', 'c:\\\\foo'),
            array('file:///C:/foo', '/z:/bar', 'file:///z:/bar'),
            array('file:///C:/foo', '/bar', 'file:///bar'),
            array('file://localhost/C:/foo', '/bar', 'file://localhost/bar'),
            array('file:///C:/foo/com/', '/bar', 'file:///bar'),
            array('file:///C:/something', '//somehost/path', 'file://somehost/path'),
            array('file:///C:/something', '/\\\\//somehost/path', 'file:///\\\\//somehost/path'),
            array('http://host/a', 'http://another/', 'http://another/'),
            array('http://host/a', 'http:////another/', 'http:////another/'),
            array('http://foo/bar', '', 'http://foo/bar'),
            array('http://foo/bar#ref', '', 'http://foo/bar'),
            array('http://foo/bar#', '', 'http://foo/bar'),
            array('http://foo/bar', ' another ', 'http://foo/ another '),
            array('http://foo/bar', ' . ', 'http://foo/ . '),
            array('http://foo/bar', ' \\t', 'http://foo/ \\t'),
            array('http://host/a', 'http:path', 'http:path'),
            array('http://host/a/', 'http:path', 'http:path'),
            array('http://host/a', 'http:/path', 'http:/path'),
            array('http://host/a', 'HTTP:/path', 'HTTP:/path'),
            array('http://host/a', 'https:host2', 'https:host2'),
            array('http://host/a', 'htto:/host2', 'htto:/host2'),
            array('http://host/a', '/b/c/d', 'http://host/b/c/d'),
            array('http://host/a', '\\\\b\\\\c\\\\d', 'http://host/\\\\b\\\\c\\\\d'),
            array('http://host/a', '/b/../c', 'http://host/c'),
            array('http://host/a?b#c', '/b/../c', 'http://host/c'),
            array('http://host/a', '\\\\b/../c?x#y', 'http://host/c?x#y'),
            array('http://host/a?b#c', '/b/../c?x#y', 'http://host/c?x#y'),
            array('http://host/a', 'b', 'http://host/b'),
            array('http://host/a', 'bc/de', 'http://host/bc/de'),
            array('http://host/a/', 'bc/de?query#ref', 'http://host/a/bc/de?query#ref'),
            array('http://host/a/', '.', 'http://host/a/'),
            array('http://host/a/', '..', 'http://host/'),
            array('http://host/a/', './..', 'http://host/'),
            array('http://host/a/', '../.', 'http://host/'),
            array('http://host/a/', '././.', 'http://host/a/'),
            array('http://host/a?query#ref', '../../../foo', 'http://host/foo'),
            array('http://host/a', '?foo=bar', 'http://host/a?foo=bar'),
            array('http://host/a?x=y#z', '?', 'http://host/a?'),
            array('http://host/a?x=y#z', '?foo=bar#com', 'http://host/a?foo=bar#com'),
            array('http://host/a', '#ref', 'http://host/a#ref'),
            array('http://host/a#b', '#', 'http://host/a#'),
            array('http://host/a?foo=bar#hello', '#bye', 'http://host/a?foo=bar#bye'),
            array('data:foobar', 'baz.html', 'data:baz.html'),
            array('data:foobar', 'data:baz', 'data:baz'),
            array('data:foobar', 'data:/base', 'data:/base'),
            array('data:foobar', 'http://host/', 'http://host/'),
            array('data:foobar', 'http:host', 'http:host'),
            array('http://foo/bar', './asd:fgh', 'http://foo/asd:fgh'),
            array('http://foo/bar', ':foo', 'http://foo/:foo'),
            array('http://foo/bar', ' hello world', 'http://foo/ hello world'),
            array('data:asdf', ':foo', 'data::foo'),
            array('http://host/a', ';foo', 'http://host/;foo'),
            array('http://host/a;', ';foo', 'http://host/;foo'),
            array('http://host/a', ';/../bar', 'http://host/bar'),
            array('http://host/a', '//another', 'http://another'),
            array('http://host/a', '//another/path?query#ref', 'http://another/path?query#ref'),
            array('http://host/a', '///another/path', 'http:///another/path'),
            array('http://host/a', '//Another\\\\path', 'http://Another\\\\path'),
            array('http://host/a', '//', 'http://'),
            array('http://host/a', '\\\\/another/path', 'http://host/\\\\/another/path'),
            array('http://host/a', '/\\\\Another\\\\path', 'http://host/\\\\Another\\\\path'),
            array('data:text/plain,baseURL', 'http://user:pass@foo:21/bar;par?b#c', 'http://user:pass@foo:21/bar;par?b#c'),
            array('data:text/plain,baseURL', 'http:foo.com', 'http:foo.com'),
            array('data:text/plain,baseURL', ' foo.com ', 'data:text/ foo.com '),
            array('data:text/plain,baseURL', 'http://f:21/ b ? d # e ', 'http://f:21/ b ? d # e '),
            array('data:text/plain,baseURL', 'http://f:/c', 'http://f:/c'),
            array('data:text/plain,baseURL', 'http://f:0/c', 'http://f:0/c'),
            array('data:text/plain,baseURL', 'http://f:00000000000000/c', 'http://f:00000000000000/c'),
            array('data:text/plain,baseURL', 'http://f:00000000000000000000080/c', 'http://f:00000000000000000000080/c'),
            array('data:text/plain,baseURL', 'http://f:b/c', 'http://f:b/c'),
            array('data:text/plain,baseURL', 'http://f: /c', 'http://f: /c'),
            array('data:text/plain,baseURL', 'http://f:fifty-two/c', 'http://f:fifty-two/c'),
            array('data:text/plain,baseURL', 'http://f:999999/c', 'http://f:999999/c'),
            array('data:text/plain,baseURL', 'http://f: 21 / b ? d # e ', 'http://f: 21 / b ? d # e '),
            array('data:text/plain,baseURL', '', 'data:text/plain,baseURL'),
            array('data:text/plain,baseURL', ':foo.com/', 'data:text/:foo.com/'),
            array('data:text/plain,baseURL', ':foo.com\\\\', 'data:text/:foo.com\\\\'),
            array('data:text/plain,baseURL', ':', 'data:text/:'),
            array('data:text/plain,baseURL', ':a', 'data:text/:a'),
            array('data:text/plain,baseURL', ':/', 'data:text/:/'),
            array('data:text/plain,baseURL', ':\\\\', 'data:text/:\\\\'),
            array('data:text/plain,baseURL', ':#', 'data:text/:#'),
            array('data:text/plain,baseURL', '#', 'data:text/plain,baseURL#'),
            array('data:text/plain,baseURL', '#/', 'data:text/plain,baseURL#/'),
            array('data:text/plain,baseURL', '#\\\\', 'data:text/plain,baseURL#\\\\'),
            array('data:text/plain,baseURL', '#;?', 'data:text/plain,baseURL#;?'),
            array('data:text/plain,baseURL', '?', 'data:text/plain,baseURL?'),
            array('data:text/plain,baseURL', '/', 'data:/'),
            array('data:text/plain,baseURL', ':23', 'data:text/:23'),
            array('data:text/plain,baseURL', '/:23', 'data:/:23'),
            array('data:text/plain,baseURL', '//', 'data://'),
            array('data:text/plain,baseURL', '::', 'data:text/::'),
            array('data:text/plain,baseURL', '::23', 'data:text/::23'),
            array('data:text/plain,baseURL', 'foo://', 'foo://'),
            array('data:text/plain,baseURL', 'http://a:b@c:29/d', 'http://a:b@c:29/d'),
            array('data:text/plain,baseURL', 'http::@c:29', 'http::@c:29'),
            array('data:text/plain,baseURL', 'http://&amp;a:foo(b]c@d:2/', 'http://&amp;a:foo(b]c@d:2/'),
            array('data:text/plain,baseURL', 'http://::@c@d:2', 'http://::@c@d:2'),
            array('data:text/plain,baseURL', 'http://foo.com:b@d/', 'http://foo.com:b@d/'),
            array('data:text/plain,baseURL', 'http://foo.com/\\\\@', 'http://foo.com/\\\\@'),
            array('data:text/plain,baseURL', 'http:\\\\\\\\foo.com\\\\', 'http:\\\\\\\\foo.com\\\\'),
            array('data:text/plain,baseURL', 'http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\', 'http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\'),
            array('data:text/plain,baseURL', 'foo:/', 'foo:/'),
            array('data:text/plain,baseURL', 'foo:/bar.com/', 'foo:/bar.com/'),
            array('data:text/plain,baseURL', 'foo://///////', 'foo://///////'),
            array('data:text/plain,baseURL', 'foo://///////bar.com/', 'foo://///////bar.com/'),
            array('data:text/plain,baseURL', 'foo:////://///', 'foo:////://///'),
            array('data:text/plain,baseURL', 'c:/foo', 'c:/foo'),
            array('data:text/plain,baseURL', '//foo/bar', 'data://foo/bar'),
            array('data:text/plain,baseURL', 'http://foo/path;a??e#f#g', 'http://foo/path;a??e#f#g'),
            array('data:text/plain,baseURL', 'http://foo/abcd?efgh?ijkl', 'http://foo/abcd?efgh?ijkl'),
            array('data:text/plain,baseURL', 'http://foo/abcd#foo?bar', 'http://foo/abcd#foo?bar'),
            array('data:text/plain,baseURL', '[61:24:74]:98', '[61:24:74]:98'),
            array('data:text/plain,baseURL', 'http://[61:27]:98', 'http://[61:27]:98'),
            array('data:text/plain,baseURL', 'http:[61:27]/:foo', 'http:[61:27]/:foo'),
            array('data:text/plain,baseURL', 'http://[1::2]:3:4', 'http://[1::2]:3:4'),
            array('data:text/plain,baseURL', 'http://2001::1', 'http://2001::1'),
            array('data:text/plain,baseURL', 'http://[2001::1', 'http://[2001::1'),
            array('data:text/plain,baseURL', 'http://2001::1]', 'http://2001::1]'),
            array('data:text/plain,baseURL', 'http://2001::1]:80', 'http://2001::1]:80'),
            array('data:text/plain,baseURL', 'http://[2001::1]', 'http://[2001::1]'),
            array('data:text/plain,baseURL', 'http://[2001::1]:80', 'http://[2001::1]:80'),
            array('data:text/plain,baseURL', 'http://[[::]]', 'http://[[::]]'),
            array('http://www.example.com/foo/bar', 'http://user:pass@foo:21/bar;par?b#c', 'http://user:pass@foo:21/bar;par?b#c'),
            array('http://www.example.com/foo/bar', 'http:foo.com', 'http:foo.com'),
            array('http://www.example.com/foo/bar', ' foo.com ', 'http://www.example.com/foo/ foo.com '),
            array('http://www.example.com/foo/bar', 'http://f:21/ b ? d # e ', 'http://f:21/ b ? d # e '),
            array('http://www.example.com/foo/bar', 'http://f:/c', 'http://f:/c'),
            array('http://www.example.com/foo/bar', 'http://f:0/c', 'http://f:0/c'),
            array('http://www.example.com/foo/bar', 'http://f:00000000000000/c', 'http://f:00000000000000/c'),
            array('http://www.example.com/foo/bar', 'http://f:00000000000000000000080/c', 'http://f:00000000000000000000080/c'),
            array('http://www.example.com/foo/bar', 'http://f:b/c', 'http://f:b/c'),
            array('http://www.example.com/foo/bar', 'http://f: /c', 'http://f: /c'),
            array('http://www.example.com/foo/bar', 'http://f:fifty-two/c', 'http://f:fifty-two/c'),
            array('http://www.example.com/foo/bar', 'http://f:999999/c', 'http://f:999999/c'),
            array('http://www.example.com/foo/bar', 'http://f: 21 / b ? d # e ', 'http://f: 21 / b ? d # e '),
            array('http://www.example.com/foo/bar', '', 'http://www.example.com/foo/bar'),
            array('http://www.example.com/foo/bar', ':foo.com/', 'http://www.example.com/foo/:foo.com/'),
            array('http://www.example.com/foo/bar', ':foo.com\\\\', 'http://www.example.com/foo/:foo.com\\\\'),
            array('http://www.example.com/foo/bar', ':', 'http://www.example.com/foo/:'),
            array('http://www.example.com/foo/bar', ':a', 'http://www.example.com/foo/:a'),
            array('http://www.example.com/foo/bar', ':/', 'http://www.example.com/foo/:/'),
            array('http://www.example.com/foo/bar', ':\\\\', 'http://www.example.com/foo/:\\\\'),
            array('http://www.example.com/foo/bar', ':#', 'http://www.example.com/foo/:#'),
            array('http://www.example.com/foo/bar', '#', 'http://www.example.com/foo/bar#'),
            array('http://www.example.com/foo/bar', '#/', 'http://www.example.com/foo/bar#/'),
            array('http://www.example.com/foo/bar', '#\\\\', 'http://www.example.com/foo/bar#\\\\'),
            array('http://www.example.com/foo/bar', '#;?', 'http://www.example.com/foo/bar#;?'),
            array('http://www.example.com/foo/bar', '?', 'http://www.example.com/foo/bar?'),
            array('http://www.example.com/foo/bar', '/', 'http://www.example.com/'),
            array('http://www.example.com/foo/bar', ':23', 'http://www.example.com/foo/:23'),
            array('http://www.example.com/foo/bar', '/:23', 'http://www.example.com/:23'),
            array('http://www.example.com/foo/bar', '//', 'http://'),
            array('http://www.example.com/foo/bar', '::', 'http://www.example.com/foo/::'),
            array('http://www.example.com/foo/bar', '::23', 'http://www.example.com/foo/::23'),
            array('http://www.example.com/foo/bar', 'foo://', 'foo://'),
            array('http://www.example.com/foo/bar', 'http://a:b@c:29/d', 'http://a:b@c:29/d'),
            array('http://www.example.com/foo/bar', 'http::@c:29', 'http::@c:29'),
            array('http://www.example.com/foo/bar', 'http://&amp;a:foo(b]c@d:2/', 'http://&amp;a:foo(b]c@d:2/'),
            array('http://www.example.com/foo/bar', 'http://::@c@d:2', 'http://::@c@d:2'),
            array('http://www.example.com/foo/bar', 'http://foo.com:b@d/', 'http://foo.com:b@d/'),
            array('http://www.example.com/foo/bar', 'http://foo.com/\\\\@', 'http://foo.com/\\\\@'),
            array('http://www.example.com/foo/bar', 'http:\\\\\\\\foo.com\\\\', 'http:\\\\\\\\foo.com\\\\'),
            array('http://www.example.com/foo/bar', 'http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\', 'http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\'),
            array('http://www.example.com/foo/bar', 'foo:/', 'foo:/'),
            array('http://www.example.com/foo/bar', 'foo:/bar.com/', 'foo:/bar.com/'),
            array('http://www.example.com/foo/bar', 'foo://///////', 'foo://///////'),
            array('http://www.example.com/foo/bar', 'foo://///////bar.com/', 'foo://///////bar.com/'),
            array('http://www.example.com/foo/bar', 'foo:////://///', 'foo:////://///'),
            array('http://www.example.com/foo/bar', 'c:/foo', 'c:/foo'),
            array('http://www.example.com/foo/bar', '//foo/bar', 'http://foo/bar'),
            array('http://www.example.com/foo/bar', 'http://foo/path;a??e#f#g', 'http://foo/path;a??e#f#g'),
            array('http://www.example.com/foo/bar', 'http://foo/abcd?efgh?ijkl', 'http://foo/abcd?efgh?ijkl'),
            array('http://www.example.com/foo/bar', 'http://foo/abcd#foo?bar', 'http://foo/abcd#foo?bar'),
            array('http://www.example.com/foo/bar', '[61:24:74]:98', '[61:24:74]:98'),
            array('http://www.example.com/foo/bar', 'http://[61:27]:98', 'http://[61:27]:98'),
            array('http://www.example.com/foo/bar', 'http:[61:27]/:foo', 'http:[61:27]/:foo'),
            array('http://www.example.com/foo/bar', 'http://[1::2]:3:4', 'http://[1::2]:3:4'),
            array('http://www.example.com/foo/bar', 'http://2001::1', 'http://2001::1'),
            array('http://www.example.com/foo/bar', 'http://[2001::1', 'http://[2001::1'),
            array('http://www.example.com/foo/bar', 'http://2001::1]', 'http://2001::1]'),
            array('http://www.example.com/foo/bar', 'http://2001::1]:80', 'http://2001::1]:80'),
            array('http://www.example.com/foo/bar', 'http://[2001::1]', 'http://[2001::1]'),
            array('http://www.example.com/foo/bar', 'http://[2001::1]:80', 'http://[2001::1]:80'),
            array('http://www.example.com/foo/bar', 'http://[[::]]', 'http://[[::]]'),
            array('http://example.org/foo/bar', 'http://example.com/', 'http://example.com/'),
            array('http://example.org/foo/bar', 'http://example.com/', 'http://example.com/'),
            array('http://example.org/foo/bar', '/', 'http://example.org/'),
            array('http://iris.test.ing/', '?value= foo bar', 'http://iris.test.ing/?value= foo bar'),
            array('http://user%40', 'example.com', 'http://user%40/example.com'),
            array('http://user%3Ainfo%40', 'example.com', 'http://user%3Ainfo%40/example.com'),
        );
    }

    /**
     * Test conversion to relative IRI reference
     *
     * @param string $iri            The reference IRI to convert to a
     *                               relative reference.
     * @param string $base           The base IRI.
     * @param bool   $schemaRelative Should schema-relative IRIs be created?
     * @param string $expected       The expected IRI reference.
     */
    #[DataProvider('relativizeProvider')]
    public function testRelativize($iri, $base, $schemaRelative, $expected)
    {
        $iri = new IRI($iri);
        $this->assertEquals($expected, (string)$iri->relativeTo($base, $schemaRelative));

        $base = new IRI($base);
        $this->assertEquals($expected, (string)$base->baseFor((string)$iri, $schemaRelative));
    }

    /**
     * Conversion to relative IRI reference test cases
     *
     * These test cases are adaptations of the tests in
     * {@link http://dig.csail.mit.edu/2005/ajar/ajaw/test/uri-test-doc.html}.
     *
     * @return array The test cases.
     */
    public static function relativizeProvider()
    {
        return array(  // $iri, $base, $schemaRelative, $expected
            array('http://ex/x/y/z', 'http://ex/x/y/z', false, 'z'),
            array('https://example.com/x/y/z', 'http://example.com/x/y/z', false, 'https://example.com/x/y/z'),
            array('http://example.com/x/y/z/', 'http://example.com/x/y/z/', false, './'),
            array('http://example.com/x/y/z/?query', 'http://example.com/x/y/z/', false, '?query'),
            array('http://example.com/x/y/z/#fragment', 'http://example.com/x/y/z/', false, '#fragment'),
            array('http://example.com/x/y/z', 'http://example.com/x/y/z', false, 'z'),
            array('http://example.com/x/y/z?query', 'http://example.com/x/y/z', false, '?query'),
            array('http://example.com/x/y/z#fragment', 'http://example.com/x/y/z', false, '#fragment'),
            array('http://example.com/x/y/z:a', 'http://example.com/x/y/', false, './z:a'),
            array('http://example.com/x/y/z', 'http://example.com/x/y', false, 'y/z'),
            array('http://example.com/x/y/z', 'http://example.com/a/b/c', false, '../../x/y/z'),
            array('http://example.com/x/y/z?query', 'http://example.com/a/b/c', false, '../../x/y/z?query'),
            array('http://example.com/x/y/z#fragment', 'http://example.com/a/b/c', false, '../../x/y/z#fragment'),
            array('http://example.com/x/y/z?query#fragment', 'http://example.com/a/b/c', false, '../../x/y/z?query#fragment'),
            array('http://example.org/x/y/z', 'http://example.com/a/b/c', false, 'http://example.org/x/y/z'),
            array('http://example.org/x/y/z', 'http://example.com/a/b/c', true, '//example.org/x/y/z'),
            array('http://example/x/abc', 'http://example/x/y/z', false, '../abc'),
            array('file:/ex/x/q/r#s', 'file:/ex/x/y', false, 'q/r#s'),
            array('http://ex/x/y', null, false, 'http://ex/x/y'),
            array('http://example.com/a', 'http://example.com/a/', false, '../a'),
            array('http://example.com/a', 'http://example.com/a/b', false, '../a'),
            array('http://example.com/a/b/c?query', 'http://example.com/a/b/c?query', false, '?query'),
            array('http://ex/r', 'http://ex/x/y/z', false, '../../r'),
            // http://dig.csail.mit.edu/2005/ajar/ajaw/test/uri-test-doc.html
            array('bar:abc', 'foo:xyz', false, 'bar:abc'),
            array('http://example/x/abc', 'http://example/x/y/z', false, '../abc'),
            array('http://example/x/abc', 'http://example2/x/y/z', false, 'http://example/x/abc'),
            array('http://example/x/abc', 'http://example2/x/y/z', true, '//example/x/abc'),
            array('http://ex/x/r', 'http://ex/x/y/z', false, '../r'),
            array('http://ex/x/q/r', 'http://ex/x/y', false, 'q/r'),
            array('http://ex/x/q/r#s', 'http://ex/x/y', false, 'q/r#s'),
            array('http://ex/x/q/r#s/t', 'http://ex/x/y', false, 'q/r#s/t'),
            array('ftp://ex/x/q/r', 'http://ex/x/y', false, 'ftp://ex/x/q/r'),
            array('http://ex/x/y/z/', 'http://ex/x/y', false, 'y/z/'),
            array('file:/swap/test/animal.rdf#Animal', 'file:/swap/test/animal.rdf', false, '#Animal'),
            array('file:/e/x/abc', 'file:/e/x/y/z', false, '../abc'),
            array('file:/example/x/abc', 'file:/example2/x/y/z', false, '../../../example/x/abc'),
            array('file:/ex/x/r', 'file:/ex/x/y/z', false, '../r'),
            array('file:/r', 'file:/ex/x/y/z', false, '../../../r'),
            array('file:/ex/x/q/r', 'file:/ex/x/y/z', false, '../q/r'),
            array('file:/ex/x/q/r#s', 'file:/ex/x/y', false, 'q/r#s'),
            array('file:/ex/x/q/r#', 'file:/ex/x/y', false, 'q/r#'),
            array('file:/ex/x/q/r#s/t', 'file:/ex/x/y', false, 'q/r#s/t'),
            array('ftp://ex/x/q/r', 'file:/ex/x/y', false, 'ftp://ex/x/q/r'),
            array('file:/ex/x/y/z/', 'file:/ex/x/y/', false, 'z/'),
            array('file://meetings.example.com/cal#m1', 'file:/devel/WWW/2000/10/swap/test/reluri-1.n3', false, 'file://meetings.example.com/cal#m1'),
            array('file://meetings.example.com/cal#m1', 'file:/devel/WWW/2000/10/swap/test/reluri-1.n3', true, '//meetings.example.com/cal#m1'),
            array('file://meetings.example.com/cal#m1', 'file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3', false, 'file://meetings.example.com/cal#m1'),
            array('file://meetings.example.com/cal#m1', 'file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3', true, '//meetings.example.com/cal#m1'),
            array('file:/some/dir/#blort', 'file:/some/dir/foo', false, './#blort'),
            array('file:/some/dir/#', 'file:/some/dir/foo', false, './#'),
            array('http://example/x/abc', 'http://example/x/y%2Fz', false, 'abc'),
            array('http://example/x%2Fabc', 'http://example/x/y/z', false, '../../x%2Fabc'),
            array('http://example/x%2Fabc', 'http://example/x/y%2Fz', false, '../x%2Fabc'),
            array('http://example/x%2Fy/abc', 'http://example/x%2Fy/z', false, 'abc'),
            array('http://example/x/', 'http://example/x/abc.efg', false, './'),   // ???
            array('http://www.w3.org/2002/01/tr-automation/tr.rdf', 'http://www.w3.org/People/Berners-Lee/card.rdf', false, '../../2002/01/tr-automation/tr.rdf'),
        );
    }

    /**
     * Invalid IRI test cases
     *
     * These test cases were taken from
     * {@link http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html}.
     *
     * @return array The invalid IRI test cases.
     */
    public function invalidIriProvider()
    {
        return array(
            array('[2010:836B:4179::836B:4179]'),
            array('http://foo.org:80Path/More'),
            array('::'),
            array(' '),  // is this an invalid IRI??
            array('%'),
            array('A%Z'),
            array('%ZZ'),
            array('%AZ'),
            array('A C'),
            array('A\C"'),
            array('A`C'),
            array('A<C'),
            array('A>C'),
            array('A^C'),
            array('A\\C'),
            array('A{C'),
            array('A|C'),
            array('A}C'),
            array('A[C'),
            array('A]C'),
            array('A[**]C'),
            array('http://[xyz]/'),
            array('http://]/'),
            array('http://example.org/[2010:836B:4179::836B:4179]'),
            array('http://example.org/abc#[2010:836B:4179::836B:4179]'),
            array('http://example.org/xxx/[qwerty]#a[b]'),
            array('http://example.org/xxx/qwerty#a#b'),
            array('http://user:pass@example.org:99aaa/bbb')
        );
    }

    /**
     * Normalization test cases
     *
     * These test cases were taken from
     * {@link http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html}.
     *
     * @return array The normalization test cases.
     */
    public function normalizationProvider()
    {
        return array(
            // Case normalization; cf. RFC3986 section 6.2.2.1 (NOTE: authority case normalization is not performed)
            array('HTTP://EXAMPLE.com/Root/%2a?%2b#%2c', 'http://EXAMPLE.com/Root/%2A?%2B#%2C'),
            // Encoding normalization; cf. RFC3986 section 6.2.2.2
            array('HTTP://EXAMPLE.com/Root/%7eMe/', 'HTTP://EXAMPLE.com/Root/~Me/'),
            array('foo:%40%41%5a%5b%60%61%7a%7b%2f%30%39%3a%2d%2e%5f%7e', 'foo:%40AZ%5b%60az%7b%2f09%3a-._~'),
            array('foo:%3a%2f%3f%23%5b%5d%40', 'foo:%3a%2f%3f%23%5b%5d%40'),
            // Path segment normalization; cf. RFC3986 section 6.2.2.3
            array('http://example/a/b/../../c', 'http://example/c'),
            array('http://example/a/b/c/../../', 'http://example/a/'),
            array('http://example/a/b/c/./', 'http://example/a/b/c/'),
            array('http://example/a/b/c/.././', 'http://example/a/b/'),
            array('http://example/a/b/c/d/../../../../e', 'http://example/e'),
            array('http://example/a/b/c/d/../.././../../e', 'http://example/e'),
            array('http://example/a/b/../.././../../e', 'http://example/e'),
            array('foo:a/b/../.././../../e', 'foo:e')
        );
    }
}