aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/gob/codec_test.go
diff options
context:
space:
mode:
authorJohan Abildskov <randomsort@gmail.com>2023-03-22 06:31:25 +0000
committerGopher Robot <gobot@golang.org>2023-03-23 17:32:41 +0000
commit3d5391ed87d813110e10b954c62bf7ed578b591f (patch)
treecf48d8b3303b187cab288d68896aa13ab4588cec /src/encoding/gob/codec_test.go
parent1596d71255f3c19a27600e751592079dae46bf40 (diff)
downloadgo-3d5391ed87d813110e10b954c62bf7ed578b591f.tar.xz
encoding/gob: extend partially allocated string slices
Fixes #59172 Change-Id: I54d5e724f10117a40ec5dd58c810f6bbb2475933 GitHub-Last-Rev: d1a986698c820415b2e0be12141091a3cbf6fde3 GitHub-Pull-Request: golang/go#59173 Reviewed-on: https://go-review.googlesource.com/c/go/+/478215 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
Diffstat (limited to 'src/encoding/gob/codec_test.go')
-rw-r--r--src/encoding/gob/codec_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/encoding/gob/codec_test.go b/src/encoding/gob/codec_test.go
index 54c356c464..28cd6088af 100644
--- a/src/encoding/gob/codec_test.go
+++ b/src/encoding/gob/codec_test.go
@@ -1544,6 +1544,10 @@ type LargeSliceStruct struct {
S []StringPair
}
+type LargeSliceString struct {
+ S []string
+}
+
func testEncodeDecode(t *testing.T, in, out any) {
t.Helper()
var b bytes.Buffer
@@ -1592,4 +1596,14 @@ func TestLargeSlice(t *testing.T) {
rt := &LargeSliceStruct{}
testEncodeDecode(t, st, rt)
})
+ t.Run("string", func(t *testing.T) {
+ t.Parallel()
+ s := make([]string, 1<<21)
+ for i := range s {
+ s[i] = string(rune(i))
+ }
+ st := &LargeSliceString{S: s}
+ rt := &LargeSliceString{}
+ testEncodeDecode(t, st, rt)
+ })
}