Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(781)

Delta Between Two Patch Sets: src/pkg/encoding/hex/hex_test.go

Issue 7038051: code review 7038051: src: Use bytes.Equal instead of bytes.Compare where pos... (Closed)
Left Patch Set: Created 11 years, 2 months ago
Right Patch Set: diff -r be6ca9f6bfe8 https://code.google.com/p/go Created 11 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/encoding/asn1/marshal_test.go ('k') | src/pkg/encoding/json/decode_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package hex 5 package hex
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 ) 10 )
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 } 59 }
60 60
61 func TestDecodeString(t *testing.T) { 61 func TestDecodeString(t *testing.T) {
62 for i, test := range encDecTests { 62 for i, test := range encDecTests {
63 dst, err := DecodeString(test.enc) 63 dst, err := DecodeString(test.enc)
64 if err != nil { 64 if err != nil {
65 t.Errorf("#%d: unexpected err value: %s", i, err) 65 t.Errorf("#%d: unexpected err value: %s", i, err)
66 continue 66 continue
67 } 67 }
68 » » if bytes.Compare(dst, test.dec) != 0 { 68 » » if !bytes.Equal(dst, test.dec) {
69 t.Errorf("#%d: got: %#v want: #%v", i, dst, test.dec) 69 t.Errorf("#%d: got: %#v want: #%v", i, dst, test.dec)
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 type errTest struct { 74 type errTest struct {
75 in string 75 in string
76 err string 76 err string
77 } 77 }
78 78
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 out := []byte(Dump(in[:])) 140 out := []byte(Dump(in[:]))
141 if !bytes.Equal(out, expectedHexDump) { 141 if !bytes.Equal(out, expectedHexDump) {
142 t.Errorf("got:\n%s\nwant:\n%s", out, expectedHexDump) 142 t.Errorf("got:\n%s\nwant:\n%s", out, expectedHexDump)
143 } 143 }
144 } 144 }
145 145
146 var expectedHexDump = []byte(`00000000 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d |.. !"#$%&'()*+,-| 146 var expectedHexDump = []byte(`00000000 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d |.. !"#$%&'()*+,-|
147 00000010 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d |./0123456789:;<=| 147 00000010 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d |./0123456789:;<=|
148 00000020 3e 3f 40 41 42 43 44 45 |>?@ABCDE| 148 00000020 3e 3f 40 41 42 43 44 45 |>?@ABCDE|
149 `) 149 `)
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b