From bae90c989cb020d17a24919ec84c0b8dd2fae2da Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 4 Jun 2014 23:15:33 +0000 Subject: libgo: Merge from revision 18783:00cce3a34d7e of master library. This revision was committed January 7, 2014. The next revision deleted runtime/mfinal.c. That will be done in a subsequent merge. This merge changes type descriptors to add a zero field, pointing to a zero value for that type. This is implemented as a common variable. * go-gcc.cc (Gcc_backend::implicit_variable): Add is_common and alignment parameters. Permit init parameter to be NULL. From-SVN: r211249 --- libgo/go/bytes/bytes.go | 4 ++-- libgo/go/bytes/bytes_test.go | 20 ++++++++++++++++++++ libgo/go/bytes/compare_test.go | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'libgo/go/bytes') diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go index 01a5d9ae..644bf75 100644 --- a/libgo/go/bytes/bytes.go +++ b/libgo/go/bytes/bytes.go @@ -265,8 +265,8 @@ func Fields(s []byte) [][]byte { // FieldsFunc interprets s as a sequence of UTF-8-encoded Unicode code points. // It splits the slice s at each run of code points c satisfying f(c) and -// returns a slice of subslices of s. If no code points in s satisfy f(c), an -// empty slice is returned. +// returns a slice of subslices of s. If all code points in s satisfy f(c), or +// len(s) == 0, an empty slice is returned. func FieldsFunc(s []byte, f func(rune) bool) [][]byte { n := 0 inField := false diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go index ab5da4f..808655a 100644 --- a/libgo/go/bytes/bytes_test.go +++ b/libgo/go/bytes/bytes_test.go @@ -1073,6 +1073,8 @@ var TitleTests = []TitleTest{ {"123a456", "123a456"}, {"double-blind", "Double-Blind"}, {"ÿøû", "Ÿøû"}, + {"with_underscore", "With_underscore"}, + {"unicode \xe2\x80\xa8 line separator", "Unicode \xe2\x80\xa8 Line Separator"}, } func TestTitle(t *testing.T) { @@ -1160,6 +1162,24 @@ func TestBufferTruncateOutOfRange(t *testing.T) { b.Truncate(20) } +var containsTests = []struct { + b, subslice []byte + want bool +}{ + {[]byte("hello"), []byte("hel"), true}, + {[]byte("日本語"), []byte("日本"), true}, + {[]byte("hello"), []byte("Hello, world"), false}, + {[]byte("東京"), []byte("京東"), false}, +} + +func TestContains(t *testing.T) { + for _, tt := range containsTests { + if got := Contains(tt.b, tt.subslice); got != tt.want { + t.Errorf("Contains(%q, %q) = %v, want %v", tt.b, tt.subslice, got, tt.want) + } + } +} + var makeFieldsInput = func() []byte { x := make([]byte, 1<<20) // Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space. diff --git a/libgo/go/bytes/compare_test.go b/libgo/go/bytes/compare_test.go index 0a36f5a..6352237 100644 --- a/libgo/go/bytes/compare_test.go +++ b/libgo/go/bytes/compare_test.go @@ -1,3 +1,7 @@ +// Copyright 2013 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 bytes_test import ( -- cgit v1.1