This repository was archived by the owner on Nov 3, 2025. It is now read-only.
Add more tests to scolapasta-hex - #2598
Merged
Merged
Conversation
Additionally add a new `From` impl that accepts `&[u8; N]`. Bump version to v0.3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 Heximpl.I'll let ChatGPT describe the tests we added together.
Test Description
The
test_try_encodefunction tests thetry_encodefunction by encoding a byte slice and asserting that the result matches the expected output.The
test_try_encode_intofunction tests thetry_encode_intofunction by encoding a byte slice into a pre-allocatedStringand asserting that the resultingStringmatches the expected output.The
test_format_intofunction tests theformat_intofunction by encoding a byte slice into a pre-allocatedStringusing thefmt::Writetrait and asserting that the resultingStringmatches the expected output.The
test_write_intofunction (enabled only with thestdfeature) tests thewrite_intofunction by encoding a byte slice into a vector of bytes using theio::Writetrait and asserting that the resulting vector of bytes matches the expected output.The
test_hex_iteratorfunction tests theHexiterator by creating an iterator from a string, collecting the elements into aString, and asserting that the resultingStringmatches 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 theHexiterator handles a sequence of bytes correctly, even if there is a remaining escaped byte.test_hex_iterator_empty_after_exhausted: This test ensures that theHexiterator becomes empty after consuming all the bytes.test_hex_iterator_not_empty_with_remaining_escaped_byte: This test checks that theHexiterator 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 theHexiterator is not empty when there are remaining unescaped bytes.test_hex_iterator_empty: This test verifies that theHexiterator is empty when the input byte slice is empty.test_hex_iterator_with_single_escaped_byte: This test checks that theHexiterator correctly handles a sequence with a single escaped byte.test_hex_iterator_with_multiple_escaped_bytes: This test ensures that theHexiterator handles multiple escaped bytes correctly.test_hex_iterator_with_invalid_escape_sequence: This test verifies the behavior of theHexiterator when an invalid escape sequence is encountered.test_hex_iterator_with_no_remaining_bytes: This test checks theHexiterator when there are no remaining bytes after iteration.test_hex_iterator_with_emoji_sequence: This test validates that theHexiterator handles an input sequence containing emojis correctly.test_hex_iterator_with_chinese_hanzi_sequence: Similar to the previous test, this one checks theHexiterator with a sequence containing Chinese characters.These tests cover various scenarios and edge cases to ensure the correctness of the
Hexiterator implementation.