[
https://issues.apache.org/jira/browse/LANG-1304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15786816#comment-15786816
]
ASF GitHub Bot commented on LANG-1304:
--------------------------------------
Github user andyklimczak commented on a diff in the pull request:
https://github.com/apache/commons-lang/pull/223#discussion_r94201194
--- Diff: src/test/java/org/apache/commons/lang3/StringUtilsTest.java ---
@@ -2563,6 +2563,24 @@ public void testIsAllUpperCase() {
assertFalse(StringUtils.isAllUpperCase("A/C"));
}
+ /**
+ * Test for {@link StringUtils#isMixedCase(CharSequence)}.
+ */
+ @Test
+ public void testIsMixedCase() {
+ assertFalse(StringUtils.isMixedCase(null));
+ assertFalse(StringUtils.isMixedCase(StringUtils.EMPTY));
+ assertFalse(StringUtils.isMixedCase(" "));
+ assertTrue(StringUtils.isMixedCase("aBc"));
+ assertFalse(StringUtils.isMixedCase("abc"));
+ assertFalse(StringUtils.isMixedCase("ABC"));
+ assertFalse(StringUtils.isMixedCase("aBc "));
+ assertFalse(StringUtils.isMixedCase("A c"));
+ assertFalse(StringUtils.isMixedCase("aBc\n"));
+ assertFalse(StringUtils.isMixedCase("A1c"));
+ assertFalse(StringUtils.isMixedCase("a/C"));
--- End diff --
Done, and I added a quick return case to skip going into the loop
unnecessarily because a char sequence of length 1 cannot have both an upper and
lowercase.
> Add a method in StringUtils to check for mixed case in string
> -------------------------------------------------------------
>
> Key: LANG-1304
> URL: https://issues.apache.org/jira/browse/LANG-1304
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Reporter: Arshad Basha
> Priority: Minor
> Fix For: 3.6
>
>
> It would be nice to have a method that check whether the string has mixed
> (lower and upper) case.
> Examples:
> StringUtils.isMixedCase("passWORD"); //true
> StringUtils.isMixedCase("PASSWORD"); //false
> StringUtils.isMixedCase("password"); //false
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)