Fixed #8. Added support for isLowerCase function

This commit is contained in:
Shekhar Gulati
2016-05-20 19:52:55 +05:30
parent c77d86a68a
commit c9f0b125d5
2 changed files with 24 additions and 0 deletions
+11
View File
@@ -493,6 +493,17 @@ public abstract class Strman {
return append(value.substring(0, index), substr, value.substring(index));
}
/**
* Verifies if String is lower case
*
* @param value The input String
* @return true if String is lowercase false otherwise
*/
public static boolean isLowerCase(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Objects.equals(value, value.toLowerCase());
}
public static String leftPad(final String value, final String pad, final int length) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (value.length() >= length) {
+13
View File
@@ -396,4 +396,17 @@ public class StrmanTest {
assertThat(insert("foobar", "x", 6), equalTo("foobarx"));
assertThat(insert("foo bar", "asadasd", 100), equalTo("foo bar"));
}
@Test
public void isLowerCase_shouldBeTrueWhenStringIsLowerCase() throws Exception {
assertThat(isLowerCase(""), equalTo(true));
assertThat(isLowerCase("foo"), equalTo(true));
assertThat(isLowerCase("foobarfoo"), equalTo(true));
}
@Test
public void isLowerCase_shouldBeFalseWhenStringIsNotLowerCase() throws Exception {
assertThat(isLowerCase("Foo"), equalTo(false));
assertThat(isLowerCase("foobarfooA"), equalTo(false));
}
}