diff options
Diffstat (limited to 'gcc/testsuite/go.test/test/stringrange.go')
-rw-r--r-- | gcc/testsuite/go.test/test/stringrange.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/testsuite/go.test/test/stringrange.go b/gcc/testsuite/go.test/test/stringrange.go index d5ada26..6a7063e 100644 --- a/gcc/testsuite/go.test/test/stringrange.go +++ b/gcc/testsuite/go.test/test/stringrange.go @@ -9,28 +9,29 @@ package main import ( "fmt" "os" - "utf8" + "unicode/utf8" ) func main() { s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx" - expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' } + expect := []rune{0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x'} offset := 0 - var i, c int + var i int + var c rune ok := true cnum := 0 for i, c = range s { - rune, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way + r, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way if i != offset { fmt.Printf("unexpected offset %d not %d\n", i, offset) ok = false } - if rune != expect[cnum] { - fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, rune, expect[cnum]) + if r != expect[cnum] { + fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, r, expect[cnum]) ok = false } if c != expect[cnum] { - fmt.Printf("unexpected rune %d from range: %x not %x\n", i, rune, expect[cnum]) + fmt.Printf("unexpected rune %d from range: %x not %x\n", i, r, expect[cnum]) ok = false } offset += size |