Zhongxin Yan created LANG-1798:
----------------------------------

             Summary: In the unit test testCountMatches_char of 
StringUtilsSubstringTest, one of the assertions is calling the wrong overload 
of countMatches
                 Key: LANG-1798
                 URL: https://issues.apache.org/jira/browse/LANG-1798
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.*
    Affects Versions: 3.20.0
         Environment: {code:java}
// code placeholder
{code}
            Reporter: Zhongxin Yan


In the unit test {{testCountMatches_char}} of StringUtilsSubstringTest, one of 
the assertions is calling the wrong overload of {{{}countMatches{}}}.
{code:java}
// code placeholder
@Test
void testCountMatches_char() {
    assertEquals(0, StringUtils.countMatches(null, 'D'));
    assertEquals(5, StringUtils.countMatches("one long someone sentence of 
one", ' '));
    assertEquals(6, StringUtils.countMatches("one long someone sentence of 
one", 'o'));
    assertEquals(4, StringUtils.countMatches("oooooooooooo", "ooo")); // <-- 
incorrect overload
} {code}
The last assertion invokes:

 
{code:java}

StringUtils.countMatches(CharSequence str, CharSequence sub) {code}
even though the test method is intended to verify the {{{}char{}}}-based 
overload:
{code:java}

StringUtils.countMatches(CharSequence str, char ch)
 {code}
This assertion should :
 * Be rewritten to use the char version if it is intended to stay within this 
test.
This is my *[Github PR|https://github.com/apache/commons-lang/pull/1511]*  
Looking forward to being merged. [~ggregory] 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to