mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-24 18:10:54 +00:00
add tests for string utils, see #230
This commit is contained in:
parent
9975a7d8f6
commit
9efeb7e339
2 changed files with 57 additions and 0 deletions
|
@ -463,6 +463,8 @@ class InputLogicTest {
|
||||||
assertEquals("b", composingText)
|
assertEquals("b", composingText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/Helium314/openboard/issues/215
|
||||||
|
// https://github.com/Helium314/openboard/issues/229
|
||||||
@Test fun `autospace works in URL field when input isn't URL, also for multiple suggestions`() {
|
@Test fun `autospace works in URL field when input isn't URL, also for multiple suggestions`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
|
@ -508,6 +510,19 @@ class InputLogicTest {
|
||||||
assertEquals("hi ${StringUtils.newSingleCodePointString(0x1F36D)}", text)
|
assertEquals("hi ${StringUtils.newSingleCodePointString(0x1F36D)}", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/Helium314/openboard/issues/230
|
||||||
|
// todo: make it work
|
||||||
|
@Test fun `no autospace after opening quotes`() {
|
||||||
|
reset()
|
||||||
|
chainInput("\"Hi\" \"h")
|
||||||
|
assertEquals("\"Hi\" \"h", text)
|
||||||
|
assertEquals("h", composingText)
|
||||||
|
reset()
|
||||||
|
chainInput("\"Hi\", \"h")
|
||||||
|
assertEquals("\"Hi\", \"h", text)
|
||||||
|
assertEquals("", composingText)
|
||||||
|
}
|
||||||
|
|
||||||
// ------- helper functions ---------
|
// ------- helper functions ---------
|
||||||
|
|
||||||
// should be called before every test, so the same state is guaranteed
|
// should be called before every test, so the same state is guaranteed
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.dslul.openboard.inputmethod.latin
|
||||||
|
|
||||||
|
import org.dslul.openboard.inputmethod.latin.common.StringUtils
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
// todo: actually this test could/should be significantly expanded...
|
||||||
|
class StringUtilsTest {
|
||||||
|
@Test fun `not inside double quotes without quotes`() {
|
||||||
|
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello yes"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun `inside double quotes after opening a quote`() {
|
||||||
|
assert(StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// maybe this is not that bad, should be correct after entering next text
|
||||||
|
@Test fun `not inside double quotes directly after closing quote`() {
|
||||||
|
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\""))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun `not inside double quotes after closing quote0`() {
|
||||||
|
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\" "))
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: fix it!
|
||||||
|
@Test fun `not inside double quotes after closing quote1`() {
|
||||||
|
assert(!StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun `inside double quotes after opening another quote`() {
|
||||||
|
assert(StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\" \"h"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun `inside double quotes after opening another quote2`() {
|
||||||
|
assert(StringUtils.isInsideDoubleQuoteOrAfterDigit("hello \"yes\", \"h"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: add tests for emoji detection?
|
||||||
|
// could help towards fully fixing https://github.com/Helium314/openboard/issues/22
|
||||||
|
// though this might be tricky, as some emojis will show as one on new Android versions, and
|
||||||
|
// as two on older versions
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue