Add copyright notices to all source files and put a license in LICENSE.
[versaplex.git] / wvdotnet / t / wvurl.t.cs
blob0d83bbd03f2d4c9bd21c8a3e7a3dd8e84d1df6e9
1 /*
2 * Versaplex:
3 * Copyright (C)2007-2008 Versabanq Innovations Inc. and contributors.
4 * See the included file named LICENSE for license information.
5 */
6 #include "wvtest.cs.h"
7 using System;
8 using Wv.Test;
9 using Wv;
11 [TestFixture]
12 public class WvUrlTests
14 [Test] public void urls()
16 WvUrl u;
18 u = new WvUrl("/foo/blah");
19 WVPASSEQ(u.ToString(), "file:/foo/blah");
20 WVPASSEQ(u.host, null);
21 WVPASSEQ(u.port, 0);
23 u = new WvUrl("foo/blah");
24 WVPASSEQ(u.ToString(), "file:foo/blah");
25 WVPASSEQ(u.host, null);
26 WVPASSEQ(u.port, 0);
28 u = new WvUrl("file:foo/blah");
29 WVPASSEQ(u.ToString(), "file:foo/blah");
31 u = new WvUrl("whatever:anything@nothing:stuff");
32 WVPASSEQ(u.ToString(), "whatever:anything@nothing:stuff");
33 WVPASSEQ(u.host, null);
34 WVPASSEQ(u.port, 0);
35 WVPASSEQ(u.path, "anything@nothing:stuff");
37 u = new WvUrl("http:");
38 WVPASSEQ(u.ToString(), "http:");
40 u = new WvUrl("http://");
41 WVPASSEQ(u.ToString(), "http:");
43 u = new WvUrl("http://user:pass@host:57/path/to/stuff");
44 WVPASSEQ(u.ToString(), "http://user@host:57/path/to/stuff");
45 WVPASSEQ(u.ToString(true), "http://user:pass@host:57/path/to/stuff");
46 WVPASSEQ(u.method, "http");
47 WVPASSEQ(u.user, "user");
48 WVPASSEQ(u.password, "pass");
49 WVPASSEQ(u.host, "host");
50 WVPASSEQ(u.port, 57);
51 WVPASSEQ(u.path, "/path/to/stuff");
53 // Microsoft UNC-style paths are actually valid URLs by our measure :)
54 u = new WvUrl(@"\\server\path\to\stuff");
55 WVPASSEQ(u.ToString(), "file://server/path/to/stuff");
56 WVPASSEQ(u.method, "file");
57 WVPASSEQ(u.user, null);
58 WVPASSEQ(u.password, null);
59 WVPASSEQ(u.host, "server");
60 WVPASSEQ(u.port, 0);
61 WVPASSEQ(u.path, "/path/to/stuff");
63 u = new WvUrl(@"\\ser:9@1:23\path\to\stuff");
64 WVPASSEQ(u.ToString(), "file://ser@1:23/path/to/stuff");
65 WVPASSEQ(u.ToString(true), "file://ser:9@1:23/path/to/stuff");
66 WVPASSEQ(u.method, "file");
67 WVPASSEQ(u.user, "ser");
68 WVPASSEQ(u.password, "9");
69 WVPASSEQ(u.host, "1");
70 WVPASSEQ(u.port, 23);
71 WVPASSEQ(u.path, "/path/to/stuff");
73 u = new WvUrl("://:@:");
74 WVPASSEQ(u.ToString(), ":");
75 WVPASSEQ(u.method, "");
76 WVPASSEQ(u.user, null);
77 WVPASSEQ(u.password, null);
78 WVPASSEQ(u.host, null);
79 WVPASSEQ(u.port, 0);
80 WVPASSEQ(u.path, "");
82 u = new WvUrl("://:47@:");
83 WVPASSEQ(u.ToString(), "://");
84 WVPASSEQ(u.ToString(true), "://:47@");