mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
test: refactor & add more tests
This commit is contained in:
parent
4e2e772389
commit
67a5237541
1 changed files with 28 additions and 6 deletions
|
@ -1,13 +1,14 @@
|
|||
package app.revanced.patcher.usage
|
||||
package app.revanced.patcher.patch
|
||||
|
||||
import app.revanced.patcher.patch.PatchOption
|
||||
import app.revanced.patcher.usage.bytecode.ExampleBytecodePatch
|
||||
import kotlin.test.Test
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
|
||||
internal class PatchOptionsTest {
|
||||
private val options = ExampleBytecodePatch().options
|
||||
|
||||
internal class PatchOptionsUsage {
|
||||
@Test
|
||||
fun patchOptionsUsage() {
|
||||
val options = ExampleBytecodePatch().options
|
||||
fun `should not throw an exception`() {
|
||||
for (option in options) {
|
||||
when (option) {
|
||||
is PatchOption.StringOption -> {
|
||||
|
@ -34,4 +35,25 @@ internal class PatchOptionsUsage {
|
|||
options["key1"] = "Hello, world!"
|
||||
println(options["key1"].value)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should fail because the option does not exist`() {
|
||||
assertThrows<NoSuchOptionException> {
|
||||
options["this option does not exist"] = 123
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should fail because of invalid value type`() {
|
||||
assertThrows<IllegalArgumentException> {
|
||||
options["key1"] = 123
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should fail because of an illegal value`() {
|
||||
assertThrows<IllegalArgumentException> {
|
||||
options["key3"] = "this value is not an allowed option"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue