summaryrefslogtreecommitdiff
path: root/src/pkg/gob/encoder_test.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-08-30 19:46:35 -0700
committerRob Pike <r@golang.org>2009-08-30 19:46:35 -0700
commitfb1312f19cad5e4ebfb6b42d3bdbc66cfcd3de22 (patch)
tree06c0a37c04178237cd1cfcf3eb5ae17e91a3b62a /src/pkg/gob/encoder_test.go
parent1264626b079e9b3505526c71cdd478ebd3d08090 (diff)
downloadgolang-fb1312f19cad5e4ebfb6b42d3bdbc66cfcd3de22.tar.gz
can't encode array or slice - catch in sendType rather than failing in Encode
R=rsc DELTA=38 (33 added, 3 deleted, 2 changed) OCL=34101 CL=34104
Diffstat (limited to 'src/pkg/gob/encoder_test.go')
-rw-r--r--src/pkg/gob/encoder_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pkg/gob/encoder_test.go b/src/pkg/gob/encoder_test.go
index 534816fc8..4cad834d0 100644
--- a/src/pkg/gob/encoder_test.go
+++ b/src/pkg/gob/encoder_test.go
@@ -243,3 +243,25 @@ func TestBadData(t *testing.T) {
corruptDataCheck("\x7Fhi", io.ErrUnexpectedEOF, t);
corruptDataCheck("\x03now is the time for all good men", errBadType, t);
}
+
+// Types not supported by the Encoder (only structs work at the top level).
+// Basic types work implicitly.
+var unsupportedValues = []interface{} {
+ []int{ 1, 2, 3 },
+ [3]int{ 1, 2, 3 },
+ make(chan int),
+ func(a int) bool { return true },
+ make(map[string] int),
+ new(interface{}),
+}
+
+func TestUnsupported(t *testing.T) {
+ var b bytes.Buffer;
+ enc := NewEncoder(&b);
+ for _, v := range unsupportedValues {
+ err := enc.Encode(v);
+ if err == nil {
+ t.Errorf("expected error for %T; got none", v)
+ }
+ }
+}