Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / websvcs / tests / Test_URL_Addr.cpp
blobd41958f28cb8a31ac53bc86792e70e8708c9bd07
1 #include "websvcs/lib/URL_Addr.h"
2 #include "ace/Log_Msg.h"
5 void test_http_addr ();
6 void test_ftp_addr ();
7 void test_mailto_addr ();
8 void test_url_addr ();
10 int ACE_TMAIN (int, ACE_TCHAR*[])
12 test_http_addr ();
13 test_ftp_addr ();
14 test_mailto_addr ();
15 test_url_addr ();
16 return 0;
19 #define HTTP_TEST_ARRAY \
20 ACE_TEXT("http://www.cs.wustl.edu/"), \
21 ACE_TEXT("http://www.cs.wustl.edu/index.html"), \
22 ACE_TEXT("http://www.cs.wustl.edu/form?var=foo"), \
23 ACE_TEXT("http://www.notexist.com:8080/index.html"), \
24 ACE_TEXT("http://www.notexist.com:80/index.html"), \
25 ACE_TEXT("ftp://foo"), \
26 ACE_TEXT("http://www/?kkk//")
28 #define FTP_TEST_ARRAY \
29 ACE_TEXT("ftp://www.cs.wustl.edu/"), \
30 ACE_TEXT("ftp://user@www.cs.wustl.edu/"), \
31 ACE_TEXT("ftp://user:pass@www.cs.wustl.edu/"), \
32 ACE_TEXT("ftp://user:pass@www.cs.wustl.edu/path"), \
33 ACE_TEXT("ftp://www.cs.wustl.edu"), \
34 ACE_TEXT("http://www.cs.wustl.edu/index.html")
36 #define MAILTO_TEST_ARRAY \
37 ACE_TEXT("mailto:ace-users@cs.wustl.edu"), \
38 ACE_TEXT("mailto:majordomo@cs.wustl.edu?Subject: subscribe ace-users"), \
39 ACE_TEXT("mailto:nobody"), \
40 ACE_TEXT("http://www.cs.wustl.edu")
42 #define URL_TEST_ARRAY \
43 ACE_TEXT("file:/etc/passwd")
45 void test_http_addr ()
47 static const ACE_TCHAR *addresses[] = {
48 HTTP_TEST_ARRAY
50 static int naddresses = sizeof(addresses)/sizeof(addresses[0]);
51 for (int i = 0; i < naddresses; ++i)
53 ACE_HTTP_Addr addr;
54 if (addr.string_to_addr (addresses[i]) != 0)
56 ACE_ERROR ((LM_ERROR,
57 "HTTP[%d]\n"
58 " \"%s\" ERROR\n",
59 i, addresses[i]));
60 continue;
63 ACE_TCHAR buffer[BUFSIZ];
64 if (addr.addr_to_string (buffer, BUFSIZ, i%2) == 0)
66 ACE_DEBUG ((LM_DEBUG,
67 "HTTP[%d]\n"
68 " \"%s\"\n"
69 " <%s>\n"
70 " <%s>\n",
71 i, addresses[i],
72 addr.get_url (),
73 buffer));
75 else
77 ACE_ERROR ((LM_ERROR,
78 "HTTP[%d]\n"
79 " \"%s\" ERROR\n",
80 i, addresses[i]));
85 void test_ftp_addr ()
87 static const ACE_TCHAR *addresses[] = {
88 FTP_TEST_ARRAY
90 static int naddresses = sizeof(addresses)/sizeof(addresses[0]);
91 for (int i = 0; i < naddresses; ++i)
93 ACE_FTP_Addr addr;
94 if (addr.string_to_addr (addresses[i]) != 0)
96 ACE_ERROR ((LM_ERROR,
97 "FTP[%d]\n"
98 " \"%s\" ERROR\n",
99 i, addresses[i]));
100 continue;
103 ACE_TCHAR buffer[BUFSIZ];
104 if (addr.addr_to_string (buffer, BUFSIZ, i%2) == 0)
106 ACE_DEBUG ((LM_DEBUG,
107 "FTP[%d]\n"
108 " \"%s\"\n"
109 " <%s>\n"
110 " <%s>\n",
111 i, addresses[i],
112 addr.get_url (),
113 buffer));
115 else
117 ACE_ERROR ((LM_ERROR,
118 "FTP[%d]\n"
119 " \"%s\" ERROR\n",
120 i, addresses[i]));
125 void test_mailto_addr ()
127 static const ACE_TCHAR *addresses[] = {
128 MAILTO_TEST_ARRAY
130 static int naddresses = sizeof(addresses)/sizeof(addresses[0]);
131 for (int i = 0; i < naddresses; ++i)
133 ACE_Mailto_Addr addr;
134 if (addr.string_to_addr (addresses[i]) != 0)
136 ACE_ERROR ((LM_ERROR,
137 "Mailto[%d]\n"
138 " \"%s\" ERROR\n",
139 i, addresses[i]));
140 continue;
143 ACE_TCHAR buffer[BUFSIZ];
144 if (addr.addr_to_string (buffer, BUFSIZ, i%2) == 0)
146 ACE_DEBUG ((LM_DEBUG,
147 "Mailto[%d]\n"
148 " \"%s\"\n"
149 " <%s>\n"
150 " <%s>\n",
151 i, addresses[i],
152 addr.get_url (),
153 buffer));
155 else
157 ACE_ERROR ((LM_ERROR,
158 "Mailto[%d]\n"
159 " \"%s\" ERROR\n",
160 i, addresses[i]));
165 void test_url_addr ()
167 static const ACE_TCHAR *addresses[] = {
168 HTTP_TEST_ARRAY,
169 FTP_TEST_ARRAY,
170 MAILTO_TEST_ARRAY,
171 URL_TEST_ARRAY
173 static int naddresses = sizeof(addresses)/sizeof(addresses[0]);
174 for (int i = 0; i < naddresses; ++i)
176 ACE_URL_Addr* addr =
177 ACE_URL_Addr::create_address (addresses[i]);
178 if (addr == 0)
180 ACE_ERROR ((LM_ERROR,
181 "URL[%d]\n"
182 " \"%s\" ERROR\n",
183 i, addresses[i]));
184 continue;
187 ACE_TCHAR buffer[BUFSIZ];
188 if (addr->addr_to_string (buffer, BUFSIZ, i%2) == 0)
190 ACE_DEBUG ((LM_DEBUG,
191 "URL[%d]\n"
192 " \"%s\"\n"
193 " <%s>\n"
194 " <%s>\n",
195 i, addresses[i],
196 addr->get_url (),
197 buffer));
199 else
201 ACE_ERROR ((LM_ERROR,
202 "URL[%d]\n"
203 " \"%s\" ERROR\n",
204 i, addresses[i]));