mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 07:37:12 +01:00
Faster Expandable Text calculator.
This commit is contained in:
@@ -24,6 +24,7 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.amethyst.commons.ExpandableTextParser
|
||||
import com.vitorpamplona.amethyst.commons.nthIndexOf
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -38,18 +39,38 @@ class ExpandableViewComputationBenchmark {
|
||||
fun computeTestCase1() {
|
||||
benchmarkRule.measureRepeated {
|
||||
TestCase.assertEquals(
|
||||
294,
|
||||
ExpandableTextParser().computeWhereToCutIfPostIsTooLong(testCase1),
|
||||
293,
|
||||
testCase1.nthIndexOf('\n', 10),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun computeTestCase2() {
|
||||
benchmarkRule.measureRepeated {
|
||||
TestCase.assertEquals(
|
||||
423,
|
||||
testCase2.nthIndexOf('\n', 10),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun computeTestCase1All() {
|
||||
benchmarkRule.measureRepeated {
|
||||
TestCase.assertEquals(
|
||||
293,
|
||||
ExpandableTextParser.computeWhereToCutIfPostIsTooLong(testCase1),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun computeTestCase2All() {
|
||||
benchmarkRule.measureRepeated {
|
||||
TestCase.assertEquals(
|
||||
355,
|
||||
ExpandableTextParser().computeWhereToCutIfPostIsTooLong(testCase2),
|
||||
ExpandableTextParser.computeWhereToCutIfPostIsTooLong(testCase2),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user