commit
c54f2d6102
|
@ -0,0 +1,6 @@
|
||||||
|
## Core Java Character
|
||||||
|
|
||||||
|
This module contains articles about Java Character Class
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- Character#isAlphabetic vs Character#isLetter
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>core-java-char</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
<name>core-java-char</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${openjdk.jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${openjdk.jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
||||||
|
<assertj.version>3.11.1</assertj.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.baeldung.character;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class CharacterGeneralCategoryTypeUnitTest {
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenUpperCaseLetter_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('U') == Character.UPPERCASE_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenLowerCaseLetter_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('u') == Character.LOWERCASE_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenTitleCaseLetter_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('\u01f2') == Character.TITLECASE_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenModifierLetter_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('\u02b0') == Character.MODIFIER_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenOtherLetter_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('\u05d0') == Character.OTHER_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenLetterNumber_thenAssertTrue() {
|
||||||
|
assertTrue(Character.getType('\u2164') == Character.LETTER_NUMBER);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.baeldung.character;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
|
public class IsLetterOrAlphabetUnitTest {
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenLetter_thenAssertIsLetterTrue() {
|
||||||
|
assertTrue(Character.isLetter('a'));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenLetter_thenAssertIsAlphabeticTrue() {
|
||||||
|
assertTrue(Character.isAlphabetic('a'));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenAlphabeticAndNotLetter_thenAssertIsLetterFalse() {
|
||||||
|
assertFalse(Character.isLetter('\u2164'));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenACharacter_whenAlphabeticAndNotLetter_thenAssertIsAlphabeticTrue() {
|
||||||
|
assertTrue(Character.isAlphabetic('\u2164'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,8 @@
|
||||||
<module>core-java-arrays-convert</module>
|
<module>core-java-arrays-convert</module>
|
||||||
<module>core-java-arrays-operations-basic</module>
|
<module>core-java-arrays-operations-basic</module>
|
||||||
<module>core-java-arrays-operations-advanced</module>
|
<module>core-java-arrays-operations-advanced</module>
|
||||||
|
|
||||||
|
<module>core-java-char</module>
|
||||||
<module>core-java-collections</module>
|
<module>core-java-collections</module>
|
||||||
<module>core-java-collections-2</module>
|
<module>core-java-collections-2</module>
|
||||||
<module>core-java-collections-3</module>
|
<module>core-java-collections-3</module>
|
||||||
|
|
Loading…
Reference in New Issue