Fixed #10. Added support for isUpperCase function

This commit is contained in:
Shekhar Gulati
2016-05-20 19:55:28 +05:30
parent c9f0b125d5
commit 6986e34fd3
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 uppercase
*
* @param value The input String
* @return true if String is uppercase false otherwise
*/
public static boolean isUpperCase(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Objects.equals(value, value.toUpperCase());
}
/**
* Verifies if String is lower case
*
+13
View File
@@ -409,4 +409,17 @@ public class StrmanTest {
assertThat(isLowerCase("Foo"), equalTo(false));
assertThat(isLowerCase("foobarfooA"), equalTo(false));
}
@Test
public void isUpperCase_shouldBeTrueWhenStringIsUpperCase() throws Exception {
assertThat(isUpperCase(""), equalTo(true));
assertThat(isUpperCase("FOO"), equalTo(true));
assertThat(isUpperCase("FOOBARFOO"), equalTo(true));
}
@Test
public void isUpperCase_shouldBeFalseWhenStringIsNotUpperCase() throws Exception {
assertThat(isUpperCase("Foo"), equalTo(false));
assertThat(isUpperCase("foobarfooA"), equalTo(false));
}
}