aboutsummaryrefslogtreecommitdiff
path: root/src/unicode/utf16/utf16_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/unicode/utf16/utf16_test.go')
-rw-r--r--src/unicode/utf16/utf16_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/unicode/utf16/utf16_test.go b/src/unicode/utf16/utf16_test.go
index be339b1fdf..a5a503d387 100644
--- a/src/unicode/utf16/utf16_test.go
+++ b/src/unicode/utf16/utf16_test.go
@@ -5,6 +5,7 @@
package utf16_test
import (
+ "internal/testenv"
"reflect"
"testing"
"unicode"
@@ -103,6 +104,22 @@ var decodeTests = []decodeTest{
{[]uint16{0xdfff}, []rune{0xfffd}},
}
+func TestAllocationsDecode(t *testing.T) {
+ testenv.SkipIfOptimizationOff(t)
+
+ for _, tt := range decodeTests {
+ allocs := testing.AllocsPerRun(10, func() {
+ out := Decode(tt.in)
+ if out == nil {
+ t.Errorf("Decode(%x) = nil", tt.in)
+ }
+ })
+ if allocs > 0 {
+ t.Errorf("Decode allocated %v times", allocs)
+ }
+ }
+}
+
func TestDecode(t *testing.T) {
for _, tt := range decodeTests {
out := Decode(tt.in)