1#!perl
2
3use strict;
4use warnings;
5
6use Test::More 0.86;
7use HTTP::Tiny;
8
9my @tests = (
10    [ 'HtTp://Example.COM/',                 'http',  'example.com',    80, '/', '',          ],
11    [ 'HtTp://Example.com:1024/',            'http',  'example.com',  1024, '/', '',          ],
12    [ 'http://example.com',                  'http',  'example.com',    80, '/', '',          ],
13    [ 'http://example.com:',                 'http',  'example.com',    80, '/', '',          ],
14    [ 'http://foo@example.com:',             'http',  'example.com',    80, '/', 'foo',          ],
15    [ 'http://foo:pass@example.com:',        'http',  'example.com',    80, '/', 'foo:pass',          ],
16    [ 'http://@example.com:',                'http',  'example.com',    80, '/', '',          ],
17    [ 'http://example.com?foo=bar',          'http',  'example.com',    80, '/?foo=bar', '',  ],
18    [ 'http://example.com?foo=bar#fragment', 'http',  'example.com',    80, '/?foo=bar', '',  ],
19    [ 'http://example.com/path?foo=bar',     'http',  'example.com',    80, '/path?foo=bar', '',  ],
20    [ 'http:///path?foo=bar',                'http',  'localhost',      80, '/path?foo=bar', '',  ],
21    [ 'HTTPS://example.com/',                'https', 'example.com',   443, '/', '',          ],
22    [ 'http://[::]:1024',                    'http',  '[::]',         1024, '/', '',          ],
23    [ 'xxx://foo/',                          'xxx',   'foo',         undef, '/', '',          ],
24);
25
26plan tests => scalar @tests;
27
28for my $test (@tests) {
29    my $url = shift(@$test);
30    my $got = [ HTTP::Tiny->_split_url($url) ];
31    my $exp = $test;
32    is_deeply($got, $exp, "->split_url('$url')") or diag explain $got;
33}
34
35
36