1 // Copyright 2014 The Gorilla WebSocket Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 var hostPortNoPortTests = []struct {
14 hostPort, hostNoPort string
16 {&url.URL{Scheme: "ws", Host: "example.com"}, "example.com:80", "example.com"},
17 {&url.URL{Scheme: "wss", Host: "example.com"}, "example.com:443", "example.com"},
18 {&url.URL{Scheme: "ws", Host: "example.com:7777"}, "example.com:7777", "example.com"},
19 {&url.URL{Scheme: "wss", Host: "example.com:7777"}, "example.com:7777", "example.com"},
22 func TestHostPortNoPort(t *testing.T) {
23 for _, tt := range hostPortNoPortTests {
24 hostPort, hostNoPort := hostPortNoPort(tt.u)
25 if hostPort != tt.hostPort {
26 t.Errorf("hostPortNoPort(%v) returned hostPort %q, want %q", tt.u, hostPort, tt.hostPort)
28 if hostNoPort != tt.hostNoPort {
29 t.Errorf("hostPortNoPort(%v) returned hostNoPort %q, want %q", tt.u, hostNoPort, tt.hostNoPort)