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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [http/] [httputil/] [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 a duplicate of ../chunked_test.go with these edits:
6
//      s/newChunked/NewChunked/g
7
//      s/package http/package httputil/
8
// Please make any changes in both files.
9
 
10
package httputil
11
 
12
import (
13
        "bytes"
14
        "io/ioutil"
15
        "testing"
16
)
17
 
18
func TestChunk(t *testing.T) {
19
        var b bytes.Buffer
20
 
21
        w := NewChunkedWriter(&b)
22
        const chunk1 = "hello, "
23
        const chunk2 = "world! 0123456789abcdef"
24
        w.Write([]byte(chunk1))
25
        w.Write([]byte(chunk2))
26
        w.Close()
27
 
28
        if g, e := b.String(), "7\r\nhello, \r\n17\r\nworld! 0123456789abcdef\r\n0\r\n"; g != e {
29
                t.Fatalf("chunk writer wrote %q; want %q", g, e)
30
        }
31
 
32
        r := NewChunkedReader(&b)
33
        data, err := ioutil.ReadAll(r)
34
        if err != nil {
35
                t.Logf(`data: "%s"`, data)
36
                t.Fatalf("ReadAll from reader: %v", err)
37
        }
38
        if g, e := string(data), chunk1+chunk2; g != e {
39
                t.Errorf("chunk reader read %q; want %q", g, e)
40
        }
41
}

powered by: WebSVN 2.1.0

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