Repository navigation
AlphabetConverter.toString() renders the encoded value, not the original code point - #798
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
…nal code point The toString() lambda appended the Integer key (the original letter's code point, e.g. 97) after the arrow instead of the mapped encoded value (e.g. 000), leaving the declared 'v' parameter unused. This made the output show, for example, "a -> 97" rather than "a -> 000". Append the encoded value and add a regression test.
amalsaidov
force-pushed
the
fix-alphabetconverter-tostring-encoded-value
branch
from
December 1, 2026 16:34
5d5c326 to
0920708
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
AlphabetConverter.toString()renders the integer code point of each original letter instead of its encoded value.The
toString()method iteratesoriginalToEncoded(aMap<Integer, String>of original code point → encoded string) with a lambda(k, v), but appendskafter the arrow instead ofv. Thevparameter is left unused, which is the tell-tale of the mix-up (likely introduced when the loop was converted to a lambda).As a result the output shows the raw code point rather than the mapping:
toString()outputa -> 97b -> 98c -> 99d -> 100a -> 000b -> 001c -> 010d -> 011Fix
Append the encoded value
vinstead of the keyk.Test
Adds
AlphabetConverterTest.testToStringRendersEncodedValues, which asserts eachoriginal -> encodedmapping appears intoString(). It fails before the fix (output containsa -> 97, nota -> 000) and passes after. The existingtoString()round-trip assertion is unaffected.AlphabetConverterTest: 21/21 green.mvn checkstyle:checkandmvn pmd:check: clean.