15 if (!(nominal == actual))
17 return (nominal == actual);
23 TUri base =
TUri(
"http://a/b/c/d;p?q");
27 success &= TestResolutionHelper(
"g:h",
"g:h", base);
28 success &= TestResolutionHelper(
"g",
"http://a/b/c/g", base);
29 success &= TestResolutionHelper(
"./g",
"http://a/b/c/g", base);
30 success &= TestResolutionHelper(
"g/",
"http://a/b/c/g/", base);
31 success &= TestResolutionHelper(
"/g",
"http://a/g", base);
32 success &= TestResolutionHelper(
"//g",
"http://g", base);
33 success &= TestResolutionHelper(
"?y",
"http://a/b/c/d;p?y", base);
34 success &= TestResolutionHelper(
"g?y",
"http://a/b/c/g?y", base);
35 success &= TestResolutionHelper(
"#s",
"http://a/b/c/d;p?q#s", base);
36 success &= TestResolutionHelper(
"g#s",
"http://a/b/c/g#s", base);
37 success &= TestResolutionHelper(
"g?y#s",
"http://a/b/c/g?y#s", base);
38 success &= TestResolutionHelper(
";x",
"http://a/b/c/;x", base);
39 success &= TestResolutionHelper(
"g;x",
"http://a/b/c/g;x", base);
40 success &= TestResolutionHelper(
"g;x?y#s",
"http://a/b/c/g;x?y#s", base);
41 success &= TestResolutionHelper(
"",
"http://a/b/c/d;p?q", base);
42 success &= TestResolutionHelper(
".",
"http://a/b/c/", base);
43 success &= TestResolutionHelper(
"./",
"http://a/b/c/", base);
44 success &= TestResolutionHelper(
"..",
"http://a/b/", base);
45 success &= TestResolutionHelper(
"../",
"http://a/b/", base);
46 success &= TestResolutionHelper(
"../g",
"http://a/b/g", base);
47 success &= TestResolutionHelper(
"../..",
"http://a/", base);
48 success &= TestResolutionHelper(
"../../",
"http://a/", base);
49 success &= TestResolutionHelper(
"../../g",
"http://a/g", base);
51 success &= TestResolutionHelper(
"../../../g",
"http://a/g", base);
52 success &= TestResolutionHelper(
"../../../../g",
"http://a/g", base);
53 success &= TestResolutionHelper(
"/./g",
"http://a/g", base);
54 success &= TestResolutionHelper(
"/../g",
"http://a/g", base);
55 success &= TestResolutionHelper(
"g.",
"http://a/b/c/g.", base);
56 success &= TestResolutionHelper(
".g",
"http://a/b/c/.g", base);
57 success &= TestResolutionHelper(
"g..",
"http://a/b/c/g..", base);
58 success &= TestResolutionHelper(
"..g",
"http://a/b/c/..g", base);
59 success &= TestResolutionHelper(
"./../g",
"http://a/b/g", base);
60 success &= TestResolutionHelper(
"./g/.",
"http://a/b/c/g/", base);
61 success &= TestResolutionHelper(
"g/./h",
"http://a/b/c/g/h", base);
62 success &= TestResolutionHelper(
"g/../h",
"http://a/b/c/h", base);
63 success &= TestResolutionHelper(
"g;x=1/./y",
"http://a/b/c/g;x=1/y", base);
64 success &= TestResolutionHelper(
"g;x=1/../y",
"http://a/b/c/y", base);
65 success &= TestResolutionHelper(
"g?y/./x",
"http://a/b/c/g?y/./x", base);
66 success &= TestResolutionHelper(
"g?y/../x",
"http://a/b/c/g?y/../x", base);
67 success &= TestResolutionHelper(
"g#s/./x",
"http://a/b/c/g#s/./x", base);
68 success &= TestResolutionHelper(
"g#s/../x",
"http://a/b/c/g#s/../x", base);
69 success &= TestResolutionHelper(
"http:g",
"http:g", base);
77 for (
char i = 0; i < 127; i++) {
80 sprintf(buffer,
"0x%02x, ", i);
81 errors = errors + buffer;
93 TString composed =
"http://user:pass@host.org/some/path/file.avi?key1=value1#anchor3";
98 uri.
SetPath(
"/some/path/file.avi");
101 return uri.
GetUri() == composed;
104void Answer(
Bool_t success)
109 Printf(
"---> F A I L E D F A I L E D F A I L E D\n");
116 valid &=
TUri(
"ftp://ftp.is.co.za/rfc/rfc1808.txt").
IsUri();
117 valid &=
TUri(
"http://www.ietf.org/rfc/rfc2396.txt").
IsUri();
119 valid &=
TUri(
"mailto:John.Doe@example.com").
IsUri();
120 valid &=
TUri(
"news:comp.infosystems.www.servers.unix").
IsUri();
121 valid &=
TUri(
"tel:+1-816-555-1212").
IsUri();
122 valid &=
TUri(
"telnet://192.0.2.16:80/").
IsUri();
123 valid &=
TUri(
"urn:oasis:names:specification:docbook:dtd:xml:4.1.2").
IsUri();
130 Printf(
"\n\nTUri test macro ...");
131 Printf(
"---> Validation");
132 Answer(TestValidation());
133 Printf(
"---> Reference Resolution");
134 Answer(TestResolution());
135 Printf(
"---> PCT Conversion");
137 Printf(
"---> Equivalence and Normalisation");
138 Answer(
TUri(
"example://a/b/c/%7Bfoo%7D") ==
TUri(
"eXAMPLE://a/./b/../b/%63/%7bfoo%7d"));
139 Printf(
"---> Composition");
140 Answer(TestComposition());
void Printf(const char *fmt,...)
const char * Data() const
This class represents a RFC 3986 compatible URI.
Bool_t SetScheme(const TString &scheme)
Set scheme component of URI:
Bool_t SetFragment(const TString &fragment)
Set fragment component of URI:
Bool_t SetPath(const TString &path)
Set path component of URI:
Bool_t SetUserInfo(const TString &userinfo)
Set userinfo component of URI:
Bool_t IsUri() const
Returns kTRUE if instance qualifies as URI URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] ...
static const TString PctEncode(const TString &source)
Percent-encode and return the given string according to RFC 3986 in principle, this function cannot f...
const TString GetUri() const
Returns the whole URI - an implementation of chapter 5.3 component recomposition.
static TUri Transform(const TUri &reference, const TUri &base)
Transform a URI reference into its target URI using given a base URI.
Bool_t SetQuery(const TString &path)
Set query component of URI:
Bool_t SetHost(const TString &host)
Set host component of URI:
static const TString PctDecode(const TString &source)
Percent-decode the given string according to chapter 2.1 we assume a valid pct-encoded string.