~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/gorilla/websocket/util_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
 
 
5
package websocket
 
6
 
 
7
import (
 
8
        "net/http"
 
9
        "testing"
 
10
)
 
11
 
 
12
var tokenListContainsValueTests = []struct {
 
13
        value string
 
14
        ok    bool
 
15
}{
 
16
        {"WebSocket", true},
 
17
        {"WEBSOCKET", true},
 
18
        {"websocket", true},
 
19
        {"websockets", false},
 
20
        {"x websocket", false},
 
21
        {"websocket x", false},
 
22
        {"other,websocket,more", true},
 
23
        {"other, websocket, more", true},
 
24
}
 
25
 
 
26
func TestTokenListContainsValue(t *testing.T) {
 
27
        for _, tt := range tokenListContainsValueTests {
 
28
                h := http.Header{"Upgrade": {tt.value}}
 
29
                ok := tokenListContainsValue(h, "Upgrade", "websocket")
 
30
                if ok != tt.ok {
 
31
                        t.Errorf("tokenListContainsValue(h, n, %q) = %v, want %v", tt.value, ok, tt.ok)
 
32
                }
 
33
        }
 
34
}