OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [http/] [chunked_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 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
// This code is duplicated in httputil/chunked_test.go.
6
// Please make any changes in both files.
7
 
8
package http
9
 
10
import (
11
        "bytes"
12
        "io/ioutil"
13
        "testing"
14
)
15
 
16
func TestChunk(t *testing.T) {
17
        var b bytes.Buffer
18
 
19
        w := newChunkedWriter(&b)
20
        const chunk1 = "hello, "
21
        const chunk2 = "world! 0123456789abcdef"
22
        w.Write([]byte(chunk1))
23
        w.Write([]byte(chunk2))
24
        w.Close()
25
 
26
        if g, e := b.String(), "7\r\nhello, \r\n17\r\nworld! 0123456789abcdef\r\n0\r\n"; g != e {
27
                t.Fatalf("chunk writer wrote %q; want %q", g, e)
28
        }
29
 
30
        r := newChunkedReader(&b)
31
        data, err := ioutil.ReadAll(r)
32
        if err != nil {
33
                t.Logf(`data: "%s"`, data)
34
                t.Fatalf("ReadAll from reader: %v", err)
35
        }
36
        if g, e := string(data), chunk1+chunk2; g != e {
37
                t.Errorf("chunk reader read %q; want %q", g, e)
38
        }
39
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.