~jonas-drange/ubuntu-push/lp1577723-skiptest

« back to all changes in this revision

Viewing changes to http13client/lex_test.go

  • Committer: Samuele Pedroni (Canonical Services Ltd.)
  • Date: 2014-03-19 20:20:19 UTC
  • mto: This revision was merged to the branch mainline in revision 82.
  • Revision ID: samuele.pedroni@canonical.com-20140319202019-p0w8krshj1098f82
grab go 1.3 dev net/http and massage it so that the test run on 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2009 The Go 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 http
 
6
 
 
7
import (
 
8
        "testing"
 
9
)
 
10
 
 
11
func isChar(c rune) bool { return c <= 127 }
 
12
 
 
13
func isCtl(c rune) bool { return c <= 31 || c == 127 }
 
14
 
 
15
func isSeparator(c rune) bool {
 
16
        switch c {
 
17
        case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t':
 
18
                return true
 
19
        }
 
20
        return false
 
21
}
 
22
 
 
23
func TestIsToken(t *testing.T) {
 
24
        for i := 0; i <= 130; i++ {
 
25
                r := rune(i)
 
26
                expected := isChar(r) && !isCtl(r) && !isSeparator(r)
 
27
                if isToken(r) != expected {
 
28
                        t.Errorf("isToken(0x%x) = %v", r, !expected)
 
29
                }
 
30
        }
 
31
}