Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(192)

Side by Side Diff: src/pkg/encoding/binary/binary_test.go

Issue 183091: code review 183091: Allow slice values in binary.Write. Fixes issue 478
Patch Set: code review 183091: Allow slice values in binary.Write. Fixes issue 478 Created 14 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package binary 5 package binary
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 "bytes" 9 "bytes"
10 "math" 10 "math"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 slice := make([]int32, 2) 105 slice := make([]int32, 2)
106 err := Read(bytes.NewBuffer(src), BigEndian, slice) 106 err := Read(bytes.NewBuffer(src), BigEndian, slice)
107 checkResult(t, "ReadSlice", BigEndian, err, slice, res) 107 checkResult(t, "ReadSlice", BigEndian, err, slice, res)
108 } 108 }
109 109
110 func TestWriteSlice(t *testing.T) { 110 func TestWriteSlice(t *testing.T) {
111 buf := new(bytes.Buffer) 111 buf := new(bytes.Buffer)
112 err := Write(buf, BigEndian, res) 112 err := Write(buf, BigEndian, res)
113 checkResult(t, "WriteSlice", BigEndian, err, buf.Bytes(), src) 113 checkResult(t, "WriteSlice", BigEndian, err, buf.Bytes(), src)
114 } 114 }
115
116
117 type Issue478Test struct {
118 A uint8
119 B uint8
120 C []byte
121 }
122
123 func TestIssue478(t *testing.T) {
124 var buf bytes.Buffer
125 s := Issue478Test{1, 2, []byte{3, 4}}
126 err := Write(&buf, BigEndian, s)
127 exp := []uint8{1, 2, 3, 4}
128 checkResult(t, "Issue478", BigEndian, err, buf.Bytes(), exp)
129 }
OLDNEW
« src/pkg/encoding/binary/binary.go ('K') | « src/pkg/encoding/binary/binary.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b