Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also add
impl<'a, const N: usize> From<&'a [u8; N]> for Hex
impl.I'll let ChatGPT describe the tests we added together.
Test Description
The
test_try_encode
function tests thetry_encode
function by encoding a byte slice and asserting that the result matches the expected output.The
test_try_encode_into
function tests thetry_encode_into
function by encoding a byte slice into a pre-allocatedString
and asserting that the resultingString
matches the expected output.The
test_format_into
function tests theformat_into
function by encoding a byte slice into a pre-allocatedString
using thefmt::Write
trait and asserting that the resultingString
matches the expected output.The
test_write_into
function (enabled only with thestd
feature) tests thewrite_into
function by encoding a byte slice into a vector of bytes using theio::Write
trait and asserting that the resulting vector of bytes matches the expected output.The
test_hex_iterator
function tests theHex
iterator by creating an iterator from a string, collecting the elements into aString
, and asserting that the resultingString
matches the expected output.Here's a brief overview of the additional tests:
literal_exhaustive
: This test iterates over all possible byte values (0 to 255) and checks that the corresponding hex digits are correctly generated.test_hex_iterator_with_remaining_escaped_byte
: This test verifies that theHex
iterator handles a sequence of bytes correctly, even if there is a remaining escaped byte.test_hex_iterator_empty_after_exhausted
: This test ensures that theHex
iterator becomes empty after consuming all the bytes.test_hex_iterator_not_empty_with_remaining_escaped_byte
: This test checks that theHex
iterator is not empty when there are remaining escaped bytes.test_hex_iterator_not_empty_with_remaining_byte
: Similar to the previous test, this one checks that theHex
iterator is not empty when there are remaining unescaped bytes.test_hex_iterator_empty
: This test verifies that theHex
iterator is empty when the input byte slice is empty.test_hex_iterator_with_single_escaped_byte
: This test checks that theHex
iterator correctly handles a sequence with a single escaped byte.test_hex_iterator_with_multiple_escaped_bytes
: This test ensures that theHex
iterator handles multiple escaped bytes correctly.test_hex_iterator_with_invalid_escape_sequence
: This test verifies the behavior of theHex
iterator when an invalid escape sequence is encountered.test_hex_iterator_with_no_remaining_bytes
: This test checks theHex
iterator when there are no remaining bytes after iteration.test_hex_iterator_with_emoji_sequence
: This test validates that theHex
iterator handles an input sequence containing emojis correctly.test_hex_iterator_with_chinese_hanzi_sequence
: Similar to the previous test, this one checks theHex
iterator with a sequence containing Chinese characters.These tests cover various scenarios and edge cases to ensure the correctness of the
Hex
iterator implementation.