summaryrefslogtreecommitdiff
path: root/src/test/java/sevenUnitsGUI
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/sevenUnitsGUI')
-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.
*