Skip to content

Commit

Permalink
Fix prerelease test function
Browse files Browse the repository at this point in the history
  • Loading branch information
fire-light42 authored Jul 28, 2024
1 parent 04dda00 commit 82f8ab4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import java.text.DecimalFormat
import kotlin.math.floor
import kotlin.math.log10
import kotlin.math.pow

import org.junit.Test
import org.junit.Assert

data class PluginViewData(
val plugin: Plugin,
Expand Down Expand Up @@ -96,13 +97,23 @@ class PluginAdapter(
}

companion object {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
tailrec fun findClosestBase2(target: Int, current: Int = 16, max: Int = 512): Int {
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)
}

// DO NOT MOVE, as running this test will result in ExceptionInInitializerError on prerelease due to static variables using Resources.getSystem()
// this test function is only to show how the function works
@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))
}

private val iconSizeExact = 32.toPx
private val iconSize by lazy {
findClosestBase2(iconSizeExact, 16, 512)
Expand Down
16 changes: 0 additions & 16 deletions app/src/test/java/com/lagradost/cloudstream3/PluginAdapterTest.kt

This file was deleted.

0 comments on commit 82f8ab4

Please sign in to comment.