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
a0d1c926
Commit
a0d1c926
authored
Jul 21, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gobs: fix bug in singleton arrays
Fixes #934. R=rsc CC=golang-dev
https://golang.org/cl/1869043
parent
8f9aeb5a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
encode.go
src/pkg/gob/encode.go
+0
-4
encoder_test.go
src/pkg/gob/encoder_test.go
+4
-1
No files found.
src/pkg/gob/encode.go
View file @
a0d1c926
...
...
@@ -722,10 +722,6 @@ func encOpFor(rt reflect.Type) (encOp, int, os.Error) {
return
nil
,
0
,
err
}
op
=
func
(
i
*
encInstr
,
state
*
encoderState
,
p
unsafe
.
Pointer
)
{
slice
:=
(
*
reflect
.
SliceHeader
)(
p
)
if
slice
.
Len
==
0
{
return
}
state
.
update
(
i
)
state
.
err
=
encodeArray
(
state
.
b
,
uintptr
(
p
),
elemOp
,
t
.
Elem
()
.
Size
(),
indir
,
t
.
Len
())
}
...
...
src/pkg/gob/encoder_test.go
View file @
a0d1c926
...
...
@@ -274,6 +274,7 @@ var testFloat32 float32
var
testString
string
var
testSlice
[]
string
var
testMap
map
[
string
]
int
var
testArray
[
7
]
int
type
SingleTest
struct
{
in
interface
{}
...
...
@@ -287,6 +288,8 @@ var singleTests = []SingleTest{
SingleTest
{
"bike shed"
,
&
testString
,
""
},
SingleTest
{[]
string
{
"bike"
,
"shed"
,
"paint"
,
"color"
},
&
testSlice
,
""
},
SingleTest
{
map
[
string
]
int
{
"seven"
:
7
,
"twelve"
:
12
},
&
testMap
,
""
},
SingleTest
{[
7
]
int
{
4
,
55
,
0
,
0
,
0
,
0
,
0
},
&
testArray
,
""
},
// case that once triggered a bug
SingleTest
{[
7
]
int
{
4
,
55
,
1
,
44
,
22
,
66
,
1234
},
&
testArray
,
""
},
// Decode errors
SingleTest
{
172
,
&
testFloat32
,
"wrong type"
},
...
...
@@ -320,7 +323,7 @@ func TestSingletons(t *testing.T) {
// Get rid of the pointer in the rhs
val
:=
reflect
.
NewValue
(
test
.
out
)
.
(
*
reflect
.
PtrValue
)
.
Elem
()
.
Interface
()
if
!
reflect
.
DeepEqual
(
test
.
in
,
val
)
{
t
.
Errorf
(
"decoding
int
: expected %v got %v"
,
test
.
in
,
val
)
t
.
Errorf
(
"decoding
singleton
: expected %v got %v"
,
test
.
in
,
val
)
}
}
}
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