summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrien Hopkins <ahopk127@my.yorku.ca>2022-07-17 11:21:35 -0500
committerAdrien Hopkins <ahopk127@my.yorku.ca>2022-07-17 11:21:35 -0500
commit5b371a3c57bf5967946e48daa7bd9e16182f529a (patch)
treedfebe6382d4553c7107447d41e6d11edd378d46e /src
parent022da8adeebb9ee62e6b7bc642992e9eb14e6762 (diff)
Added a test for StandardDisplayRules.getStandardRule
Diffstat (limited to 'src')
-rw-r--r--src/test/java/sevenUnitsGUI/RoundingTest.java21
1 files changed, 21 insertions, 0 deletions
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;
@@ -221,6 +223,25 @@ class RoundingTest {
}
/**
+ * 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.
*