Steven Verrell created CODEC-332:
------------------------------------
Summary: 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
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)