mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 06:09:09 +00:00
add test related to GH-1408
This commit is contained in:
parent
1b1dbd4006
commit
b26ba76221
1 changed files with 19 additions and 0 deletions
|
@ -1,12 +1,23 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
package helium314.keyboard.latin
|
package helium314.keyboard.latin
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import helium314.keyboard.ShadowInputMethodManager2
|
||||||
import helium314.keyboard.latin.common.StringUtils
|
import helium314.keyboard.latin.common.StringUtils
|
||||||
import helium314.keyboard.latin.common.getFullEmojiAtEnd
|
import helium314.keyboard.latin.common.getFullEmojiAtEnd
|
||||||
|
import helium314.keyboard.latin.common.nonWordCodePointAndNoSpaceBeforeCursor
|
||||||
|
import helium314.keyboard.latin.settings.SpacingAndPunctuations
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
// todo: actually this test could/should be significantly expanded...
|
// todo: actually this test could/should be significantly expanded...
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(shadows = [
|
||||||
|
ShadowInputMethodManager2::class,
|
||||||
|
])
|
||||||
class StringUtilsTest {
|
class StringUtilsTest {
|
||||||
@Test fun `not inside double quotes without quotes`() {
|
@Test fun `not inside double quotes without quotes`() {
|
||||||
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello yes"))
|
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello yes"))
|
||||||
|
@ -41,6 +52,14 @@ class StringUtilsTest {
|
||||||
assert(StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\", \"h"))
|
assert(StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\", \"h"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun `non-word codepoints and no space`() {
|
||||||
|
val sp = SpacingAndPunctuations(ApplicationProvider.getApplicationContext<App>().resources, false)
|
||||||
|
assert(!nonWordCodePointAndNoSpaceBeforeCursor("this is", sp))
|
||||||
|
assert(!nonWordCodePointAndNoSpaceBeforeCursor("this ", sp))
|
||||||
|
assert(!nonWordCodePointAndNoSpaceBeforeCursor("th.is ", sp))
|
||||||
|
assert(nonWordCodePointAndNoSpaceBeforeCursor("th.is", sp))
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun detectEmojisAtEnd() {
|
@Test fun detectEmojisAtEnd() {
|
||||||
assertEquals("", getFullEmojiAtEnd("\uD83C\uDF83 "))
|
assertEquals("", getFullEmojiAtEnd("\uD83C\uDF83 "))
|
||||||
assertEquals("", getFullEmojiAtEnd("a"))
|
assertEquals("", getFullEmojiAtEnd("a"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue