Increase unit test coverage to like 0.000001%
This commit is contained in:
parent
ee89f60e9c
commit
fc74050c99
@ -43,4 +43,6 @@ dependencies {
|
|||||||
implementation(libs.bundles.androidx.lifecycle)
|
implementation(libs.bundles.androidx.lifecycle)
|
||||||
implementation(libs.commons.text)
|
implementation(libs.commons.text)
|
||||||
|
|
||||||
|
testImplementation(libs.bundles.tests)
|
||||||
|
|
||||||
}
|
}
|
||||||
52
ktx/src/test/java/de/mm20/launcher2/ktx/StringKtTest.kt
Normal file
52
ktx/src/test/java/de/mm20/launcher2/ktx/StringKtTest.kt
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package de.mm20.launcher2.ktx
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
|
||||||
|
internal class StringKtTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun stringNormalizer_diacritics() {
|
||||||
|
Assert.assertEquals("a b c d e f g h i j", "À b ç d Ę F Ğ h ï j".normalize())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun stringNormalizer_ligatures() {
|
||||||
|
Assert.assertEquals("aeoessss", "ÆŒßẞ".normalize())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun stringNormalizer_search() {
|
||||||
|
val pairs = listOf(
|
||||||
|
"文件" to "jian",
|
||||||
|
"文件" to "jiàn",
|
||||||
|
"文件" to "文",
|
||||||
|
"génération" to "Generation",
|
||||||
|
"Kvæsitso" to "kvaes",
|
||||||
|
"Übersetzer" to "uberset",
|
||||||
|
)
|
||||||
|
for ((str, q) in pairs) {
|
||||||
|
Assert.assertTrue(str.normalize().contains(q.normalize()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that A.contains(B) -> A.normalize().contains(B.normalize())
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun stringNormalize_substring_implication() {
|
||||||
|
val pairs = listOf(
|
||||||
|
"文件" to "文",
|
||||||
|
"génération" to "énér",
|
||||||
|
"Kvæsitso" to "æ",
|
||||||
|
"Übersetzer" to "übe",
|
||||||
|
)
|
||||||
|
for ((str, q) in pairs) {
|
||||||
|
Assert.assertTrue(
|
||||||
|
if (str.contains(q)) str.normalize().contains(q.normalize())
|
||||||
|
else true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -280,6 +280,10 @@ dependencyResolutionManagement {
|
|||||||
|
|
||||||
library("lottie", "com.airbnb.android", "lottie-compose")
|
library("lottie", "com.airbnb.android", "lottie-compose")
|
||||||
.version("5.2.0")
|
.version("5.2.0")
|
||||||
|
|
||||||
|
version("junit", "4.13")
|
||||||
|
library("junit", "junit", "junit").versionRef("junit")
|
||||||
|
bundle("tests", listOf("junit"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user