Fix bytes decoding

dev
Alberto Restifo 2020-04-19 13:45:07 +02:00
parent ed19ece346
commit 9a7ec44b66
2 changed files with 4 additions and 4 deletions

View File

@ -56,8 +56,8 @@ describe CBOR::Lexer do
# { %(23(h'01020304')), "d7 44 01 02 03 04"}, # { %(23(h'01020304')), "d7 44 01 02 03 04"},
# { %(24(h'6449455446')), "d8 18 45 64 49 45 54 46"}, # { %(24(h'6449455446')), "d8 18 45 64 49 45 54 46"},
# { %(32("http://www.example.com")), "d8 20 76 68 74 74 70 3a 2f 2f 77 77 77 2e 65 78 61 6d 70 6c 65 2e 63 6f 6d" }, # { %(32("http://www.example.com")), "d8 20 76 68 74 74 70 3a 2f 2f 77 77 77 2e 65 78 61 6d 70 6c 65 2e 63 6f 6d" },
# { %(h''), "40" }, { %(h''), "40" },
# { %(h'01020304'), "44 01 02 03 04" }, { %(h'01020304'), "44 01 02 03 04" },
# { %(""), "60" }, # { %(""), "60" },
# { %("a"), "61 61" }, # { %("a"), "61 61" },
# { %("IETF"), "64 49 45 54 46" }, # { %("IETF"), "64 49 45 54 46" },

View File

@ -71,8 +71,8 @@ class CBOR::Lexer
when 0x3b when 0x3b
consume_int(to_negative_int(read(UInt64))) consume_int(to_negative_int(read(UInt64)))
when 0x40..0x57 when 0x40..0x57
# Reads a single byte which is offset by 0x40 # read current_byte - 0x40 bytes ahead
Token::BytesT.new(@current_byte_number, value: Bytes[current_byte - 0x40]) consume_binary(current_byte - 0x40)
when 0x58 when 0x58
consume_binary(read(UInt8)) consume_binary(read(UInt8))
when 0x59 when 0x59