mirror of
https://github.com/golang/go
synced 2024-11-26 15:56:57 -07:00
encoding/gob: add test case for issue 4214.
See http://code.google.com/p/go/issues/detail?id=4214 R=golang-dev, r CC=golang-dev https://golang.org/cl/6619068
This commit is contained in:
parent
e855fcc307
commit
aa97c88ecb
@ -5,6 +5,7 @@
|
||||
package gob
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
@ -192,3 +193,30 @@ func TestRegistrationNaming(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStressParallel(t *testing.T) {
|
||||
type T2 struct{ A int }
|
||||
c := make(chan bool)
|
||||
const N = 10
|
||||
for i := 0; i < N; i++ {
|
||||
go func() {
|
||||
p := new(T2)
|
||||
Register(p)
|
||||
b := new(bytes.Buffer)
|
||||
enc := NewEncoder(b)
|
||||
err := enc.Encode(p)
|
||||
if err != nil {
|
||||
t.Error("encoder fail:", err)
|
||||
}
|
||||
dec := NewDecoder(b)
|
||||
err = dec.Decode(p)
|
||||
if err != nil {
|
||||
t.Error("decoder fail:", err)
|
||||
}
|
||||
c <- true
|
||||
}()
|
||||
}
|
||||
for i := 0; i < N; i++ {
|
||||
<-c
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user