Skip to content
Permalink
Browse files
Merge branch 'master' into 1.8
  • Loading branch information
wongoo committed Jan 13, 2021
2 parents 5b6bf1c + c052455 commit 038c74620dfd2025348d9c19d5c3f5283f11898d
Showing 2 changed files with 12 additions and 1 deletion.
@@ -108,7 +108,8 @@ func encString(b []byte, v string) []byte {
byteCount int
)

bufp := gxbytes.AcquireBytes(CHUNK_SIZE * 3)
// Acquire (CHUNK_SIZE + 1) * 3 bytes since charCount could reach CHUNK_SIZE + 1.
bufp := gxbytes.AcquireBytes((CHUNK_SIZE + 1) * 3)
defer gxbytes.ReleaseBytes(bufp)
buf := *bufp

@@ -111,6 +111,16 @@ func TestEncRune(t *testing.T) {
assertEqual([]byte(res.(string)), []byte(v), t)
}

func TestEncStringChunk(t *testing.T) {
enc := NewEncoder()
v := strings.Repeat("我", CHUNK_SIZE-1) + "🤣"
assert.Nil(t, enc.Encode(v))
dec := NewDecoder(enc.Buffer())
s, err := dec.Decode()
assert.Nil(t, err)
assert.Equal(t, v, s)
}

func TestString(t *testing.T) {
s0 := ""
s1 := "0"

0 comments on commit 038c746

Please sign in to comment.