@@ -6,49 +6,9 @@ package websocket
6
6
7
7
import (
8
8
"net/url"
9
- "reflect"
10
9
"testing"
11
10
)
12
11
13
- var parseURLTests = []struct {
14
- s string
15
- u * url.URL
16
- rui string
17
- }{
18
- {"ws://example.com/" , & url.URL {Scheme : "ws" , Host : "example.com" , Opaque : "/" }, "/" },
19
- {"ws://example.com" , & url.URL {Scheme : "ws" , Host : "example.com" , Opaque : "/" }, "/" },
20
- {"ws://example.com:7777/" , & url.URL {Scheme : "ws" , Host : "example.com:7777" , Opaque : "/" }, "/" },
21
- {"wss://example.com/" , & url.URL {Scheme : "wss" , Host : "example.com" , Opaque : "/" }, "/" },
22
- {"wss://example.com/a/b" , & url.URL {Scheme : "wss" , Host : "example.com" , Opaque : "/a/b" }, "/a/b" },
23
- {"ss://example.com/a/b" , nil , "" },
24
- {
"ws://[email protected] /" ,
nil ,
"" },
25
- {"wss://example.com/a/b?x=y" , & url.URL {Scheme : "wss" , Host : "example.com" , Opaque : "/a/b" , RawQuery : "x=y" }, "/a/b?x=y" },
26
- {"wss://example.com?x=y" , & url.URL {Scheme : "wss" , Host : "example.com" , Opaque : "/" , RawQuery : "x=y" }, "/?x=y" },
27
- }
28
-
29
- func TestParseURL (t * testing.T ) {
30
- for _ , tt := range parseURLTests {
31
- u , err := parseURL (tt .s )
32
- if tt .u != nil && err != nil {
33
- t .Errorf ("parseURL(%q) returned error %v" , tt .s , err )
34
- continue
35
- }
36
- if tt .u == nil {
37
- if err == nil {
38
- t .Errorf ("parseURL(%q) did not return error" , tt .s )
39
- }
40
- continue
41
- }
42
- if ! reflect .DeepEqual (u , tt .u ) {
43
- t .Errorf ("parseURL(%q) = %v, want %v" , tt .s , u , tt .u )
44
- continue
45
- }
46
- if u .RequestURI () != tt .rui {
47
- t .Errorf ("parseURL(%q).RequestURI() = %v, want %v" , tt .s , u .RequestURI (), tt .rui )
48
- }
49
- }
50
- }
51
-
52
12
var hostPortNoPortTests = []struct {
53
13
u * url.URL
54
14
hostPort , hostNoPort string
0 commit comments