File: urltest.cpp

package info (click to toggle)
pcm 202502-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,164 kB
  • sloc: cpp: 44,347; ansic: 1,161; sh: 778; python: 388; awk: 28; makefile: 13
file content (44 lines) | stat: -rw-r--r-- 1,232 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
#define UNIT_TEST 1

#include "../src/pcm-sensor-server.cpp"

#undef UNIT_TEST

std::vector<std::string> urls{
    "http://otto:test@www.intel.com/~otto/file1.txt",
    "file://localhost/c/mnt/cd/file2.txt",
    "ftp://otto%40yahoo.com:abcd%3B1234@www.intel.com:30/xyz.php?a=1&t=3",
    "gopher://otto@hostname1.intel.com:8080/file3.zyx",
    "www.intel.com",
    "http://www.blah.org/file.html#firstmark",
    "http://www.blah.org/file.html#firstmark%21%23",
    "localhost",
    "https://www.intel.com",
    "://google.com/",
    "https://intc.com/request?",
    "htt:ps//www.intel.com",
    "http://www.intel.com:66666/",
    "http:///",
    "http://[1234::1234::1234/",
    "http://@www.intel.com",
    "http://otto@:www.intel.com",
    "https://:@www.intel.com",
    "https://user:@www.intel.com",
    "http:www.intel.com/",
    "http://ww\x00\x00\x00rstmark\x0a"
};

int main( int, char** ) {
    int errors = 0;
    for ( auto & s : urls ) {
        try {
            std::cout << s << "\n";
            URL x = URL::parse( s );
            x.printURL(std::cout);
	} catch (const std::runtime_error & x ) {
            std::cout << "\"" << s << "\": " << x.what() << "\n";
	    ++errors;
        }
    }
    return errors;
}