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.
13 Parsed
int // # of parsed characters
17 var lexTests
= []lexTest
{
21 Result
: []string{"abcdef", "ghi"},
23 // My understanding of the RFC is that escape sequences outside of
24 // quotes are not interpreted?
28 Result
: []string{"\t", "t\t"},
33 Result
: []string{"?ab", "r", "n"},
38 Result
: []string{"ab?"},
41 Raw
: "\"ab \" c,de f, gh, ij\n\t\r",
43 Result
: []string{"ab ", "c", "de", "f", "gh", "ij"},
47 func min(x
, y
int) int {
54 func TestSplitFieldValue(t
*testing
.T
) {
55 for k
, l
:= range lexTests
{
56 parsed
, result
:= httpSplitFieldValue(l
.Raw
)
57 if parsed
!= l
.Parsed
{
58 t
.Errorf("#%d: Parsed %d, expected %d", k
, parsed
, l
.Parsed
)
60 if len(result
) != len(l
.Result
) {
61 t
.Errorf("#%d: Result len %d, expected %d", k
, len(result
), len(l
.Result
))
63 for i
:= 0; i
< min(len(result
), len(l
.Result
)); i
++ {
64 if result
[i
] != l
.Result
[i
] {
65 t
.Errorf("#%d: %d-th entry mismatch. Have {%s}, expect {%s}",
66 k
, i
, result
[i
], l
.Result
[i
])