Retro68/gcc/libgo/go/net/http/lex_test.go

32 lines
700 B
Go
Raw Normal View History

2012-03-28 01:13:14 +02:00
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http
import (
"testing"
)
2014-09-21 19:33:12 +02:00
func isChar(c rune) bool { return c <= 127 }
2012-03-28 01:13:14 +02:00
2014-09-21 19:33:12 +02:00
func isCtl(c rune) bool { return c <= 31 || c == 127 }
2012-03-28 01:13:14 +02:00
2014-09-21 19:33:12 +02:00
func isSeparator(c rune) bool {
switch c {
case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t':
return true
2012-03-28 01:13:14 +02:00
}
2014-09-21 19:33:12 +02:00
return false
2012-03-28 01:13:14 +02:00
}
2014-09-21 19:33:12 +02:00
func TestIsToken(t *testing.T) {
for i := 0; i <= 130; i++ {
r := rune(i)
expected := isChar(r) && !isCtl(r) && !isSeparator(r)
if isToken(r) != expected {
t.Errorf("isToken(0x%x) = %v", r, !expected)
2012-03-28 01:13:14 +02:00
}
}
}