LEFT | RIGHT |
(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 Loading... |
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 Loading... |
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 `) |
LEFT | RIGHT |