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

Side by Side Diff: src/pkg/bytes/buffer_test.go

Issue 156115: code review 156115: gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg (Closed)
Patch Set: code review 156115: gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg Created 15 years, 4 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
« no previous file with comments | « src/pkg/bytes/buffer.go ('k') | src/pkg/bytes/bytes.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bytes_test 5 package bytes_test
6 6
7 import ( 7 import (
8 . "bytes"; 8 . "bytes";
9 "rand"; 9 "rand";
10 "testing"; 10 "testing";
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 check(t, testname+" (empty 1)", buf, s); 104 check(t, testname+" (empty 1)", buf, s);
105 105
106 for { 106 for {
107 n, err := buf.Read(fub); 107 n, err := buf.Read(fub);
108 if n == 0 { 108 if n == 0 {
109 break 109 break
110 } 110 }
111 if err != nil { 111 if err != nil {
112 t.Errorf(testname+" (empty 2): err should always be nil, found err == %s\n", err) 112 t.Errorf(testname+" (empty 2): err should always be nil, found err == %s\n", err)
113 } 113 }
114 » » s = s[n:len(s)]; 114 » » s = s[n:];
115 check(t, testname+" (empty 3)", buf, s); 115 check(t, testname+" (empty 3)", buf, s);
116 } 116 }
117 117
118 check(t, testname+" (empty 4)", buf, ""); 118 check(t, testname+" (empty 4)", buf, "");
119 } 119 }
120 120
121 121
122 func TestBasicOperations(t *testing.T) { 122 func TestBasicOperations(t *testing.T) {
123 var buf Buffer; 123 var buf Buffer;
124 124
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 wlen := rand.Intn(len(data)); 221 wlen := rand.Intn(len(data));
222 if i%2 == 0 { 222 if i%2 == 0 {
223 s = fillString(t, "TestMixedReadsAndWrites (1)", &buf, s , 1, data[0:wlen]) 223 s = fillString(t, "TestMixedReadsAndWrites (1)", &buf, s , 1, data[0:wlen])
224 } else { 224 } else {
225 s = fillBytes(t, "TestMixedReadsAndWrites (1)", &buf, s, 1, bytes[0:wlen]) 225 s = fillBytes(t, "TestMixedReadsAndWrites (1)", &buf, s, 1, bytes[0:wlen])
226 } 226 }
227 227
228 rlen := rand.Intn(len(data)); 228 rlen := rand.Intn(len(data));
229 fub := make([]byte, rlen); 229 fub := make([]byte, rlen);
230 n, _ := buf.Read(fub); 230 n, _ := buf.Read(fub);
231 » » s = s[n:len(s)]; 231 » » s = s[n:];
232 } 232 }
233 empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len()) ); 233 empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len()) );
234 } 234 }
235 235
236 236
237 func TestNil(t *testing.T) { 237 func TestNil(t *testing.T) {
238 var b *Buffer; 238 var b *Buffer;
239 if b.String() != "<nil>" { 239 if b.String() != "<nil>" {
240 t.Error("expcted <nil>; got %q", b.String()) 240 t.Error("expcted <nil>; got %q", b.String())
241 } 241 }
242 } 242 }
OLDNEW
« no previous file with comments | « src/pkg/bytes/buffer.go ('k') | src/pkg/bytes/bytes.go » ('j') | no next file with comments »

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