diff options
Diffstat (limited to 'libgo/go/utf8')
-rw-r--r-- | libgo/go/utf8/string_test.go | 14 | ||||
-rw-r--r-- | libgo/go/utf8/utf8.go | 2 | ||||
-rw-r--r-- | libgo/go/utf8/utf8_test.go | 18 |
3 files changed, 17 insertions, 17 deletions
diff --git a/libgo/go/utf8/string_test.go b/libgo/go/utf8/string_test.go index 484d46fbffd..9dd84724730 100644 --- a/libgo/go/utf8/string_test.go +++ b/libgo/go/utf8/string_test.go @@ -15,13 +15,13 @@ func TestScanForwards(t *testing.T) { runes := []int(s) str := NewString(s) if str.RuneCount() != len(runes) { - t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) + t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) break } for i, expect := range runes { got := str.At(i) if got != expect { - t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got) + t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got) } } } @@ -32,14 +32,14 @@ func TestScanBackwards(t *testing.T) { runes := []int(s) str := NewString(s) if str.RuneCount() != len(runes) { - t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) + t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) break } for i := len(runes) - 1; i >= 0; i-- { expect := runes[i] got := str.At(i) if got != expect { - t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got) + t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got) } } } @@ -55,7 +55,7 @@ func TestRandomAccess(t *testing.T) { runes := []int(s) str := NewString(s) if str.RuneCount() != len(runes) { - t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) + t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) break } for j := 0; j < randCount; j++ { @@ -63,7 +63,7 @@ func TestRandomAccess(t *testing.T) { expect := runes[i] got := str.At(i) if got != expect { - t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got) + t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got) } } } @@ -77,7 +77,7 @@ func TestRandomSliceAccess(t *testing.T) { runes := []int(s) str := NewString(s) if str.RuneCount() != len(runes) { - t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) + t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) break } for k := 0; k < randCount; k++ { diff --git a/libgo/go/utf8/utf8.go b/libgo/go/utf8/utf8.go index dfcdef9613b..455499e4d95 100644 --- a/libgo/go/utf8/utf8.go +++ b/libgo/go/utf8/utf8.go @@ -293,7 +293,7 @@ func RuneLen(rune int) int { // EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune. // It returns the number of bytes written. -func EncodeRune(rune int, p []byte) int { +func EncodeRune(p []byte, rune int) int { // Negative values are erroneous. Making it unsigned addresses the problem. r := uint(rune) diff --git a/libgo/go/utf8/utf8_test.go b/libgo/go/utf8/utf8_test.go index dc130f606f4..7a1db93e550 100644 --- a/libgo/go/utf8/utf8_test.go +++ b/libgo/go/utf8/utf8_test.go @@ -58,11 +58,11 @@ func TestFullRune(t *testing.T) { m := utf8map[i] b := []byte(m.str) if !FullRune(b) { - t.Errorf("FullRune(%q) (rune %04x) = false, want true", b, m.rune) + t.Errorf("FullRune(%q) (%U) = false, want true", b, m.rune) } s := m.str if !FullRuneInString(s) { - t.Errorf("FullRuneInString(%q) (rune %04x) = false, want true", s, m.rune) + t.Errorf("FullRuneInString(%q) (%U) = false, want true", s, m.rune) } b1 := b[0 : len(b)-1] if FullRune(b1) { @@ -80,7 +80,7 @@ func TestEncodeRune(t *testing.T) { m := utf8map[i] b := []byte(m.str) var buf [10]byte - n := EncodeRune(m.rune, buf[0:]) + n := EncodeRune(buf[0:], m.rune) b1 := buf[0:n] if !bytes.Equal(b, b1) { t.Errorf("EncodeRune(%#04x) = %q want %q", m.rune, b1, b) @@ -166,13 +166,13 @@ func TestIntConversion(t *testing.T) { for _, ts := range testStrings { runes := []int(ts) if RuneCountInString(ts) != len(runes) { - t.Error("%q: expected %d runes; got %d", ts, len(runes), RuneCountInString(ts)) + t.Errorf("%q: expected %d runes; got %d", ts, len(runes), RuneCountInString(ts)) break } i := 0 for _, r := range ts { if r != runes[i] { - t.Errorf("%q[%d]: expected %c (U+%04x); got %c (U+%04x)", ts, i, runes[i], runes[i], r, r) + t.Errorf("%q[%d]: expected %c (%U); got %c (%U)", ts, i, runes[i], runes[i], r, r) } i++ } @@ -242,9 +242,9 @@ func testSequence(t *testing.T, s string) { // Check that negative runes encode as U+FFFD. func TestNegativeRune(t *testing.T) { errorbuf := make([]byte, UTFMax) - errorbuf = errorbuf[0:EncodeRune(RuneError, errorbuf)] + errorbuf = errorbuf[0:EncodeRune(errorbuf, RuneError)] buf := make([]byte, UTFMax) - buf = buf[0:EncodeRune(-1, buf)] + buf = buf[0:EncodeRune(buf, -1)] if !bytes.Equal(buf, errorbuf) { t.Errorf("incorrect encoding [% x] for -1; expected [% x]", buf, errorbuf) } @@ -289,14 +289,14 @@ func BenchmarkRuneCountTenJapaneseChars(b *testing.B) { func BenchmarkEncodeASCIIRune(b *testing.B) { buf := make([]byte, UTFMax) for i := 0; i < b.N; i++ { - EncodeRune('a', buf) + EncodeRune(buf, 'a') } } func BenchmarkEncodeJapaneseRune(b *testing.B) { buf := make([]byte, UTFMax) for i := 0; i < b.N; i++ { - EncodeRune('本', buf) + EncodeRune(buf, '本') } } |