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:
parent
8f9b3e29ae
commit
f06192c57a
2 changed files with 19 additions and 1 deletions
|
@ -5,6 +5,7 @@ import android.text.format.Formatter.formatShortFileSize
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -95,7 +96,8 @@ class PluginAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
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 >= max) return max
|
||||||
if (current >= target) return current
|
if (current >= target) return current
|
||||||
return findClosestBase2(target, current * 2, max)
|
return findClosestBase2(target, current * 2, max)
|
||||||
|
|
|
@ -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))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue