Commit 1959c3ac authored by Rob Pike's avatar Rob Pike

tests: fix prints

- delete unnecessary newlines
- make sure formatted prints call the formatting routines

R=adg
CC=golang-dev
https://golang.org/cl/2225046
parent c10865ce
......@@ -367,7 +367,7 @@ func TestCertificate(t *testing.T) {
t.Errorf("Unmarshal failed: %v", err)
}
if !reflect.DeepEqual(cert, derEncodedSelfSignedCert) {
t.Errorf("Bad result:\ngot: %+v\nwant: %+v\n", cert, derEncodedSelfSignedCert)
t.Errorf("Bad result:\ngot: %+v\nwant: %+v", cert, derEncodedSelfSignedCert)
}
}
......
......@@ -310,13 +310,13 @@ func TestGetString(t *testing.T) {
if test.base == 10 {
s := z.String()
if s != test.out {
t.Errorf("#%da got %s; want %s\n", i, s, test.out)
t.Errorf("#%da got %s; want %s", i, s, test.out)
}
}
s := fmt.Sprintf(format(test.base), z)
if s != test.out {
t.Errorf("#%db got %s; want %s\n", i, s, test.out)
t.Errorf("#%db got %s; want %s", i, s, test.out)
}
}
}
......@@ -344,10 +344,10 @@ func TestSetString(t *testing.T) {
}
if n1.Cmp(expected) != 0 {
t.Errorf("#%d (input '%s') got: %s want: %d\n", i, test.in, n1, test.val)
t.Errorf("#%d (input '%s') got: %s want: %d", i, test.in, n1, test.val)
}
if n2.Cmp(expected) != 0 {
t.Errorf("#%d (input '%s') got: %s want: %d\n", i, test.in, n2, test.val)
t.Errorf("#%d (input '%s') got: %s want: %d", i, test.in, n2, test.val)
}
}
}
......@@ -582,7 +582,7 @@ func TestBitLen(t *testing.T) {
}
if n := x.BitLen(); n != test.out {
t.Errorf("#%d got %d want %d\n", i, n, test.out)
t.Errorf("#%d got %d want %d", i, n, test.out)
}
}
}
......
......@@ -301,7 +301,7 @@ func runModWTests(t *testing.T, tests []modWTest) {
r := in.abs.modW(d.abs[0])
if r != out.abs[0] {
t.Errorf("#%d failed: got %s want %s\n", i, r, out)
t.Errorf("#%d failed: got %s want %s", i, r, out)
}
}
}
......@@ -322,7 +322,7 @@ func TestTrailingZeroBits(t *testing.T) {
x--
for i := 0; i < _W; i++ {
if trailingZeroBits(x) != i {
t.Errorf("Failed at step %d: x: %x got: %d\n", i, x, trailingZeroBits(x))
t.Errorf("Failed at step %d: x: %x got: %d", i, x, trailingZeroBits(x))
}
x <<= 1
}
......
......@@ -69,7 +69,7 @@ func TestReaderSimple(t *testing.T) {
b = NewReader(newRot13Reader(bytes.NewBufferString(data)))
if s := readBytes(b); s != "uryyb jbeyq" {
t.Error("rot13 hello world test failed: got %q", s)
t.Errorf("rot13 hello world test failed: got %q", s)
}
}
......@@ -250,7 +250,7 @@ func TestUnreadRune(t *testing.T) {
t.Error("unexpected error reading after unreading:", err)
}
if rune != rune1 {
t.Error("incorrect rune after unread: got %c wanted %c", rune1, rune)
t.Errorf("incorrect rune after unread: got %c wanted %c", rune1, rune)
}
}
if got != data {
......
......@@ -30,19 +30,19 @@ func check(t *testing.T, testname string, buf *Buffer, s string) {
bytes := buf.Bytes()
str := buf.String()
if buf.Len() != len(bytes) {
t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d\n", testname, buf.Len(), len(bytes))
t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d", testname, buf.Len(), len(bytes))
}
if buf.Len() != len(str) {
t.Errorf("%s: buf.Len() == %d, len(buf.String()) == %d\n", testname, buf.Len(), len(str))
t.Errorf("%s: buf.Len() == %d, len(buf.String()) == %d", testname, buf.Len(), len(str))
}
if buf.Len() != len(s) {
t.Errorf("%s: buf.Len() == %d, len(s) == %d\n", testname, buf.Len(), len(s))
t.Errorf("%s: buf.Len() == %d, len(s) == %d", testname, buf.Len(), len(s))
}
if string(bytes) != s {
t.Errorf("%s: string(buf.Bytes()) == %q, s == %q\n", testname, string(bytes), s)
t.Errorf("%s: string(buf.Bytes()) == %q, s == %q", testname, string(bytes), s)
}
}
......@@ -55,10 +55,10 @@ func fillString(t *testing.T, testname string, buf *Buffer, s string, n int, fus
for ; n > 0; n-- {
m, err := buf.WriteString(fus)
if m != len(fus) {
t.Errorf(testname+" (fill 2): m == %d, expected %d\n", m, len(fus))
t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fus))
}
if err != nil {
t.Errorf(testname+" (fill 3): err should always be nil, found err == %s\n", err)
t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
}
s += fus
check(t, testname+" (fill 4)", buf, s)
......@@ -75,10 +75,10 @@ func fillBytes(t *testing.T, testname string, buf *Buffer, s string, n int, fub
for ; n > 0; n-- {
m, err := buf.Write(fub)
if m != len(fub) {
t.Errorf(testname+" (fill 2): m == %d, expected %d\n", m, len(fub))
t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fub))
}
if err != nil {
t.Errorf(testname+" (fill 3): err should always be nil, found err == %s\n", err)
t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
}
s += string(fub)
check(t, testname+" (fill 4)", buf, s)
......@@ -110,7 +110,7 @@ func empty(t *testing.T, testname string, buf *Buffer, s string, fub []byte) {
break
}
if err != nil {
t.Errorf(testname+" (empty 2): err should always be nil, found err == %s\n", err)
t.Errorf(testname+" (empty 2): err should always be nil, found err == %s", err)
}
s = s[n:]
check(t, testname+" (empty 3)", buf, s)
......@@ -134,10 +134,10 @@ func TestBasicOperations(t *testing.T) {
n, err := buf.Write(Bytes(data[0:1]))
if n != 1 {
t.Errorf("wrote 1 byte, but n == %d\n", n)
t.Errorf("wrote 1 byte, but n == %d", n)
}
if err != nil {
t.Errorf("err should always be nil, but err == %s\n", err)
t.Errorf("err should always be nil, but err == %s", err)
}
check(t, "TestBasicOperations (4)", &buf, "a")
......@@ -146,7 +146,7 @@ func TestBasicOperations(t *testing.T) {
n, err = buf.Write(Bytes(data[2:26]))
if n != 24 {
t.Errorf("wrote 25 bytes, but n == %d\n", n)
t.Errorf("wrote 25 bytes, but n == %d", n)
}
check(t, "TestBasicOperations (6)", &buf, string(data[0:26]))
......@@ -162,14 +162,14 @@ func TestBasicOperations(t *testing.T) {
buf.WriteByte(data[1])
c, err := buf.ReadByte()
if err != nil {
t.Errorf("ReadByte unexpected eof\n")
t.Error("ReadByte unexpected eof")
}
if c != data[1] {
t.Errorf("ReadByte wrong value c=%v\n", c)
t.Error("ReadByte wrong value c=%v", c)
}
c, err = buf.ReadByte()
if err == nil {
t.Errorf("ReadByte unexpected not eof\n")
t.Error("ReadByte unexpected not eof")
}
}
}
......@@ -238,7 +238,7 @@ func TestMixedReadsAndWrites(t *testing.T) {
func TestNil(t *testing.T) {
var b *Buffer
if b.String() != "<nil>" {
t.Error("expcted <nil>; got %q", b.String())
t.Errorf("expcted <nil>; got %q", b.String())
}
}
......
This diff is collapsed.
......@@ -76,7 +76,7 @@ func TestMapCounter(t *testing.T) {
t.Error("red.Kind() is not a number.")
}
if x != 3 {
t.Error("red = %v, want 3", x)
t.Errorf("red = %v, want 3", x)
}
}
......
......@@ -594,15 +594,15 @@ func TestFormatterPrintln(t *testing.T) {
expect := "<v=F(1)>\n"
s := Sprint(f, "\n")
if s != expect {
t.Errorf("Sprint wrong with Formatter: expected %q got %q\n", expect, s)
t.Errorf("Sprint wrong with Formatter: expected %q got %q", expect, s)
}
s = Sprintln(f)
if s != expect {
t.Errorf("Sprintln wrong with Formatter: expected %q got %q\n", expect, s)
t.Errorf("Sprintln wrong with Formatter: expected %q got %q", expect, s)
}
s = Sprintf("%v\n", f)
if s != expect {
t.Errorf("Sprintf wrong with Formatter: expected %q got %q\n", expect, s)
t.Errorf("Sprintf wrong with Formatter: expected %q got %q", expect, s)
}
}
......
......@@ -64,7 +64,7 @@ func TestUintCodec(t *testing.T) {
t.Error("DecodeUint:", u, decState.err)
}
if u != v {
t.Errorf("Encode/Decode: sent %#x received %#x\n", u, v)
t.Errorf("Encode/Decode: sent %#x received %#x", u, v)
}
if u&(1<<63) != 0 {
break
......@@ -87,7 +87,7 @@ func verifyInt(i int64, t *testing.T) {
t.Error("DecodeInt:", i, decState.err)
}
if i != j {
t.Errorf("Encode/Decode: sent %#x received %#x\n", uint64(i), uint64(j))
t.Errorf("Encode/Decode: sent %#x received %#x", uint64(i), uint64(j))
}
}
......
......@@ -55,7 +55,7 @@ func TestEncoderDecoder(t *testing.T) {
}
if !reflect.DeepEqual(et1, newEt1) {
t.Fatalf("invalid data for et1: expected %+v; got %+v\n", *et1, *newEt1)
t.Fatalf("invalid data for et1: expected %+v; got %+v", *et1, *newEt1)
}
if b.Len() != 0 {
t.Error("not at eof;", b.Len(), "bytes left")
......@@ -68,7 +68,7 @@ func TestEncoderDecoder(t *testing.T) {
t.Fatal("round 2: error decoding ET1:", dec.state.err)
}
if !reflect.DeepEqual(et1, newEt1) {
t.Fatalf("round 2: invalid data for et1: expected %+v; got %+v\n", *et1, *newEt1)
t.Fatalf("round 2: invalid data for et1: expected %+v; got %+v", *et1, *newEt1)
}
if b.Len() != 0 {
t.Error("round 2: not at eof;", b.Len(), "bytes left")
......
......@@ -83,6 +83,6 @@ func TestMultiWriter(t *testing.T) {
}
if sink.String() != sourceString {
t.Error("expected %q; got %q", sourceString, sink.String())
t.Errorf("expected %q; got %q", sourceString, sink.String())
}
}
This diff is collapsed.
......@@ -39,7 +39,7 @@ func exportReceive(exp *Exporter, t *testing.T) {
v := <-ch
if closed(ch) {
if i != closeCount {
t.Errorf("exportReceive expected close at %d; got one at %d\n", closeCount, i)
t.Errorf("exportReceive expected close at %d; got one at %d", closeCount, i)
}
break
}
......@@ -73,7 +73,7 @@ func importReceive(imp *Importer, t *testing.T, done chan bool) {
v := <-ch
if closed(ch) {
if i != closeCount {
t.Errorf("importReceive expected close at %d; got one at %d\n", closeCount, i)
t.Errorf("importReceive expected close at %d; got one at %d", closeCount, i)
}
break
}
......
......@@ -144,7 +144,7 @@ Body.
// Just the body?
r, err := conn.Body(fmt.Sprintf("%d", l))
if err != nil {
t.Fatal("should be able to fetch the low article body\n" + err.String())
t.Fatal("should be able to fetch the low article body" + err.String())
}
if _, err = ioutil.ReadAll(r); err != nil {
t.Fatal("error reading reader: " + err.String())
......
......@@ -71,7 +71,7 @@ func TestMatch(t *testing.T) {
for _, tt := range matchTests {
ok, err := Match(tt.pattern, tt.s)
if ok != tt.match || err != tt.err {
t.Errorf("Match(%#q, %#q) = %v, %v want %v, nil\n", tt.pattern, tt.s, ok, err, tt.match)
t.Errorf("Match(%#q, %#q) = %v, %v want %v, nil", tt.pattern, tt.s, ok, err, tt.match)
}
}
}
......@@ -290,26 +290,26 @@ func compareFloat32Slices(s1, s2 []float32) int {
func TestNormTables(t *testing.T) {
testKn, testWn, testFn := initNorm()
if i := compareUint32Slices(kn[0:], testKn); i >= 0 {
t.Errorf("kn disagrees at index %v; %v != %v\n", i, kn[i], testKn[i])
t.Errorf("kn disagrees at index %v; %v != %v", i, kn[i], testKn[i])
}
if i := compareFloat32Slices(wn[0:], testWn); i >= 0 {
t.Errorf("wn disagrees at index %v; %v != %v\n", i, wn[i], testWn[i])
t.Errorf("wn disagrees at index %v; %v != %v", i, wn[i], testWn[i])
}
if i := compareFloat32Slices(fn[0:], testFn); i >= 0 {
t.Errorf("fn disagrees at index %v; %v != %v\n", i, fn[i], testFn[i])
t.Errorf("fn disagrees at index %v; %v != %v", i, fn[i], testFn[i])
}
}
func TestExpTables(t *testing.T) {
testKe, testWe, testFe := initExp()
if i := compareUint32Slices(ke[0:], testKe); i >= 0 {
t.Errorf("ke disagrees at index %v; %v != %v\n", i, ke[i], testKe[i])
t.Errorf("ke disagrees at index %v; %v != %v", i, ke[i], testKe[i])
}
if i := compareFloat32Slices(we[0:], testWe); i >= 0 {
t.Errorf("we disagrees at index %v; %v != %v\n", i, we[i], testWe[i])
t.Errorf("we disagrees at index %v; %v != %v", i, we[i], testWe[i])
}
if i := compareFloat32Slices(fe[0:], testFe); i >= 0 {
t.Errorf("fe disagrees at index %v; %v != %v\n", i, fe[i], testFe[i])
t.Errorf("fe disagrees at index %v; %v != %v", i, fe[i], testFe[i])
}
}
......
......@@ -112,14 +112,14 @@ func testAtof(t *testing.T, opt bool) {
out, err := Atof64(test.in)
outs := Ftoa64(out, 'g', -1)
if outs != test.out || !reflect.DeepEqual(err, test.err) {
t.Errorf("Atof64(%v) = %v, %v want %v, %v\n",
t.Errorf("Atof64(%v) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
out, err = AtofN(test.in, 64)
outs = FtoaN(out, 'g', -1, 64)
if outs != test.out || !reflect.DeepEqual(err, test.err) {
t.Errorf("AtofN(%v, 64) = %v, %v want %v, %v\n",
t.Errorf("AtofN(%v, 64) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
......@@ -127,7 +127,7 @@ func testAtof(t *testing.T, opt bool) {
out32, err := Atof32(test.in)
outs := Ftoa32(out32, 'g', -1)
if outs != test.out || !reflect.DeepEqual(err, test.err) {
t.Errorf("Atof32(%v) = %v, %v want %v, %v # %v\n",
t.Errorf("Atof32(%v) = %v, %v want %v, %v # %v",
test.in, out32, err, test.out, test.err, out)
}
......@@ -135,7 +135,7 @@ func testAtof(t *testing.T, opt bool) {
out32 = float32(out)
outs = FtoaN(float64(out32), 'g', -1, 32)
if outs != test.out || !reflect.DeepEqual(err, test.err) {
t.Errorf("AtofN(%v, 32) = %v, %v want %v, %v # %v\n",
t.Errorf("AtofN(%v, 32) = %v, %v want %v, %v # %v",
test.in, out32, err, test.out, test.err, out)
}
}
......@@ -144,7 +144,7 @@ func testAtof(t *testing.T, opt bool) {
outf, err := Atof(test.in)
outs := Ftoa(outf, 'g', -1)
if outs != test.out || !reflect.DeepEqual(err, test.err) {
t.Errorf("Ftoa(%v) = %v, %v want %v, %v # %v\n",
t.Errorf("Ftoa(%v) = %v, %v want %v, %v # %v",
test.in, outf, err, test.out, test.err, out)
}
}
......
......@@ -193,7 +193,7 @@ func TestAtoui64(t *testing.T) {
test := &atoui64tests[i]
out, err := Atoui64(test.in)
if test.out != out || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoui64(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoui64(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -204,7 +204,7 @@ func TestBtoui64(t *testing.T) {
test := &btoui64tests[i]
out, err := Btoui64(test.in, 0)
if test.out != out || !reflect.DeepEqual(test.err, err) {
t.Errorf("Btoui64(%q) = %v, %v want %v, %v\n",
t.Errorf("Btoui64(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -215,7 +215,7 @@ func TestAtoi64(t *testing.T) {
test := &atoi64tests[i]
out, err := Atoi64(test.in)
if test.out != out || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoi64(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoi64(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -226,7 +226,7 @@ func TestBtoi64(t *testing.T) {
test := &btoi64tests[i]
out, err := Btoi64(test.in, 0)
if test.out != out || !reflect.DeepEqual(test.err, err) {
t.Errorf("Btoi64(%q) = %v, %v want %v, %v\n",
t.Errorf("Btoi64(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -239,7 +239,7 @@ func TestAtoui(t *testing.T) {
test := &atoui32tests[i]
out, err := Atoui(test.in)
if test.out != uint32(out) || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoui(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoui(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -248,7 +248,7 @@ func TestAtoui(t *testing.T) {
test := &atoui64tests[i]
out, err := Atoui(test.in)
if test.out != uint64(out) || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoui(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoui(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -262,7 +262,7 @@ func TestAtoi(t *testing.T) {
test := &atoi32tests[i]
out, err := Atoi(test.in)
if test.out != int32(out) || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoi(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoi(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......@@ -271,7 +271,7 @@ func TestAtoi(t *testing.T) {
test := &atoi64tests[i]
out, err := Atoi(test.in)
if test.out != int64(out) || !reflect.DeepEqual(test.err, err) {
t.Errorf("Atoi(%q) = %v, %v want %v, %v\n",
t.Errorf("Atoi(%q) = %v, %v want %v, %v",
test.in, out, err, test.out, test.err)
}
}
......
......@@ -34,7 +34,7 @@ func TestDecimalShift(t *testing.T) {
test := &shifttests[i]
s := NewDecimal(test.i).Shift(test.shift).String()
if s != test.out {
t.Errorf("Decimal %v << %v = %v, want %v\n",
t.Errorf("Decimal %v << %v = %v, want %v",
test.i, test.shift, s, test.out)
}
}
......@@ -70,17 +70,17 @@ func TestDecimalRound(t *testing.T) {
test := &roundtests[i]
s := NewDecimal(test.i).RoundDown(test.nd).String()
if s != test.down {
t.Errorf("Decimal %v RoundDown %d = %v, want %v\n",
t.Errorf("Decimal %v RoundDown %d = %v, want %v",
test.i, test.nd, s, test.down)
}
s = NewDecimal(test.i).Round(test.nd).String()
if s != test.round {
t.Errorf("Decimal %v Round %d = %v, want %v\n",
t.Errorf("Decimal %v Round %d = %v, want %v",
test.i, test.nd, s, test.down)
}
s = NewDecimal(test.i).RoundUp(test.nd).String()
if s != test.up {
t.Errorf("Decimal %v RoundUp %d = %v, want %v\n",
t.Errorf("Decimal %v RoundUp %d = %v, want %v",
test.i, test.nd, s, test.up)
}
}
......@@ -110,7 +110,7 @@ func TestDecimalRoundedInteger(t *testing.T) {
test := roundinttests[i]
int := NewDecimal(test.i).Shift(test.shift).RoundedInteger()
if int != test.int {
t.Errorf("Decimal %v >> %v RoundedInteger = %v, want %v\n",
t.Errorf("Decimal %v >> %v RoundedInteger = %v, want %v",
test.i, test.shift, int, test.int)
}
}
......
......@@ -118,7 +118,7 @@ func TestFp(t *testing.T) {
}
a := strings.Split(line, " ", -1)
if len(a) != 4 {
t.Error("testfp.txt:", lineno, ": wrong field count\n")
t.Error("testfp.txt:", lineno, ": wrong field count")
continue
}
var s string
......
......@@ -62,14 +62,14 @@ func TestItoa(t *testing.T) {
for _, test := range itob64tests {
s := Itob64(test.in, test.base)
if s != test.out {
t.Errorf("Itob64(%v, %v) = %v want %v\n",
t.Errorf("Itob64(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
if test.in >= 0 {
s := Uitob64(uint64(test.in), test.base)
if s != test.out {
t.Errorf("Uitob64(%v, %v) = %v want %v\n",
t.Errorf("Uitob64(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
}
......@@ -77,14 +77,14 @@ func TestItoa(t *testing.T) {
if int64(int(test.in)) == test.in {
s := Itob(int(test.in), test.base)
if s != test.out {
t.Errorf("Itob(%v, %v) = %v want %v\n",
t.Errorf("Itob(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
if test.in >= 0 {
s := Uitob(uint(test.in), test.base)
if s != test.out {
t.Errorf("Uitob(%v, %v) = %v want %v\n",
t.Errorf("Uitob(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
}
......@@ -93,14 +93,14 @@ func TestItoa(t *testing.T) {
if test.base == 10 {
s := Itoa64(test.in)
if s != test.out {
t.Errorf("Itoa64(%v) = %v want %v\n",
t.Errorf("Itoa64(%v) = %v want %v",
test.in, s, test.out)
}
if test.in >= 0 {
s := Uitob64(uint64(test.in), test.base)
if s != test.out {
t.Errorf("Uitob64(%v, %v) = %v want %v\n",
t.Errorf("Uitob64(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
}
......@@ -108,14 +108,14 @@ func TestItoa(t *testing.T) {
if int64(int(test.in)) == test.in {
s := Itoa(int(test.in))
if s != test.out {
t.Errorf("Itoa(%v) = %v want %v\n",
t.Errorf("Itoa(%v) = %v want %v",
test.in, s, test.out)
}
if test.in >= 0 {
s := Uitoa(uint(test.in))
if s != test.out {
t.Errorf("Uitoa(%v) = %v want %v\n",
t.Errorf("Uitoa(%v) = %v want %v",
test.in, s, test.out)
}
}
......@@ -143,14 +143,14 @@ func TestUitoa(t *testing.T) {
for _, test := range uitob64tests {
s := Uitob64(test.in, test.base)
if s != test.out {
t.Errorf("Uitob64(%v, %v) = %v want %v\n",
t.Errorf("Uitob64(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
if uint64(uint(test.in)) == test.in {
s := Uitob(uint(test.in), test.base)
if s != test.out {
t.Errorf("Uitob(%v, %v) = %v want %v\n",
t.Errorf("Uitob(%v, %v) = %v want %v",
test.in, test.base, s, test.out)
}
}
......@@ -158,14 +158,14 @@ func TestUitoa(t *testing.T) {
if test.base == 10 {
s := Uitoa64(test.in)
if s != test.out {
t.Errorf("Uitoa64(%v) = %v want %v\n",
t.Errorf("Uitoa64(%v) = %v want %v",
test.in, s, test.out)
}
if uint64(uint(test.in)) == test.in {
s := Uitoa(uint(test.in))
if s != test.out {
t.Errorf("Uitoa(%v) = %v want %v\n",
t.Errorf("Uitoa(%v) = %v want %v",
test.in, s, test.out)
}
}
......
......@@ -47,7 +47,7 @@ func TestNew(t *testing.T) {
func TestNewLogger(t *testing.T) {
f := NewLogger(LOG_INFO, 0)
if f == nil {
t.Errorf("NewLogger() failed\n")
t.Errorf("NewLogger() failed")
}
}
......
......@@ -209,28 +209,28 @@ func TestRubyParse(t *testing.T) {
func checkTime(time *Time, test *ParseTest, t *testing.T) {
// The time should be Thu Feb 4 21:00:57 PST 2010
if test.yearSign*time.Year != 2010 {
t.Errorf("%s: bad year: %d not %d\n", test.name, time.Year, 2010)
t.Errorf("%s: bad year: %d not %d", test.name, time.Year, 2010)
}
if time.Month != 2 {
t.Errorf("%s: bad month: %d not %d\n", test.name, time.Month, 2)
t.Errorf("%s: bad month: %d not %d", test.name, time.Month, 2)
}
if time.Day != 4 {
t.Errorf("%s: bad day: %d not %d\n", test.name, time.Day, 4)
t.Errorf("%s: bad day: %d not %d", test.name, time.Day, 4)
}
if time.Hour != 21 {
t.Errorf("%s: bad hour: %d not %d\n", test.name, time.Hour, 21)
t.Errorf("%s: bad hour: %d not %d", test.name, time.Hour, 21)
}
if time.Minute != 0 {
t.Errorf("%s: bad minute: %d not %d\n", test.name, time.Minute, 0)
t.Errorf("%s: bad minute: %d not %d", test.name, time.Minute, 0)
}
if time.Second != 57 {
t.Errorf("%s: bad second: %d not %d\n", test.name, time.Second, 57)
t.Errorf("%s: bad second: %d not %d", test.name, time.Second, 57)
}
if test.hasTZ && time.ZoneOffset != -28800 {
t.Errorf("%s: bad tz offset: %d not %d\n", test.name, time.ZoneOffset, -28800)
t.Errorf("%s: bad tz offset: %d not %d", test.name, time.ZoneOffset, -28800)
}
if test.hasWD && time.Weekday != 4 {
t.Errorf("%s: bad weekday: %d not %d\n", test.name, time.Weekday, 4)
t.Errorf("%s: bad weekday: %d not %d", test.name, time.Weekday, 4)
}
}
......@@ -283,9 +283,9 @@ func TestParseErrors(t *testing.T) {
for _, test := range parseErrorTests {
_, err := Parse(test.format, test.value)
if err == nil {
t.Errorf("expected error for %q %q\n", test.format, test.value)
t.Errorf("expected error for %q %q", test.format, test.value)
} else if strings.Index(err.String(), test.expect) < 0 {
t.Errorf("expected error with %q for %q %q; got %s\n", test.expect, test.format, test.value, err)
t.Errorf("expected error with %q for %q %q; got %s", test.expect, test.format, test.value, err)
}
}
}
......
......@@ -106,12 +106,12 @@ var testLetter = []int{
func TestDigit(t *testing.T) {
for _, r := range testDigit {
if !IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = false, want true\n", r)
t.Errorf("IsDigit(U+%04X) = false, want true", r)
}
}
for _, r := range testLetter {
if IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = true, want false\n", r)
t.Errorf("IsDigit(U+%04X) = true, want false", r)
}
}
}
......
......@@ -216,17 +216,17 @@ var caseTest = []caseT{
func TestIsLetter(t *testing.T) {
for _, r := range upperTest {
if !IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = false, want true\n", r)
t.Errorf("IsLetter(U+%04X) = false, want true", r)
}
}
for _, r := range letterTest {
if !IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = false, want true\n", r)
t.Errorf("IsLetter(U+%04X) = false, want true", r)
}
}
for _, r := range notletterTest {
if IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = true, want false\n", r)
t.Errorf("IsLetter(U+%04X) = true, want false", r)
}
}
}
......@@ -234,17 +234,17 @@ func TestIsLetter(t *testing.T) {
func TestIsUpper(t *testing.T) {
for _, r := range upperTest {
if !IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = false, want true\n", r)
t.Errorf("IsUpper(U+%04X) = false, want true", r)
}
}
for _, r := range notupperTest {
if IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = true, want false\n", r)
t.Errorf("IsUpper(U+%04X) = true, want false", r)
}
}
for _, r := range notletterTest {
if IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = true, want false\n", r)
t.Errorf("IsUpper(U+%04X) = true, want false", r)
}
}
}
......@@ -265,7 +265,7 @@ func TestTo(t *testing.T) {
for _, c := range caseTest {
r := To(c.cas, c.in)
if c.out != r {
t.Errorf("To(U+%04X, %s) = U+%04X want U+%04X\n", c.in, caseString(c.cas), r, c.out)
t.Errorf("To(U+%04X, %s) = U+%04X want U+%04X", c.in, caseString(c.cas), r, c.out)
}
}
}
......@@ -277,7 +277,7 @@ func TestToUpperCase(t *testing.T) {
}
r := ToUpper(c.in)
if c.out != r {
t.Errorf("ToUpper(U+%04X) = U+%04X want U+%04X\n", c.in, r, c.out)
t.Errorf("ToUpper(U+%04X) = U+%04X want U+%04X", c.in, r, c.out)
}
}
}
......@@ -289,7 +289,7 @@ func TestToLowerCase(t *testing.T) {
}
r := ToLower(c.in)
if c.out != r {
t.Errorf("ToLower(U+%04X) = U+%04X want U+%04X\n", c.in, r, c.out)
t.Errorf("ToLower(U+%04X) = U+%04X want U+%04X", c.in, r, c.out)
}
}
}
......@@ -301,7 +301,7 @@ func TestToTitleCase(t *testing.T) {
}
r := ToTitle(c.in)
if c.out != r {
t.Errorf("ToTitle(U+%04X) = U+%04X want U+%04X\n", c.in, r, c.out)
t.Errorf("ToTitle(U+%04X) = U+%04X want U+%04X", c.in, r, c.out)
}
}
}
......
......@@ -194,13 +194,13 @@ func TestScripts(t *testing.T) {
t.Fatal(test.script, "not a known script")
}
if !Is(Scripts[test.script], test.rune) {
t.Errorf("IsScript(%#x, %s) = false, want true\n", test.rune, test.script)
t.Errorf("IsScript(%#x, %s) = false, want true", test.rune, test.script)
}
notTested[test.script] = false, false
}
for _, test := range outTest {
if Is(Scripts[test.script], test.rune) {
t.Errorf("IsScript(%#x, %s) = true, want false\n", test.rune, test.script)
t.Errorf("IsScript(%#x, %s) = true, want false", test.rune, test.script)
}
}
for k := range notTested {
......@@ -218,7 +218,7 @@ func TestCategories(t *testing.T) {
t.Fatal(test.script, "not a known category")
}
if !Is(Categories[test.script], test.rune) {
t.Errorf("IsCategory(%#x, %s) = false, want true\n", test.rune, test.script)
t.Errorf("IsCategory(%#x, %s) = false, want true", test.rune, test.script)
}
notTested[test.script] = false, false
}
......@@ -237,7 +237,7 @@ func TestProperties(t *testing.T) {
t.Fatal(test.script, "not a known prop")
}
if !Is(Properties[test.script], test.rune) {
t.Errorf("IsCategory(%#x, %s) = false, want true\n", test.rune, test.script)
t.Errorf("IsCategory(%#x, %s) = false, want true", test.rune, test.script)
}
notTested[test.script] = false, false
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment