Commit 10b53867 authored by Russ Cox's avatar Russ Cox

encoding/hex: fix typo

Thanks to avadh4all for spotting it.

Fixes #1214.

R=r, r2
CC=golang-dev
https://golang.org/cl/2616041
parent 0db8d3df
......@@ -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
......
......@@ -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},
......
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