From 67a5237541a9b036d2d1c23a3fbd88b4b4eaf945 Mon Sep 17 00:00:00 2001 From: Sculas Date: Tue, 2 Aug 2022 22:00:32 +0200 Subject: [PATCH] test: refactor & add more tests --- .../PatchOptionsTest.kt} | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) rename src/test/kotlin/app/revanced/patcher/{usage/PatchOptionsUsage.kt => patch/PatchOptionsTest.kt} (55%) diff --git a/src/test/kotlin/app/revanced/patcher/usage/PatchOptionsUsage.kt b/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt similarity index 55% rename from src/test/kotlin/app/revanced/patcher/usage/PatchOptionsUsage.kt rename to src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt index 6c213c2..3e9656a 100644 --- a/src/test/kotlin/app/revanced/patcher/usage/PatchOptionsUsage.kt +++ b/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt @@ -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 { + options["this option does not exist"] = 123 + } + } + + @Test + fun `should fail because of invalid value type`() { + assertThrows { + options["key1"] = 123 + } + } + + @Test + fun `should fail because of an illegal value`() { + assertThrows { + options["key3"] = "this value is not an allowed option" + } + } } \ No newline at end of file