|
| 1 | +/* |
| 2 | + * Hello Minecraft! Launcher |
| 3 | + * Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | +package org.jackhuang.hmcl.upgrade; |
| 19 | + |
| 20 | +import org.jetbrains.annotations.NotNullByDefault; |
| 21 | +import org.jetbrains.annotations.Nullable; |
| 22 | +import org.junit.jupiter.params.ParameterizedTest; |
| 23 | +import org.junit.jupiter.params.provider.NullSource; |
| 24 | +import org.junit.jupiter.params.provider.ValueSource; |
| 25 | + |
| 26 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 27 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 28 | + |
| 29 | +/// Tests parsing of package-manager marker values. |
| 30 | +@NotNullByDefault |
| 31 | +public final class PackageManagerIntegrationTest { |
| 32 | + /// Verifies that conventional disabled marker values are not enabled. |
| 33 | + @ParameterizedTest |
| 34 | + @NullSource |
| 35 | + @ValueSource(strings = {"", " ", "0", "false", "FALSE", "no", "NO", "off", "OFF"}) |
| 36 | + public void shouldRejectDisabledMarkers(@Nullable String value) { |
| 37 | + assertFalse(PackageManagerIntegration.isEnabled(value)); |
| 38 | + } |
| 39 | + |
| 40 | + /// Verifies that package type markers and conventional enabled values remain enabled. |
| 41 | + @ParameterizedTest |
| 42 | + @ValueSource(strings = {"1", "true", "deb", "rpm"}) |
| 43 | + public void shouldAcceptEnabledMarkers(String value) { |
| 44 | + assertTrue(PackageManagerIntegration.isEnabled(value)); |
| 45 | + } |
| 46 | +} |
0 commit comments