diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-06-15 19:42:01 -0500 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-06-15 19:42:01 -0500 |
commit | 2fdbc084fd1d78f0b7633db34460b1195de264f3 (patch) | |
tree | 4c908950d9b049394f8160b8159b498aec586ecc /src/test/java/sevenUnitsGUI | |
parent | ed53492243ecad8d975401a97f5b634328ad2c71 (diff) | |
parent | bccb5b5e3452421c81c1fb58f83391ba6584807c (diff) |
See the tag 'v1.0.0' or the changelog for more information about this
release.
Diffstat (limited to 'src/test/java/sevenUnitsGUI')
-rw-r--r-- | src/test/java/sevenUnitsGUI/I18nTest.java | 95 | ||||
-rw-r--r-- | src/test/java/sevenUnitsGUI/PrefixRepetitionTest.java | 20 | ||||
-rw-r--r-- | src/test/java/sevenUnitsGUI/PrefixSearchTest.java | 36 | ||||
-rw-r--r-- | src/test/java/sevenUnitsGUI/PresenterTest.java | 159 | ||||
-rw-r--r-- | src/test/java/sevenUnitsGUI/RoundingTest.java | 35 | ||||
-rw-r--r-- | src/test/java/sevenUnitsGUI/TabbedViewTest.java | 22 |
6 files changed, 243 insertions, 124 deletions
diff --git a/src/test/java/sevenUnitsGUI/I18nTest.java b/src/test/java/sevenUnitsGUI/I18nTest.java new file mode 100644 index 0000000..2f90d76 --- /dev/null +++ b/src/test/java/sevenUnitsGUI/I18nTest.java @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2025 Adrien Hopkins + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package sevenUnitsGUI; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +/** + * Tests for the internationalization system. + * + * @since v1.0.0 + */ +class I18nTest { + private static final Stream<String> testLocaleSupported() { + return Stream.of("en", "fr"); + } + + private static final Stream<Arguments> testLocalization() { + return Stream.of(Arguments.of("tv.title", "en", "7Units [v]"), + Arguments.of("tv.title", "fr", "7Unités [v]"), + Arguments.of("tv.convert_units.title", "en", "Convert Units"), + Arguments.of("tv.convert_units.title", "fr", "Convertir Unités")); + } + + /** + * Tests that the default locale is supported. + * + * @since v1.0.0 + * @see Presenter#DEFAULT_LOCALE + */ + @Test + void testDefaultLocaleSupported() { + final var p = new Presenter(new ViewBot()); + assertNotNull(p.locales.get(Presenter.DEFAULT_LOCALE), + "Default locale is not supported."); + } + + /** + * Ensures that the system supports the provided locale. + * + * @param localeName locale to test for support + * + * @since 2025-06-04 + * @since v1.0.0 + */ + @ParameterizedTest + @MethodSource + void testLocaleSupported(String localeName) { + final var p = new Presenter(new ViewBot()); + assertNotNull(p.locales.get(localeName), + "Locale \"" + localeName + "\" is not supported."); + } + + /** + * Tests that the system can correctly localize text, using the default + * locales. + * + * @param key key of text to localize + * @param locale locale to use + * @param expected expected value of output text + * + * @since 2025-06-04 + * @since v1.0.0 + */ + @ParameterizedTest + @MethodSource + void testLocalization(String key, String locale, String expected) { + final var p = new Presenter(new ViewBot()); + p.setUserLocale(locale); + final var actual = p.getLocalizedText(key); + assertEquals(expected, actual); + } + +} diff --git a/src/test/java/sevenUnitsGUI/PrefixRepetitionTest.java b/src/test/java/sevenUnitsGUI/PrefixRepetitionTest.java index 476e407..ead5f4a 100644 --- a/src/test/java/sevenUnitsGUI/PrefixRepetitionTest.java +++ b/src/test/java/sevenUnitsGUI/PrefixRepetitionTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2022 Adrien Hopkins + * Copyright (C) 2022, 2024, 2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -31,15 +31,15 @@ import sevenUnits.unit.Metric; /** * Tests for the default prefix repetition rules. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ class PrefixRepetitionTest { /** * Ensures that the complex repetition rule disallows invalid prefix lists. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testInvalidComplexRepetition() { @@ -57,9 +57,9 @@ class PrefixRepetitionTest { /** * Tests the {@code NO_REPETITION} rule. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testNoRepetition() { @@ -71,9 +71,9 @@ class PrefixRepetitionTest { /** * Tests the {@code NO_RESTRICTION} rule. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testNoRestriction() { @@ -85,9 +85,9 @@ class PrefixRepetitionTest { /** * Ensures that the complex repetition rule allows valid prefix lists. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testValidComplexRepetition() { diff --git a/src/test/java/sevenUnitsGUI/PrefixSearchTest.java b/src/test/java/sevenUnitsGUI/PrefixSearchTest.java index 305d0d7..00dd960 100644 --- a/src/test/java/sevenUnitsGUI/PrefixSearchTest.java +++ b/src/test/java/sevenUnitsGUI/PrefixSearchTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2022 Adrien Hopkins + * Copyright (C) 2022, 2024, 2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -18,6 +18,7 @@ package sevenUnitsGUI; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static sevenUnitsGUI.PrefixSearchRule.COMMON_PREFIXES; import static sevenUnitsGUI.PrefixSearchRule.NO_PREFIXES; import static sevenUnitsGUI.PrefixSearchRule.getCoherentOnlyRule; @@ -35,13 +36,11 @@ import sevenUnits.unit.Metric; /** * Tests for {@link PrefixSearchRule} * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ class PrefixSearchTest { - /** - * A method that creates duplicate copies of the common prefix rule. - */ + /** A method that creates duplicate copies of the common prefix rule. */ private static final PrefixSearchRule getCommonRuleCopy() { return getCoherentOnlyRule(Set.of(Metric.KILO, Metric.MILLI)); } @@ -51,8 +50,8 @@ class PrefixSearchTest { * {@link sevenUnitsGUI.PrefixSearchRule#apply(java.util.Map.Entry)}, for a * coherent unit and {@link PrefixSearchRule#COMMON_PREFIXES}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testCoherentPrefixSearch() { @@ -69,8 +68,8 @@ class PrefixSearchTest { * Test method for * {@link sevenUnitsGUI.PrefixSearchRule#equals(java.lang.Object)}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testEquals() { @@ -84,8 +83,8 @@ class PrefixSearchTest { /** * Test method for {@link sevenUnitsGUI.PrefixSearchRule#getPrefixes()}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testGetPrefixes() { @@ -97,8 +96,8 @@ class PrefixSearchTest { /** * Test method for {@link sevenUnitsGUI.PrefixSearchRule#hashCode()}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testHashCode() { @@ -109,9 +108,9 @@ class PrefixSearchTest { /** * Tests prefix searching for a non-coherent unit and * {@link PrefixSearchRule#COMMON_PREFIXES}. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testNonCoherentPrefixSearch() { @@ -124,9 +123,9 @@ class PrefixSearchTest { /** * Tests that {@link PrefixSearchRule#NO_PREFIXES} returns the original unit. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testNoPrefixes() { @@ -145,14 +144,17 @@ class PrefixSearchTest { /** * Test method for {@link sevenUnitsGUI.PrefixSearchRule#toString()}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test final void testToString() { - assertEquals( - "Apply the following prefixes: [kilo (\u00D7 1000.0), milli (\u00D7 0.001)]", - COMMON_PREFIXES.toString()); + final var toString = COMMON_PREFIXES.toString(); + final var valid1 = "Apply the following prefixes: [kilo (\u00D7 1000.0), milli (\u00D7 0.001)]"; + final var valid2 = "Apply the following prefixes: [milli (\u00D7 0.001), kilo (\u00D7 1000.0)]"; + + assertTrue(valid1.equals(toString) || valid2.equals(toString), + "COMMON_PREFIXES.toString invalid (was \"" + toString + "\")."); } } diff --git a/src/test/java/sevenUnitsGUI/PresenterTest.java b/src/test/java/sevenUnitsGUI/PresenterTest.java index 9e25a08..9ac5b84 100644 --- a/src/test/java/sevenUnitsGUI/PresenterTest.java +++ b/src/test/java/sevenUnitsGUI/PresenterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2022 Adrien Hopkins + * Copyright (C) 2022-2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,13 +17,12 @@ package sevenUnitsGUI; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import java.math.RoundingMode; import java.nio.file.Path; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -32,12 +31,12 @@ import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import sevenUnits.unit.BaseDimension; import sevenUnits.unit.BritishImperial; import sevenUnits.unit.LinearUnit; -import sevenUnits.unit.LinearUnitValue; import sevenUnits.unit.Metric; import sevenUnits.unit.Unit; import sevenUnits.unit.UnitDatabase; @@ -53,11 +52,11 @@ import sevenUnits.utils.UncertainDouble; * <em>Note: this test outputs a lot to the standard output, because creating a * {@link UnitDatabase} and converting with a {@link ViewBot} both trigger * println statements.</em> - * + * * @author Adrien Hopkins * - * @since v0.4.0 * @since 2022-02-10 + * @since v0.4.0 */ public final class PresenterTest { private static final Path TEST_SETTINGS = Path.of("src", "test", "resources", @@ -74,10 +73,10 @@ public final class PresenterTest { /** * @return rounding rules used by {@link #testRoundingRules} - * @since v0.4.0 * @since 2022-04-16 + * @since v0.4.0 */ - private static final Stream<Function<UncertainDouble, String>> getRoundingRules() { + private static Stream<Function<UncertainDouble, String>> getRoundingRules() { final var SCIENTIFIC_ROUNDING = StandardDisplayRules.uncertaintyBased(); final var INTEGER_ROUNDING = StandardDisplayRules.fixedDecimals(0); final var SIG_FIG_ROUNDING = StandardDisplayRules.fixedPrecision(4); @@ -85,81 +84,99 @@ public final class PresenterTest { return Stream.of(SCIENTIFIC_ROUNDING, INTEGER_ROUNDING, SIG_FIG_ROUNDING); } - private static final Stream<Function<Map.Entry<String, LinearUnit>, Map<String, LinearUnit>>> getSearchRules() { + private static Stream<Function<Map.Entry<String, LinearUnit>, Map<String, LinearUnit>>> getSearchRules() { return SEARCH_RULES; } - private static final Set<String> names(Set<? extends Nameable> units) { + private static Set<String> names(Set<? extends Nameable> units) { return units.stream().map(Nameable::getName).collect(Collectors.toSet()); } + private static Stream<Arguments> testConvertExpressions() { + return Stream.of( + Arguments.of("10000.0 m", "km", "10000.0 m = 10.00000 km"), + Arguments.of("1.0 m", "ft; in", "1.0 m = 3 ft + 3 in"), + Arguments.of("1.0 m", "ftin", "1.0 m = 3 ft + 3 in")); + } + + private static Stream<Arguments> testConvertUnits() { + return Stream.of( + Arguments.of("m", "km", 10000.0, "10000.0 m = 10.00000 km"), + Arguments.of("m", "ftin", 1.0, "1.0 m = 3 ft + 3 in")); + } + /** * Test method for {@link Presenter#convertExpressions} - * - * @since v0.4.0 + * * @since 2022-02-12 + * @since v0.4.0 */ - @Test - void testConvertExpressions() { + @ParameterizedTest + @MethodSource + void testConvertExpressions(String from, String to, String expectedOutput) { // setup - final ViewBot viewBot = new ViewBot(); - final Presenter presenter = new Presenter(viewBot); + final var viewBot = new ViewBot(); + final var presenter = new Presenter(viewBot); - viewBot.setFromExpression("10000.0 m"); - viewBot.setToExpression("km"); + viewBot.setFromExpression(from); + viewBot.setToExpression(to); // convert expression presenter.convertExpressions(); // test result - final List<UnitConversionRecord> outputs = viewBot - .expressionConversionList(); - assertEquals("10000.0 m = 10.00000 km", - outputs.get(outputs.size() - 1).toString()); + final var outputs = viewBot.expressionConversionList(); + assertEquals(expectedOutput, outputs.get(outputs.size() - 1).toString()); } /** - * Tests that unit-conversion Views can correctly convert units - * - * @since v0.4.0 + * Test method for {@link Presenter#convertUnits} + * * @since 2022-02-12 + * @since v0.4.0 */ - @Test - void testConvertUnits() { + @ParameterizedTest + @MethodSource + void testConvertUnits(String from, String to, double value, + String expectedOutput) { // setup - final ViewBot viewBot = new ViewBot(); - final Presenter presenter = new Presenter(viewBot); + final var viewBot = new ViewBot(); + final var presenter = new Presenter(viewBot); - viewBot.setFromUnitNames(names(testUnits)); - viewBot.setToUnitNames(names(testUnits)); - viewBot.setFromSelection("metre"); - viewBot.setToSelection("kilometre"); - viewBot.setInputValue("10000.0"); + viewBot.setFromSelection(from); + viewBot.setToSelection(to); + viewBot.setInputValue(Double.toString(value)); - // convert units + // convert expression presenter.convertUnits(); - /* - * use result from system as expected - I'm not testing unit conversion - * here (that's for the backend tests), I'm just testing that it correctly - * calls the unit conversion system - */ - final LinearUnitValue expectedInput = LinearUnitValue.of(Metric.METRE, - UncertainDouble.fromRoundedString("10000.0")); - final LinearUnitValue expectedOutput = expectedInput - .convertTo(Metric.KILOMETRE); - final UnitConversionRecord expectedUC = UnitConversionRecord.valueOf( - expectedInput.getUnit().getName(), - expectedOutput.getUnit().getName(), "10000.0", - expectedOutput.getValue().toString(false, RoundingMode.HALF_EVEN)); - assertEquals(List.of(expectedUC), viewBot.unitConversionList()); + // test result + final var outputs = viewBot.unitConversionList(); + assertEquals(expectedOutput, outputs.get(outputs.size() - 1).toString()); + } + + /** + * Ensures that the default unitfile can be disabled. + * + * @since 2025-02-23 + * @since v1.0.0 + */ + @Test + void testDisableDefault() { + final var viewBot = new ViewBot(); + final var presenter = new Presenter(viewBot); + assumeTrue(presenter.database.containsUnitName("joule"), + "Attempted to test disabling default on unit not in default file."); + presenter.setUseDefaultDatafiles(false); + assertFalse(presenter.database.containsUnitName("joule"), + "Presenter disabled default datafiles, but still contains the joule."); } /** * Tests that duplicate units are successfully removed, if that is asked for - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @Test void testDuplicateUnits() { @@ -190,9 +207,9 @@ public final class PresenterTest { /** * Tests that one-way conversion correctly filters From and To units - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @Test void testOneWayConversion() { @@ -224,9 +241,9 @@ public final class PresenterTest { /** * Tests the prefix-viewing functionality. - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @Test void testPrefixViewing() { @@ -254,9 +271,9 @@ public final class PresenterTest { /** * Tests that rounding rules are used correctly. - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @ParameterizedTest @MethodSource("getRoundingRules") @@ -273,9 +290,9 @@ public final class PresenterTest { presenter.convertUnits(); // test the result of the rounding - final String expectedOutputString = roundingRule + final var expectedOutputString = roundingRule .apply(UncertainDouble.fromRoundedString("12.3456789")); - final String actualOutputString = viewBot.unitConversionList().get(0) + final var actualOutputString = viewBot.unitConversionList().get(0) .outputValueString(); assertEquals(expectedOutputString, actualOutputString); } @@ -284,8 +301,8 @@ public final class PresenterTest { * Tests that the Presenter correctly applies search rules. * * @param searchRule search rule to test - * @since v0.4.0 * @since 2022-07-08 + * @since v0.4.0 */ @ParameterizedTest @MethodSource("getSearchRules") @@ -309,7 +326,7 @@ public final class PresenterTest { .apply(Map.entry("inch", BritishImperial.Length.INCH)).keySet()); expectedOutput.addAll( searchRule.apply(Map.entry("metre", Metric.METRE)).keySet()); - final Set<String> actualOutput = viewBot.getFromUnitNames(); + final var actualOutput = viewBot.getFromUnitNames(); // test output assertEquals(expectedOutput, actualOutput); @@ -317,9 +334,9 @@ public final class PresenterTest { /** * Tests that settings can be saved to and loaded from a file. - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @Test void testSettingsSaving() { @@ -351,9 +368,9 @@ public final class PresenterTest { /** * Ensures the Presenter generates the correct data upon a unit-viewing. - * - * @since v0.4.0 + * * @since 2022-04-16 + * @since v0.4.0 */ @Test void testUnitViewing() { @@ -385,15 +402,15 @@ public final class PresenterTest { /** * Test for {@link Presenter#updateView()} - * - * @since v0.4.0 + * * @since 2022-02-12 + * @since v0.4.0 */ @Test void testUpdateView() { // setup - final ViewBot viewBot = new ViewBot(); - final Presenter presenter = new Presenter(viewBot); + final var viewBot = new ViewBot(); + final var presenter = new Presenter(viewBot); presenter.setOneWayConversionEnabled(false); presenter.setSearchRule(PrefixSearchRule.NO_PREFIXES); @@ -415,8 +432,8 @@ public final class PresenterTest { // filter to length units only, then get the filtered sets of units presenter.updateView(); - final Set<String> fromUnits = viewBot.getFromUnitNames(); - final Set<String> toUnits = viewBot.getToUnitNames(); + final var fromUnits = viewBot.getFromUnitNames(); + final var toUnits = viewBot.getToUnitNames(); // test that fromUnits/toUnits is [METRE, KILOMETRE] assertEquals(Set.of("metre", "kilometre"), fromUnits); diff --git a/src/test/java/sevenUnitsGUI/RoundingTest.java b/src/test/java/sevenUnitsGUI/RoundingTest.java index f749f85..589b8d0 100644 --- a/src/test/java/sevenUnitsGUI/RoundingTest.java +++ b/src/test/java/sevenUnitsGUI/RoundingTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2022 Adrien Hopkins + * Copyright (C) 2022, 2024, 2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -41,8 +41,8 @@ import sevenUnitsGUI.StandardDisplayRules.UncertaintyBased; /** * Tests that ensure the rounding rules work as intended. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ class RoundingTest { // rounding rules to test @@ -69,8 +69,8 @@ class RoundingTest { /** * @return arguments for * {@link #testFixedDecimalRounding(UncertainDouble, String, String, String)} - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ private static final Stream<Arguments> fixedDecimalRoundingExamples() { // input, zero decimal string, two decimal string, six decimal string @@ -83,8 +83,8 @@ class RoundingTest { /** * @return arguments for * {@link #testFixedPrecisionRounding(UncertainDouble, String, String, String)} - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ private static final Stream<Arguments> fixedPrecisionRoundingExamples() { // input, one sig fig string, three s.f. string, six s.f. string @@ -97,8 +97,8 @@ class RoundingTest { /** * @return arguments for * {@link #testUncertaintyRounding(UncertainDouble, String)} - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ private static final Stream<Arguments> uncertaintyRoundingExamples() { // input, uncertainty rounding string @@ -112,8 +112,8 @@ class RoundingTest { * Test for {@link FixedDecimals#decimalPlaces()} and * {@link FixedPrecision#significantFigures()}. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @Test void testDataMethods() { @@ -137,9 +137,9 @@ class RoundingTest { /** * Tests that the rounding methods' equals() methods work. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testEquals() { @@ -161,7 +161,7 @@ class RoundingTest { // test that FixedDecimals is never equal to FixedPrecision // this unlikely argument is the test - the equals should return false! @SuppressWarnings("unlikely-arg-type") - final boolean differentRulesEqual = Objects.equals(fixedDecimals(4), + final var differentRulesEqual = Objects.equals(fixedDecimals(4), fixedPrecision(4)); assertFalse(differentRulesEqual, "fixedDecimals(4) == fixedPrecision(4)"); } @@ -174,6 +174,7 @@ class RoundingTest { * @param twoDecimalString expected string for two decimal places * @param sixDecimalString expected string for six decimal places * @since 2022-07-17 + * @since v0.4.0 */ @ParameterizedTest @MethodSource("fixedDecimalRoundingExamples") @@ -200,8 +201,8 @@ class RoundingTest { * @param oneSigFigString expected string for one significant figure * @param threeSigFigString expected string for three significant figures * @param twelveSigFigString expected string for twelve significant figures - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @ParameterizedTest @MethodSource("fixedPrecisionRoundingExamples") @@ -225,9 +226,9 @@ class RoundingTest { /** * Tests that {@link StandardDisplayRules#getStandardRule} gets rounding * rules as intended. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testGetStandardRule() { @@ -243,9 +244,9 @@ class RoundingTest { /** * Tests that the rounding methods' equals() methods work. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testHashCode() { @@ -257,9 +258,9 @@ class RoundingTest { /** * Tests that the {@code toString()} methods of the three rounding rule * classes work correctly. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testToString() { @@ -273,8 +274,8 @@ class RoundingTest { * * @param input input number * @param output expected output string - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ @ParameterizedTest @MethodSource("uncertaintyRoundingExamples") diff --git a/src/test/java/sevenUnitsGUI/TabbedViewTest.java b/src/test/java/sevenUnitsGUI/TabbedViewTest.java index 165718f..b32579c 100644 --- a/src/test/java/sevenUnitsGUI/TabbedViewTest.java +++ b/src/test/java/sevenUnitsGUI/TabbedViewTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2022 Adrien Hopkins + * Copyright (C) 2022, 2024, 2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -18,20 +18,24 @@ package sevenUnitsGUI; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.concurrent.TimeUnit; + import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; /** - * Test for the TabbedView + * Test for the TabbedView. * - * @since v0.4.0 * @since 2022-07-17 + * @since v0.4.0 */ +@Timeout(value = 10, unit = TimeUnit.SECONDS) class TabbedViewTest { /** * @return a view with all settings set to standard values - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ private static final TabbedView setupView() { final var view = new TabbedView(); @@ -50,9 +54,9 @@ class TabbedViewTest { /** * Simulates an expression conversion operation, and ensures it works * properly. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testExpressionConversion() { @@ -71,9 +75,9 @@ class TabbedViewTest { /** * Simulates a unit conversion operation, and ensures it works properly. - * - * @since v0.4.0 + * * @since 2022-07-17 + * @since v0.4.0 */ @Test void testUnitConversion() { |