You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2025/05/19 15:10:00 UTC
[jira] [Commented] (CODEC-332) removeVowels() incorrectly treating leading whitespace as the first character
[ https://issues.apache.org/jira/browse/CODEC-332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952652#comment-17952652 ]
Gary D. Gregory commented on CODEC-332:
---------------------------------------
Hello [~ilikeprogramming]
The test provided is irrelevant because it tests the class' internals and cannot cause whitespace to be used to compute values. The encoding code cleans its input.
If you think you found a bug, create a test that only use public or protected API.
See {{MatchRatingApproachEncoderTest.testCompareWithWhitespace()}}
> removeVowels() incorrectly treating leading whitespace as the first character
> -----------------------------------------------------------------------------
>
> Key: CODEC-332
> URL: https://issues.apache.org/jira/browse/CODEC-332
> Project: Commons Codec
> Issue Type: Bug
> Affects Versions: 1.19.0
> Reporter: Steven Verrell
> Priority: Major
>
> It appears that when the input contains leading whitespace, the MatchRatingApproachEncoder.removeVowels(String) method incorrectly treats the whitespace as the first character of the word.
>
>
> For example, removeVowels(" AIDAN") => " DN"
> The expected result should be "ADN". Is there miss a step like use ".trim()" to remove whitespace from the input?
> I used the test code in "/src/test/java/org/apache/commons/codec/language
> /MatchRatingApproachEncoderTest.java" and made a minor change to trigger this error.
>
> The test code is as follows:
>
> {code:java}
> @Test
> public final void testRemoveVowel__AIDAN_Returns_ADN() {
> assertEquals("ADN", getStringEncoder().removeVowels("AIDAN")); // pass
> }
> @Test
> public final void testRemoveVowel__WithLeadingWhitespace_Returns_ADN() {
> assertEquals("ADN", getStringEncoder().removeVowels(" AIDAN")); //fail
> }
> {code}
> The testRemoveVowel_{_}AIDAN_Returns_ADN{_} test passes successfully{_},{_} while the \{_}testRemoveVowel{_}_WithLeadingWhitespace_Returns_ADN test fails and returns " DN" instead of the expected "ADN".
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)