From 64343e5a7c934983be7f6628d339a7900f3514ed Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 22 Oct 2023 02:49:44 +0200 Subject: [PATCH] chore: Test resetting options --- .../patcher/patch/options/PatchOptionsTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt b/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt index 5cd6ccc8..1340eff2 100644 --- a/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt +++ b/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt @@ -72,12 +72,25 @@ internal class PatchOptionsTest { @Test fun `should allow resetting value`() = assertDoesNotThrow { OptionsTestPatch.stringOptionWithChoices = null } + @Test + fun `reset should not fail`() { + assertDoesNotThrow { + OptionsTestPatch.resettableOption.value = "test" + OptionsTestPatch.resettableOption.reset() + } + + assertThrows { + OptionsTestPatch.resettableOption.value + } + } + private object OptionsTestPatch : BytecodePatch() { var booleanOption by booleanPatchOption("bool", true) var requiredStringOption by stringPatchOption("required", "default", required = true) var stringArrayOption = stringArrayPatchOption("array", arrayOf("1", "2")) var stringOptionWithChoices by stringPatchOption("choices", "value", values = setOf("valid")) var validatedOption by stringPatchOption("validated", "default") { it == "valid" } + var resettableOption = stringPatchOption("resettable", null, required = true) override fun execute(context: BytecodeContext) {} }