Code

Make curvature work again by fixing a minor omission
[inkscape.git] / src / dom / work / testuri.cpp
1 /**
2  * Phoebe DOM Implementation.
3  *
4  * This is a C++ approximation of the W3C DOM model, which follows
5  * fairly closely the specifications in the various .idl files, copies of
6  * which are provided for reference.  Most important is this one:
7  *
8  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
9  *
10  * Authors:
11  *   Bob Jamison
12  *
13  * Copyright (C) 2006-2008 Bob Jamison
14  *
15  *  This library is free software; you can redistribute it and/or
16  *  modify it under the terms of the GNU Lesser General Public
17  *  License as published by the Free Software Foundation; either
18  *  version 2.1 of the License, or (at your option) any later version.
19  *
20  *  This library is distributed in the hope that it will be useful,
21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  *  Lesser General Public License for more details.
24  *
25  *  You should have received a copy of the GNU Lesser General Public
26  *  License along with this library; if not, write to the Free Software
27  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
30 #include "io/uristream.h"
33 typedef org::w3c::dom::URI URI;
35 static bool doURI(const char *uristr)
36 {
37     org::w3c::dom::URI uri(uristr);
38     printf("##################################\n");
39     printf("String  : '%s'\n", uristr);
40     printf("URI     : '%s'\n", uri.toString().c_str());
41     printf("scheme  : '%s'\n", uri.getSchemeStr().c_str());
42     printf("auth    : '%s'\n", uri.getAuthority().c_str());
43     printf("path    : '%s'\n", uri.getPath().c_str());
44     printf("query   : '%s'\n", uri.getQuery().c_str());
45     printf("fragment: '%s'\n", uri.getFragment().c_str());
46     printf("absolute: '%d'\n", uri.isAbsolute());
47     printf("opaque  : '%d'\n", uri.isOpaque());
49     return true;
50 }
54 static bool test1()
55 {
56     printf("########################################\n");
57     printf("## TEST 1\n");
58     printf("########################################\n");
59     const char *uristr = "http://www.mit.edu:80/index.html?test=good#hello";
60     doURI(uristr);
61     uristr = "http://www.mit.edu:80";
62     doURI(uristr);
63     uristr = "http://résumé.example.org";
64     doURI(uristr);
66     printf("\n\n");
67     return true;
68 }
70 static bool test2()
71 {
72     printf("########################################\n");
73     printf("## TEST 2\n");
74     printf("########################################\n");
75     printf("############ uri.resolve() #######\n");
76     URI absUri("file:/this/is/an/./absolute/path.sfx");
77     printf("absUri:%s\n", absUri.getPath().c_str());
78     URI relUri("../this/is/a/./relative/path.sfx");
79     printf("relUri:%s\n", relUri.getPath().c_str());
80     URI resUri = absUri.resolve(relUri);
81     printf("resUri:%s\n", resUri.getPath().c_str());
83     printf("\n\n");
84     return true;
85 }
87 static bool test3()
88 {
89     printf("########################################\n");
90     printf("## TEST 3\n");
91     printf("########################################\n");
92     printf("############ windows-style uri.resolve() #######\n");
93     URI absUri("file:C:\\this\\is\\an\\.\\absolute/path.sfx");
94     printf("absUri:%s\n", absUri.getPath().c_str());
95     printf("absUri:%s\n", absUri.getNativePath().c_str());
96     URI relUri("..\\this\\is\\a\\.\\relative\\path.sfx");
97     printf("relUri:%s\n", relUri.getPath().c_str());
98     printf("relUri:%s\n", relUri.getNativePath().c_str());
99     URI resUri = absUri.resolve(relUri);
100     printf("resUri:%s\n", resUri.getPath().c_str());
101     printf("resUri:%s\n", resUri.getNativePath().c_str());
103     printf("\n\n");
104     return true;
108 int main(int argc, char **argv)
110     if (!test1())
111         return 1;
112     if (!test2())
113         return 1;
114     if (!test3())
115         return 1;
116     return 0;