diff options
author | Ian Lance Taylor <iant@google.com> | 2014-06-04 23:15:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-06-04 23:15:33 +0000 |
commit | bae90c989cb020d17a24919ec84c0b8dd2fae2da (patch) | |
tree | 89766166feb4ceca2d983169c5360e3f6f521b12 /libgo/go/strings | |
parent | 82b3da6a714493644a4333bfd8205e3341ed3b8e (diff) | |
download | gcc-bae90c989cb020d17a24919ec84c0b8dd2fae2da.zip gcc-bae90c989cb020d17a24919ec84c0b8dd2fae2da.tar.gz gcc-bae90c989cb020d17a24919ec84c0b8dd2fae2da.tar.bz2 |
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
Diffstat (limited to 'libgo/go/strings')
-rw-r--r-- | libgo/go/strings/example_test.go | 32 | ||||
-rw-r--r-- | libgo/go/strings/strings_test.go | 2 |
2 files changed, 32 insertions, 2 deletions
diff --git a/libgo/go/strings/example_test.go b/libgo/go/strings/example_test.go index 36e0a42..7243e16 100644 --- a/libgo/go/strings/example_test.go +++ b/libgo/go/strings/example_test.go @@ -7,6 +7,7 @@ package strings_test import ( "fmt" "strings" + "unicode" ) func ExampleFields() { @@ -14,6 +15,14 @@ func ExampleFields() { // Output: Fields are: ["foo" "bar" "baz"] } +func ExampleFieldsFunc() { + f := func(c rune) bool { + return !unicode.IsLetter(c) && !unicode.IsNumber(c) + } + fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f)) + // Output: Fields are: ["foo1" "bar2" "baz3"] +} + func ExampleContains() { fmt.Println(strings.Contains("seafood", "foo")) fmt.Println(strings.Contains("seafood", "bar")) @@ -59,6 +68,25 @@ func ExampleIndex() { // -1 } +func ExampleIndexFunc() { + f := func(c rune) bool { + return unicode.Is(unicode.Han, c) + } + fmt.Println(strings.IndexFunc("Hello, 世界", f)) + fmt.Println(strings.IndexFunc("Hello, world", f)) + // Output: + // 7 + // -1 +} + +func ExampleIndexAny() { + fmt.Println(strings.IndexAny("chicken", "aeiouy")) + fmt.Println(strings.IndexAny("crwth", "aeiouy")) + // Output: + // 2 + // -1 +} + func ExampleIndexRune() { fmt.Println(strings.IndexRune("chicken", 'k')) fmt.Println(strings.IndexRune("chicken", 'd')) @@ -141,8 +169,8 @@ func ExampleToTitle() { } func ExampleTrim() { - fmt.Printf("[%q]", strings.Trim(" !!! Achtung !!! ", "! ")) - // Output: ["Achtung"] + fmt.Printf("[%q]", strings.Trim(" !!! Achtung! Achtung! !!! ", "! ")) + // Output: ["Achtung! Achtung"] } func ExampleMap() { diff --git a/libgo/go/strings/strings_test.go b/libgo/go/strings/strings_test.go index df0dd71..a5be2f9 100644 --- a/libgo/go/strings/strings_test.go +++ b/libgo/go/strings/strings_test.go @@ -903,6 +903,8 @@ var TitleTests = []struct { {"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) { |