Skip to content

Commit

Permalink
Remove Pattern.UNICODE_CHARACTER_CLASS argument from the emoji pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
felldo committed Oct 28, 2023
1 parent 6c27c38 commit badbc4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ org.gradle.caching=true

group=net.fellbaum
description=A Java library for conveniently working with emojis
version=1.3.1
version=1.3.2
2 changes: 1 addition & 1 deletion lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class EmojiManager {
EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING = emojis.stream().collect(getEmojiLinkedHashMapCollector());

EMOJI_PATTERN = Pattern.compile(EMOJIS_LENGTH_DESCENDING.stream()
.map(s -> "(" + Pattern.quote(s.getEmoji()) + ")").collect(Collectors.joining("|")), Pattern.UNICODE_CHARACTER_CLASS);
.map(s -> "(" + Pattern.quote(s.getEmoji()) + ")").collect(Collectors.joining("|")));
} catch (final JsonProcessingException e) {
throw new RuntimeException(e);
}
Expand Down
12 changes: 12 additions & 0 deletions lib/src/test/java/net/fellbaum/jemoji/EmojiManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class EmojiManagerTest {
Expand Down Expand Up @@ -105,4 +106,15 @@ public void replaceAllEmojisFunction() {
assertEquals("Hello SMILEYS_AND_EMOTION SMILEYS_AND_EMOTION SMILEYS_AND_EMOTIONSMILEYS_AND_EMOTION World PEOPLE_AND_BODY PEOPLE_AND_BODY SMILEYS_AND_EMOTION", EmojiManager.replaceAllEmojis(SIMPLE_EMOJI_STRING + " 👍 👨🏿‍🦱 😊", emoji -> emoji.getGroup().toString()));
}

@Test
public void testEmojiPattern() {
for (Emoji emoji : EmojiManager.getAllEmojis()) {
assertTrue(EmojiManager.getEmojiPattern().matcher(emoji.getEmoji()).matches());
}
assertFalse(EmojiManager.getEmojiPattern().matcher("a").matches());
assertFalse(EmojiManager.getEmojiPattern().matcher("ä").matches());
assertFalse(EmojiManager.getEmojiPattern().matcher("1").matches());
assertFalse(EmojiManager.getEmojiPattern().matcher("/").matches());
}

}

0 comments on commit badbc4e

Please sign in to comment.