BugFix for short lists

This commit is contained in:
Vitor Pamplona
2024-02-05 20:26:37 -05:00
parent 248bdffd50
commit 3298fd4493
2 changed files with 16 additions and 0 deletions

View File

@@ -75,6 +75,16 @@ class ExpandableViewComputationBenchmark {
}
}
@Test
fun computeTestCase3All() {
benchmarkRule.measureRepeated {
TestCase.assertEquals(
65,
ExpandableTextParser.computeWhereToCutIfPostIsTooLong(testCase3),
)
}
}
val testCase1 = """
#Amethyst v0.83.10
@@ -137,4 +147,9 @@ Download:
- [Play Edition](https://github.com/vitorpamplona/amethyst/releases/download/v0.83.10/amethyst-googleplay-universal-v0.83.10.apk )
- [FOSS Edition - No translations](https://github.com/vitorpamplona/amethyst/releases/download/v0.83.10/amethyst-fdroid-universal-v0.83.10.apk )
"""
val testCase3 = """#100aDayUntil100k
Day 5 ✔️
Seems like they may be getting easier"""
}

View File

@@ -49,6 +49,7 @@ fun String.nthIndexOf(
while (occur > 0) {
// calling the native function multiple times is faster than looping just once
pos = indexOf(ch, pos + 1)
if (pos == -1) return -1
occur--
}