3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test range over strings.
18 s
:= "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx"
19 expect
:= []rune
{0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x'}
26 r
, size
:= utf8
.DecodeRuneInString(s
[i
:len(s
)]) // check it another way
28 fmt
.Printf("unexpected offset %d not %d\n", i
, offset
)
31 if r
!= expect
[cnum
] {
32 fmt
.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i
, r
, expect
[cnum
])
35 if c
!= expect
[cnum
] {
36 fmt
.Printf("unexpected rune %d from range: %x not %x\n", i
, r
, expect
[cnum
])
43 fmt
.Println("after loop i is", i
, "not", len(s
)-1)
52 fmt
.Println("range empty string assigned to index:", i
)
56 fmt
.Println("range empty string assigned to value:", c
)
60 for _
, c
:= range "a\xed\xa0\x80a" {
61 if c
!= 'a' && c
!= utf8
.RuneError
{
62 fmt
.Printf("surrogate UTF-8 does not error: %U\n", c
)
68 fmt
.Println("BUG: stringrange")