[ 
https://issues.apache.org/jira/browse/LANG-1798?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042507#comment-18042507
 ] 

Gary D. Gregory commented on LANG-1798:
---------------------------------------

[~zhongxin]
-1 to the PR: The overload is still wrong!
{code:java}
assertEquals(12, StringUtils.countMatches("oooooooooooo", "o"));
{code}
It's still calling the {{(String,String)}} API instead of {{(String,char)}}
I addressed this differently in git master.


> Fix StringUtilsSubstringTest.testCountMatches_char() to call the correct 
> method
> -------------------------------------------------------------------------------
>
>                 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
>            Priority: Major
>             Fix For: 3.20.1
>
>
> 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