1
0
mirror of https://github.com/golang/go synced 2024-11-22 19:24:59 -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:
Dmitriy Vyukov 2012-10-09 09:55:57 +04:00
parent e855fcc307
commit aa97c88ecb

View File

@ -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
}
}