mirror of https://github.com/usbharu/Hideout.git
feat: emoji-ktを追加
This commit is contained in:
parent
855055d49a
commit
a015566e52
|
@ -142,6 +142,15 @@ repositories {
|
|||
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "GitHubPackages2"
|
||||
url = uri("https://maven.pkg.github.com/multim-dev/emoji-kt")
|
||||
credentials {
|
||||
|
||||
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
|
||||
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
@ -205,6 +214,8 @@ dependencies {
|
|||
implementation("org.bytedeco:javacv-platform:1.5.9")
|
||||
implementation("org.flywaydb:flyway-core")
|
||||
|
||||
implementation("dev.usbharu:emoji-kt:2.0.0")
|
||||
|
||||
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
|
||||
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package dev.usbharu.hideout.util
|
||||
|
||||
import Emojis
|
||||
|
||||
object EmojiUtil {
|
||||
|
||||
|
||||
val emojiMap by lazy {
|
||||
Emojis.allEmojis
|
||||
.associate { it.code.replace(" ", "-") to it.char }
|
||||
.filterValues { it != "™" }
|
||||
|
||||
}
|
||||
|
||||
fun isEmoji(string: String): Boolean {
|
||||
return emojiMap.any { it.value == string }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package dev.usbharu.hideout.util
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.ValueSource
|
||||
|
||||
class EmojiUtilTest {
|
||||
|
||||
@Test
|
||||
fun 絵文字を判定できる() {
|
||||
val emoji = "❤"
|
||||
val actual = EmojiUtil.isEmoji(emoji)
|
||||
|
||||
assertThat(actual).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ただの文字を判定できる() {
|
||||
val moji = "blobblinkhyper"
|
||||
val actual = EmojiUtil.isEmoji(moji)
|
||||
|
||||
assertThat(actual).isFalse()
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = ["❤", "🌄", "🤗", "⛺", "🧑🤝🧑", "🖐🏿"])
|
||||
fun `絵文字判定`(s: String) {
|
||||
val actual = EmojiUtil.isEmoji(s)
|
||||
|
||||
assertThat(actual).isTrue()
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = ["™", "㍂", "㌠"])
|
||||
fun `文字判定`(s: String) {
|
||||
val actual = EmojiUtil.isEmoji(s)
|
||||
|
||||
assertThat(actual).isFalse()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue