File: string_test.go

package info (click to toggle)
golang-golang-x-mobile 0.0~git20251126.5c265dc-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,836 kB
  • sloc: objc: 1,536; java: 1,489; ansic: 1,159; xml: 365; asm: 34; sh: 14; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package seq

import (
	"testing"
	"unicode/utf16"
)

var strData = []string{
	"abcxyz09{}",
	"Hello, 世界",
	string([]rune{0xffff, 0x10000, 0x10001, 0x12345, 0x10ffff}),
}

func TestString(t *testing.T) {
	for _, test := range strData {
		chars := make([]uint16, 4*len(test))
		nchars := UTF16Encode(test, chars)
		chars = chars[:nchars]
		got := string(utf16.Decode(chars))
		if got != test {
			t.Errorf("UTF16: got %q, want %q", got, test)
		}
	}
}