github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/mobile/bind/seq/utf16_test.go (about)

     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  
     5  package seq
     6  
     7  import "testing"
     8  
     9  var utf16Tests = []string{
    10  	"abcxyz09{}",
    11  	"Hello, 世界",
    12  	string([]rune{0xffff, 0x10000, 0x10001, 0x12345, 0x10ffff}),
    13  }
    14  
    15  func TestUTF16(t *testing.T) {
    16  	for _, test := range utf16Tests {
    17  		buf := new(Buffer)
    18  		buf.WriteUTF16(test)
    19  		buf.Offset = 0
    20  		got := buf.ReadUTF16()
    21  		if got != test {
    22  			t.Errorf("got %q, want %q", got, test)
    23  		}
    24  	}
    25  }
    26  
    27  func TestSequential(t *testing.T) {
    28  	buf := new(Buffer)
    29  	for _, test := range utf16Tests {
    30  		buf.WriteUTF16(test)
    31  	}
    32  	buf.Offset = 0
    33  	for i, test := range utf16Tests {
    34  		got := buf.ReadUTF16()
    35  		if got != test {
    36  			t.Errorf("%d: got %q, want %q", i, got, test)
    37  		}
    38  	}
    39  }