Created
June 12, 2015 02:01
-
-
Save marcel-dias/51c1e048d73f67eacd27 to your computer and use it in GitHub Desktop.
IsFirstLetterUpperCaseTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.junit.Assert.assertThat; | |
import static org.hamcrest.CoreMatchers.is; | |
public class IsFirstLetterUpperCaseTest { | |
@Test | |
public void testNullIsFirstLetterUpperCase() { | |
assertThat(Boolean.FALSE, is(isFirstLetterUpperCase(null))); | |
} | |
@Test | |
public void testUpperCaseIsFirstLetterUpperCase() { | |
assertThat(Boolean.TRUE, is(isFirstLetterUpperCase("UpperCase"))); | |
} | |
@Test | |
public void testIsFirstLetterUpperCase() { | |
assertThat(Boolean.FALSE, is(isFirstLetterUpperCase("lowerCase"))); | |
} | |
@Test | |
public void testNumberIsFirstLetterUpperCase() { | |
assertThat(Boolean.FALSE, is(isFirstLetterUpperCase("55"))); | |
} | |
public Boolean isFirstLetterUpperCase(final String text) { | |
Boolean isUpperCase = false; | |
if (text != null && !text.isEmpty()) { | |
isUpperCase = Character.isUpperCase(text.charAt(0)); | |
} | |
return isUpperCase; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment