You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2010/09/29 13:28:12 UTC
svn commit: r1002582 - in /commons/proper/io/trunk/src:
java/org/apache/commons/io/FilenameUtils.java
test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
Author: niallp
Date: Wed Sep 29 11:28:11 2010
New Revision: 1002582
URL: http://svn.apache.org/viewvc?rev=1002582&view=rev
Log:
IO-246 FilenameUtils - wildcardMatch gives incorrect results - thanks to wa
Modified:
commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java
commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java?rev=1002582&r1=1002581&r2=1002582&view=diff
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java (original)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java Wed Sep 29 11:28:11 2010
@@ -1264,6 +1264,9 @@ public class FilenameUtils {
if (wcs[wcsIdx].equals("?")) {
// ? so move to next text char
textIdx++;
+ if (textIdx > filename.length()) {
+ break;
+ }
anyChars = false;
} else if (wcs[wcsIdx].equals("*")) {
Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java?rev=1002582&r1=1002581&r2=1002582&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java Wed Sep 29 11:28:11 2010
@@ -182,6 +182,30 @@ public class FilenameUtilsWildcardTestCa
assertMatch("log.log.abc.log.abc.d", "*log?abc?d", true);
}
+ /**
+ * See https://issues.apache.org/jira/browse/IO-246
+ */
+ public void test_IO_246() {
+
+ // Tests for "*?"
+ assertMatch("aaa", "*?", false);
+
+ // Tests for "?*"
+ assertMatch("", "?*", false);
+ assertMatch("a", "a?*", false);
+ assertMatch("aa", "aa?*", false);
+ assertMatch("a", "?*", true);
+ assertMatch("aa", "?*", true);
+ assertMatch("aaa", "?*", true);
+
+ // Test ending on "?"
+ assertMatch("", "?", false);
+ assertMatch("a", "a?", false);
+ assertMatch("aa", "aa?", false);
+ assertMatch("aab", "aa?", true);
+ assertMatch("aaa", "*a", true);
+ }
+
public void testLocaleIndependence() {
Locale orig = Locale.getDefault();
Re: svn commit: r1002582 - in /commons/proper/io/trunk/src:
java/org/apache/commons/io/FilenameUtils.java test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
Posted by sebb <se...@gmail.com>.
On 29 September 2010 18:31, Niall Pemberton <ni...@gmail.com> wrote:
> On Wed, Sep 29, 2010 at 5:39 PM, sebb <se...@gmail.com> wrote:
>> On 29 September 2010 12:28, <ni...@apache.org> wrote:
>>> Author: niallp
>>> Date: Wed Sep 29 11:28:11 2010
>>> New Revision: 1002582
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1002582&view=rev
>>> Log:
>>> IO-246 FilenameUtils - wildcardMatch gives incorrect results - thanks to wa
>>>
>>> Modified:
>>> commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java
>>> commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
>> ...
>>
>>> --- commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java (original)
>>> +++ commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java Wed Sep 29 11:28:11 2010
>>> @@ -182,6 +182,30 @@ public class FilenameUtilsWildcardTestCa
>>> assertMatch("log.log.abc.log.abc.d", "*log?abc?d", true);
>>> }
>>>
>>> + /**
>>> + * See https://issues.apache.org/jira/browse/IO-246
>>> + */
>>> + public void test_IO_246() {
>>> +
>>> + // Tests for "*?"
>>> + assertMatch("aaa", "*?", false);
>>
>> Why assert that this fails?
>
> I wrote the test to investigate the bug - its clearly documented as that.
Tests are normally intended to show that a bug has been fixed.
However this assertion requires that the bug exists - I cannot see the
point of that.
>> Unless "*?" is documented as being disallowed, I don't think it should
>> be specifically disallowed by the test.
>>
>> After all, "?" can follow "*" e.g. "*.?"
>>
>> I think we should just document that "*?" does not currently work.
>
> If you want to do it then go ahead.
Will do.
> Niall
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1002582 - in /commons/proper/io/trunk/src:
java/org/apache/commons/io/FilenameUtils.java test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
Posted by Niall Pemberton <ni...@gmail.com>.
On Wed, Sep 29, 2010 at 5:39 PM, sebb <se...@gmail.com> wrote:
> On 29 September 2010 12:28, <ni...@apache.org> wrote:
>> Author: niallp
>> Date: Wed Sep 29 11:28:11 2010
>> New Revision: 1002582
>>
>> URL: http://svn.apache.org/viewvc?rev=1002582&view=rev
>> Log:
>> IO-246 FilenameUtils - wildcardMatch gives incorrect results - thanks to wa
>>
>> Modified:
>> commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java
>> commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
> ...
>
>> --- commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java (original)
>> +++ commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java Wed Sep 29 11:28:11 2010
>> @@ -182,6 +182,30 @@ public class FilenameUtilsWildcardTestCa
>> assertMatch("log.log.abc.log.abc.d", "*log?abc?d", true);
>> }
>>
>> + /**
>> + * See https://issues.apache.org/jira/browse/IO-246
>> + */
>> + public void test_IO_246() {
>> +
>> + // Tests for "*?"
>> + assertMatch("aaa", "*?", false);
>
> Why assert that this fails?
I wrote the test to investigate the bug - its clearly documented as that.
> Unless "*?" is documented as being disallowed, I don't think it should
> be specifically disallowed by the test.
>
> After all, "?" can follow "*" e.g. "*.?"
>
> I think we should just document that "*?" does not currently work.
If you want to do it then go ahead.
Niall
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1002582 - in /commons/proper/io/trunk/src:
java/org/apache/commons/io/FilenameUtils.java test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
Posted by sebb <se...@gmail.com>.
On 29 September 2010 12:28, <ni...@apache.org> wrote:
> Author: niallp
> Date: Wed Sep 29 11:28:11 2010
> New Revision: 1002582
>
> URL: http://svn.apache.org/viewvc?rev=1002582&view=rev
> Log:
> IO-246 FilenameUtils - wildcardMatch gives incorrect results - thanks to wa
>
> Modified:
> commons/proper/io/trunk/src/java/org/apache/commons/io/FilenameUtils.java
> commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
...
> --- commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java (original)
> +++ commons/proper/io/trunk/src/test/org/apache/commons/io/FilenameUtilsWildcardTestCase.java Wed Sep 29 11:28:11 2010
> @@ -182,6 +182,30 @@ public class FilenameUtilsWildcardTestCa
> assertMatch("log.log.abc.log.abc.d", "*log?abc?d", true);
> }
>
> + /**
> + * See https://issues.apache.org/jira/browse/IO-246
> + */
> + public void test_IO_246() {
> +
> + // Tests for "*?"
> + assertMatch("aaa", "*?", false);
Why assert that this fails?
Unless "*?" is documented as being disallowed, I don't think it should
be specifically disallowed by the test.
After all, "?" can follow "*" e.g. "*.?"
I think we should just document that "*?" does not currently work.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org