[ { "fn": "hexEncode", "name": "no bytes is the empty string", "args": [[]], "expect": "" }, { "fn": "hexEncode", "name": "a zero byte keeps its leading zero", "args": [[0]], "expect": "00" }, { "fn": "hexEncode", "name": "the largest byte", "args": [[255]], "expect": "ff" }, { "fn": "hexEncode", "name": "RFC 4648 section 10: \"f\"", "args": [[102]], "expect": "66" }, { "fn": "hexEncode", "name": "RFC 4648 section 10: \"foobar\", written in lowercase", "args": [[102, 111, 111, 98, 97, 114]], "expect": "666f6f626172" }, { "fn": "hexEncode", "name": "the classic deadbeef", "args": [[222, 173, 190, 239]], "expect": "deadbeef" }, { "fn": "hexEncode", "name": "every small byte keeps two digits, which toString(16) alone gets wrong", "args": [[0, 1, 15, 16, 127, 128, 254]], "expect": "00010f107f80fe" }, { "fn": "hexEncode", "name": "256 is not a byte and is not masked to 00", "args": [[1, 256]], "expectError": "bytes must be a list of integers from 0 to 255" }, { "fn": "hexEncode", "name": "a negative value is not a byte", "args": [[-1]], "expectError": "bytes must be a list of integers from 0 to 255" }, { "fn": "hexEncode", "name": "a fraction is not a byte", "args": [[1.5]], "expectError": "bytes must be a list of integers from 0 to 255" }, { "fn": "hexEncode", "name": "a string inside the list is not a byte", "args": [["a"]], "expectError": "bytes must be a list of integers from 0 to 255" }, { "fn": "hexEncode", "name": "a boolean is not a byte, even where the language treats it as 1", "args": [[true]], "expectError": "bytes must be a list of integers from 0 to 255" }, { "fn": "hexDecode", "name": "the empty string is no bytes", "args": [""], "expect": [] }, { "fn": "hexDecode", "name": "RFC 4648 section 10: \"foobar\" as the RFC prints it, in uppercase", "args": ["666F6F626172"], "expect": [102, 111, 111, 98, 97, 114] }, { "fn": "hexDecode", "name": "the same bytes in lowercase", "args": ["666f6f626172"], "expect": [102, 111, 111, 98, 97, 114] }, { "fn": "hexDecode", "name": "mixed case", "args": ["DEADbeef"], "expect": [222, 173, 190, 239] }, { "fn": "hexDecode", "name": "the smallest and largest bytes", "args": ["00ff"], "expect": [0, 255] }, { "fn": "hexDecode", "name": "a single digit is half a byte", "args": ["0"], "expectError": "hex text must have an even number of digits, received 1" }, { "fn": "hexDecode", "name": "an odd number of digits", "args": ["abc"], "expectError": "hex text must have an even number of digits, received 3" }, { "fn": "hexDecode", "name": "a 0x prefix is not accepted", "args": ["0x00"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" }, { "fn": "hexDecode", "name": "spaces between bytes are not skipped", "args": ["00 ff"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" }, { "fn": "hexDecode", "name": "a trailing newline is an error, not trimmed", "args": ["00\n"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" }, { "fn": "hexDecode", "name": "letters past f", "args": ["gg"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" }, { "fn": "hexDecode", "name": "Arabic-Indic digits are not hex digits", "args": ["٠٠"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" }, { "fn": "hexDecode", "name": "full-width digits are not hex digits", "args": ["01"], "expectError": "hex text may only contain the digits 0-9, a-f and A-F" } ]