1
0
mirror of https://github.com/golang/go synced 2024-09-24 09:30:13 -06:00

encoding/hex: fix typo

Thanks to avadh4all for spotting it.

Fixes #1214.

R=r, r2
CC=golang-dev
https://golang.org/cl/2616041
This commit is contained in:
Russ Cox 2010-10-20 16:38:57 -04:00
parent 0db8d3df4c
commit 10b53867e8
2 changed files with 3 additions and 1 deletions

View File

@ -71,7 +71,7 @@ func Decode(dst, src []byte) (int, os.Error) {
// fromHexChar converts a hex character into its value and a success flag.
func fromHexChar(c byte) (byte, bool) {
switch {
case 0 <= c && c <= '9':
case '0' <= c && c <= '9':
return c - '0', true
case 'a' <= c && c <= 'f':
return c - 'a' + 10, true

View File

@ -58,6 +58,7 @@ var decodeTests = []decodeTest{
decodeTest{[]byte{}, []byte{}, true},
decodeTest{[]byte{'0'}, []byte{}, false},
decodeTest{[]byte{'0', 'g'}, []byte{}, false},
decodeTest{[]byte{'0', '\x01'}, []byte{}, false},
decodeTest{[]byte{'0', '0'}, []byte{0}, true},
decodeTest{[]byte{'0', '1'}, []byte{1}, true},
decodeTest{[]byte{'0', '2'}, []byte{2}, true},
@ -129,6 +130,7 @@ var decodeStringTests = []decodeStringTest{
decodeStringTest{"", []byte{}, true},
decodeStringTest{"0", []byte{}, false},
decodeStringTest{"00", []byte{0}, true},
decodeStringTest{"0\x01", []byte{}, false},
decodeStringTest{"0g", []byte{}, false},
decodeStringTest{"00ff00", []byte{0, 255, 0}, true},
decodeStringTest{"0000ff", []byte{0, 0, 255}, true},