Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
0f28983a
Commit
0f28983a
authored
Oct 26, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test copy([]byte, string)
R=r, r2 CC=golang-dev
https://golang.org/cl/2740041
parent
82c6f5e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
4 deletions
+57
-4
copy.go
test/copy.go
+57
-4
No files found.
test/copy.go
View file @
0f28983a
...
...
@@ -23,6 +23,15 @@ var input32 = make([]uint32, N)
var
output32
=
make
([]
uint32
,
N
)
var
input64
=
make
([]
uint64
,
N
)
var
output64
=
make
([]
uint64
,
N
)
var
inputS
string
var
outputS
=
make
([]
uint8
,
N
)
type
my8
[]
uint8
type
my16
[]
uint16
type
my32
[]
uint32
type
my32b
[]
uint32
type
my64
[]
uint64
type
myS
string
func
u8
(
i
int
)
uint8
{
i
=
'a'
+
i
%
26
...
...
@@ -64,6 +73,7 @@ func reset() {
for
i
:=
range
input8
{
input8
[
i
]
=
u8
(
in
)
output8
[
i
]
=
u8
(
out
)
outputS
[
i
]
=
u8
(
out
)
input16
[
i
]
=
u16
(
in
)
output16
[
i
]
=
u16
(
out
)
input32
[
i
]
=
u32
(
in
)
...
...
@@ -73,6 +83,7 @@ func reset() {
in
++
out
++
}
inputS
=
string
(
input8
)
}
func
clamp
(
n
int
)
int
{
...
...
@@ -95,13 +106,15 @@ func ncopied(length, in, out int) int {
func
doAllSlices
(
length
,
in
,
out
int
)
{
reset
()
n
:=
copy
(
output8
[
out
:
clamp
(
out
+
length
)]
,
input8
[
in
:
clamp
(
in
+
length
)])
n
:=
copy
(
my8
(
output8
[
out
:
clamp
(
out
+
length
)])
,
input8
[
in
:
clamp
(
in
+
length
)])
verify8
(
length
,
in
,
out
,
n
)
n
=
copy
(
output16
[
out
:
clamp
(
out
+
length
)],
input16
[
in
:
clamp
(
in
+
length
)])
n
=
copy
(
my8
(
outputS
[
out
:
clamp
(
out
+
length
)]),
myS
(
inputS
[
in
:
clamp
(
in
+
length
)]))
verifyS
(
length
,
in
,
out
,
n
)
n
=
copy
(
my16
(
output16
[
out
:
clamp
(
out
+
length
)]),
input16
[
in
:
clamp
(
in
+
length
)])
verify16
(
length
,
in
,
out
,
n
)
n
=
copy
(
output32
[
out
:
clamp
(
out
+
length
)],
input32
[
in
:
clamp
(
in
+
length
)]
)
n
=
copy
(
my32
(
output32
[
out
:
clamp
(
out
+
length
)]),
my32b
(
input32
[
in
:
clamp
(
in
+
length
)])
)
verify32
(
length
,
in
,
out
,
n
)
n
=
copy
(
output64
[
out
:
clamp
(
out
+
length
)]
,
input64
[
in
:
clamp
(
in
+
length
)])
n
=
copy
(
my64
(
output64
[
out
:
clamp
(
out
+
length
)])
,
input64
[
in
:
clamp
(
in
+
length
)])
verify64
(
length
,
in
,
out
,
n
)
}
...
...
@@ -145,6 +158,46 @@ func verify8(length, in, out, m int) {
}
}
func
badS
(
state
string
,
i
,
length
,
in
,
out
int
)
{
fmt
.
Printf
(
"%s bad(%d %d %d): %c not %c:
\n\t
%s
\n\t
%s
\n
"
,
state
,
length
,
in
,
out
,
outputS
[
i
],
uint8
(
i
+
13
),
inputS
,
outputS
)
os
.
Exit
(
1
)
}
func
verifyS
(
length
,
in
,
out
,
m
int
)
{
n
:=
ncopied
(
length
,
in
,
out
)
if
m
!=
n
{
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
return
}
// before
var
i
int
for
i
=
0
;
i
<
out
;
i
++
{
if
outputS
[
i
]
!=
u8
(
i
+
13
)
{
badS
(
"beforeS"
,
i
,
length
,
in
,
out
)
return
}
}
// copied part
for
;
i
<
out
+
n
;
i
++
{
if
outputS
[
i
]
!=
u8
(
i
+
in
-
out
)
{
badS
(
"copiedS"
,
i
,
length
,
in
,
out
)
return
}
}
// after
for
;
i
<
len
(
outputS
);
i
++
{
if
outputS
[
i
]
!=
u8
(
i
+
13
)
{
badS
(
"afterS"
,
i
,
length
,
in
,
out
)
return
}
}
}
func
bad16
(
state
string
,
i
,
length
,
in
,
out
int
)
{
fmt
.
Printf
(
"%s bad(%d %d %d): %x not %x:
\n\t
%v
\n\t
%v
\n
"
,
state
,
...
...
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