From 5b371a3c57bf5967946e48daa7bd9e16182f529a Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sun, 17 Jul 2022 11:21:35 -0500 Subject: Added a test for StandardDisplayRules.getStandardRule --- src/test/java/sevenUnitsGUI/RoundingTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/test/java/sevenUnitsGUI') diff --git a/src/test/java/sevenUnitsGUI/RoundingTest.java b/src/test/java/sevenUnitsGUI/RoundingTest.java index d5cd669..ddf9cf3 100644 --- a/src/test/java/sevenUnitsGUI/RoundingTest.java +++ b/src/test/java/sevenUnitsGUI/RoundingTest.java @@ -18,9 +18,11 @@ 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.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static sevenUnitsGUI.StandardDisplayRules.fixedDecimals; import static sevenUnitsGUI.StandardDisplayRules.fixedPrecision; +import static sevenUnitsGUI.StandardDisplayRules.getStandardRule; import static sevenUnitsGUI.StandardDisplayRules.uncertaintyBased; import java.util.Objects; @@ -220,6 +222,25 @@ class RoundingTest { + twelveSigFigString + ")"); } + /** + * Tests that {@link StandardDisplayRules#getStandardRule} gets rounding + * rules as intended. + * + * @since v0.4.0 + * @since 2022-07-17 + */ + @Test + void testGetStandardRule() { + assertEquals(ZERO_DECIMALS, getStandardRule("Round to 0 decimal places")); + assertEquals(THREE_SIG_FIGS, + getStandardRule("Round to 3 significant figures")); + assertEquals(UNCERTAINTY_BASED, + getStandardRule("Uncertainty-Based Rounding")); + + assertThrows(IllegalArgumentException.class, + () -> getStandardRule("Not a rounding rule")); + } + /** * Tests that the {@code toString()} methods of the three rounding rule * classes work correctly. -- cgit v1.2.3