BAEL-5227 check if a first letter of a string is uppercase (#11424)

* BAEL-5227 check if the first letter of a string is uppercase

* BAEL-5227 renaming the tests

* BAEL-5227 renaming the tests

* BAEL-5227 renaming the tests

Co-authored-by: Matea Pejčinović <matea.pejcinovic@intellexi.hr>
This commit is contained in:
Teica 2021-11-07 22:19:54 +01:00 committed by GitHub
parent d8ba53a958
commit f200ce5b14

View File

@ -0,0 +1,32 @@
package com.baeldung.isuppercase;
import com.google.common.base.Ascii;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class StringFirstCharacterUppercase {
@Test
public void givenString_whenCheckingWithCharacterIsUpperCase_thenStringCapitalized() {
String example = "Katie";
Assertions.assertTrue(Character.isUpperCase(example.charAt(0)));
}
@Test
public void givenString_whenCheckingWithRegex_thenStringCapitalized() {
String example = "Katie";
String regEx = "[A-Z]\\w*";
assertThat(example, matchesPattern(regEx));
}
@Test
public void givenString_whenCheckingWithGuava_thenStringCapitalized() {
String example = "Katie";
Assertions.assertTrue(Ascii.isUpperCase(example.charAt(0)));
}
}