Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
749a445b
Commit
749a445b
authored
Oct 10, 2012
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes: fix tests and fix build
R=golang-dev, edsrzf CC=golang-dev
https://golang.org/cl/6633051
parent
84386416
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
src/pkg/bytes/buffer_test.go
src/pkg/bytes/buffer_test.go
+12
-12
No files found.
src/pkg/bytes/buffer_test.go
View file @
749a445b
...
...
@@ -13,16 +13,16 @@ import (
"unicode/utf8"
)
const
N
=
10000
// make this bigger for a larger (and slower) test
var
data
string
// test data for write tests
var
b
ytes
[]
byte
// test data; same as data but as a slice.
const
N
=
10000
// make this bigger for a larger (and slower) test
var
data
string
// test data for write tests
var
testB
ytes
[]
byte
// test data; same as data but as a slice.
func
init
()
{
b
ytes
=
make
([]
byte
,
N
)
testB
ytes
=
make
([]
byte
,
N
)
for
i
:=
0
;
i
<
N
;
i
++
{
b
ytes
[
i
]
=
'a'
+
byte
(
i
%
26
)
testB
ytes
[
i
]
=
'a'
+
byte
(
i
%
26
)
}
data
=
string
(
b
ytes
)
data
=
string
(
testB
ytes
)
}
// Verify that contents of buf match the string s.
...
...
@@ -85,7 +85,7 @@ func fillBytes(t *testing.T, testname string, buf *Buffer, s string, n int, fub
}
func
TestNewBuffer
(
t
*
testing
.
T
)
{
buf
:=
NewBuffer
(
b
ytes
)
buf
:=
NewBuffer
(
testB
ytes
)
check
(
t
,
"NewBuffer"
,
buf
,
data
)
}
...
...
@@ -188,7 +188,7 @@ func TestLargeByteWrites(t *testing.T) {
limit
=
9
}
for
i
:=
3
;
i
<
limit
;
i
+=
3
{
s
:=
fillBytes
(
t
,
"TestLargeWrites (1)"
,
&
buf
,
""
,
5
,
b
ytes
)
s
:=
fillBytes
(
t
,
"TestLargeWrites (1)"
,
&
buf
,
""
,
5
,
testB
ytes
)
empty
(
t
,
"TestLargeByteWrites (2)"
,
&
buf
,
s
,
make
([]
byte
,
len
(
data
)
/
i
))
}
check
(
t
,
"TestLargeByteWrites (3)"
,
&
buf
,
""
)
...
...
@@ -206,7 +206,7 @@ func TestLargeStringReads(t *testing.T) {
func
TestLargeByteReads
(
t
*
testing
.
T
)
{
var
buf
Buffer
for
i
:=
3
;
i
<
30
;
i
+=
3
{
s
:=
fillBytes
(
t
,
"TestLargeReads (1)"
,
&
buf
,
""
,
5
,
bytes
[
0
:
len
(
b
ytes
)
/
i
])
s
:=
fillBytes
(
t
,
"TestLargeReads (1)"
,
&
buf
,
""
,
5
,
testBytes
[
0
:
len
(
testB
ytes
)
/
i
])
empty
(
t
,
"TestLargeReads (2)"
,
&
buf
,
s
,
make
([]
byte
,
len
(
data
)))
}
check
(
t
,
"TestLargeByteReads (3)"
,
&
buf
,
""
)
...
...
@@ -220,7 +220,7 @@ func TestMixedReadsAndWrites(t *testing.T) {
if
i
%
2
==
0
{
s
=
fillString
(
t
,
"TestMixedReadsAndWrites (1)"
,
&
buf
,
s
,
1
,
data
[
0
:
wlen
])
}
else
{
s
=
fillBytes
(
t
,
"TestMixedReadsAndWrites (1)"
,
&
buf
,
s
,
1
,
b
ytes
[
0
:
wlen
])
s
=
fillBytes
(
t
,
"TestMixedReadsAndWrites (1)"
,
&
buf
,
s
,
1
,
testB
ytes
[
0
:
wlen
])
}
rlen
:=
rand
.
Intn
(
len
(
data
))
...
...
@@ -241,7 +241,7 @@ func TestNil(t *testing.T) {
func
TestReadFrom
(
t
*
testing
.
T
)
{
var
buf
Buffer
for
i
:=
3
;
i
<
30
;
i
+=
3
{
s
:=
fillBytes
(
t
,
"TestReadFrom (1)"
,
&
buf
,
""
,
5
,
bytes
[
0
:
len
(
b
ytes
)
/
i
])
s
:=
fillBytes
(
t
,
"TestReadFrom (1)"
,
&
buf
,
""
,
5
,
testBytes
[
0
:
len
(
testB
ytes
)
/
i
])
var
b
Buffer
b
.
ReadFrom
(
&
buf
)
empty
(
t
,
"TestReadFrom (2)"
,
&
b
,
s
,
make
([]
byte
,
len
(
data
)))
...
...
@@ -251,7 +251,7 @@ func TestReadFrom(t *testing.T) {
func
TestWriteTo
(
t
*
testing
.
T
)
{
var
buf
Buffer
for
i
:=
3
;
i
<
30
;
i
+=
3
{
s
:=
fillBytes
(
t
,
"TestReadFrom (1)"
,
&
buf
,
""
,
5
,
bytes
[
0
:
len
(
b
ytes
)
/
i
])
s
:=
fillBytes
(
t
,
"TestReadFrom (1)"
,
&
buf
,
""
,
5
,
testBytes
[
0
:
len
(
testB
ytes
)
/
i
])
var
b
Buffer
buf
.
WriteTo
(
&
b
)
empty
(
t
,
"TestReadFrom (2)"
,
&
b
,
s
,
make
([]
byte
,
len
(
data
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment