mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-07 15:44:25 +02:00
test: refactor & add more tests
This commit is contained in:
parent
4e2e772389
commit
67a5237541
@ -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 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
|
@Test
|
||||||
fun patchOptionsUsage() {
|
fun `should not throw an exception`() {
|
||||||
val options = ExampleBytecodePatch().options
|
|
||||||
for (option in options) {
|
for (option in options) {
|
||||||
when (option) {
|
when (option) {
|
||||||
is PatchOption.StringOption -> {
|
is PatchOption.StringOption -> {
|
||||||
@ -34,4 +35,25 @@ internal class PatchOptionsUsage {
|
|||||||
options["key1"] = "Hello, world!"
|
options["key1"] = "Hello, world!"
|
||||||
println(options["key1"].value)
|
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…
x
Reference in New Issue
Block a user