3
3
Fork 1
mirror of https://github.com/recloudstream/cloudstream.git synced 2024-08-15 01:53:11 +00:00

Rewrite test in the test folder

This commit is contained in:
EdgarPi 2024-07-25 10:52:01 +02:00
parent 8f9b3e29ae
commit f06192c57a
2 changed files with 19 additions and 1 deletions
app/src
main/java/com/lagradost/cloudstream3/ui/settings/extensions
test/java/com/lagradost/cloudstream3

View file

@ -5,6 +5,7 @@ import android.text.format.Formatter.formatShortFileSize
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone
import androidx.core.view.isVisible
@ -95,7 +96,8 @@ class PluginAdapter(
}
companion object {
private tailrec fun findClosestBase2(target: Int, current: Int = 16, max: Int = 512): Int {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
tailrec fun findClosestBase2(target: Int, current: Int = 16, max: Int = 512): Int {
if (current >= max) return max
if (current >= target) return current
return findClosestBase2(target, current * 2, max)

View file

@ -0,0 +1,16 @@
package com.lagradost.cloudstream3
import com.lagradost.cloudstream3.ui.settings.extensions.PluginAdapter.Companion.findClosestBase2
import org.junit.Assert
import org.junit.Test
class PluginAdapterTest {
@Test
fun testFindClosestBase2() {
Assert.assertEquals(16, findClosestBase2(0))
Assert.assertEquals(256, findClosestBase2(170))
Assert.assertEquals(256, findClosestBase2(256))
Assert.assertEquals(512, findClosestBase2(257))
Assert.assertEquals(512, findClosestBase2(700))
}
}