Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Jul 18, 2023
1 parent 537e71a commit 5646ea1
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ import org.junit.Test
import java.util.Locale

class AbbreviationsTest {
@Test fun `capitalizes first letter`() {
val abbr = Abbreviations(mapOf("str" to "straße"), Locale.GERMANY)
assertEquals("Straße", abbr.getExpansion("str", true, true))
}

@Test fun `removes abbreviation dot`() {
val abbr = Abbreviations(mapOf("str" to "straße"), Locale.GERMANY)
assertEquals("Straße", abbr.getExpansion("str.", true, true))
assertEquals("straße", abbr.getExpansion("str.", true, true))
}

@Test fun `ignores case`() {
val abbr = Abbreviations(mapOf("sTr" to "Straße"), Locale.GERMANY)
assertEquals("Straße", abbr.getExpansion("StR", true, true))
val abbr = Abbreviations(mapOf("sTr" to "straße"), Locale.GERMANY)
assertEquals("straße", abbr.getExpansion("StR", true, true))
}

@Test fun `expects own word by default`() {
Expand All @@ -39,31 +34,26 @@ class AbbreviationsTest {
}

@Test fun `concatenable works normally for non-concatenation`() {
val abbr = Abbreviations(mapOf("...str" to "Straat"), Locale.US)
assertEquals("Straat", abbr.getExpansion("str", true, true))
val abbr = Abbreviations(mapOf("...str" to "straat"), Locale.US)
assertEquals("straat", abbr.getExpansion("str", true, true))
}

@Test fun `get expansion of only first word`() {
val abbr = Abbreviations(mapOf("^st" to "Saint"), Locale.US)
val abbr = Abbreviations(mapOf("^st" to "saint"), Locale.US)
assertNull(abbr.getExpansion("st.", false, false))
assertEquals("Saint", abbr.getExpansion("st.", true, false))
assertEquals("saint", abbr.getExpansion("st.", true, false))
}

@Test fun `get expansion of only last word`() {
val abbr = Abbreviations(mapOf("str$" to "Straße"), Locale.US)
val abbr = Abbreviations(mapOf("str$" to "straße"), Locale.US)
assertNull(abbr.getExpansion("str", true, false))
assertNull(abbr.getExpansion("str", true, true))
assertEquals("Straße", abbr.getExpansion("str", false, true))
assertEquals("straße", abbr.getExpansion("str", false, true))
}

@Test fun `uses unicode`() {
val abbr = Abbreviations(mapOf("бл" to "Блок"), Locale("ru", "RU"))
assertEquals("Блок", abbr.getExpansion("бл", true, true))
}

@Test fun `locale dependent case`() {
val abbr = Abbreviations(mapOf("бл" to "блок"), Locale("ru", "RU"))
assertEquals("Блок", abbr.getExpansion("Бл", true, true))
assertEquals("блок", abbr.getExpansion("бл", true, true))
}

@Test fun `finds abbreviation`() {
Expand Down

0 comments on commit 5646ea1

Please sign in to comment.