string_test.go 614 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package seq
  5. import (
  6. "testing"
  7. "unicode/utf16"
  8. )
  9. var strData = []string{
  10. "abcxyz09{}",
  11. "Hello, 世界",
  12. string([]rune{0xffff, 0x10000, 0x10001, 0x12345, 0x10ffff}),
  13. }
  14. func TestString(t *testing.T) {
  15. for _, test := range strData {
  16. chars := make([]uint16, 4*len(test))
  17. nchars := UTF16Encode(test, chars)
  18. chars = chars[:nchars]
  19. got := string(utf16.Decode(chars))
  20. if got != test {
  21. t.Errorf("UTF16: got %q, want %q", got, test)
  22. }
  23. }
  24. }