-
Notifications
You must be signed in to change notification settings - Fork 486
/
Copy pathurltest.cpp
44 lines (40 loc) · 1.2 KB
/
urltest.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
#define UNIT_TEST 1
#include "../src/pcm-sensor-server.cpp"
#undef UNIT_TEST
std::vector<std::string> urls{
"http://otto:[email protected]/~otto/file1.txt",
"file://localhost/c/mnt/cd/file2.txt",
"ftp://otto%40yahoo.com:abcd%[email protected]:30/xyz.php?a=1&t=3",
"gopher://[email protected]: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;
}