From deb4a650caf9eb49d32810e573f22bbd77f0ca47 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Fri, 7 Mar 2025 11:13:50 -0500 Subject: Add tests for LinearUnitValue I specifically added tests for the methods that Jacoco says haven't been tested: - convertToMultiple - equals - equivalent - hashCode - operation methods --- src/test/java/sevenUnits/unit/UnitTest.java | 74 ----------------------------- 1 file changed, 74 deletions(-) (limited to 'src/test/java/sevenUnits/unit/UnitTest.java') diff --git a/src/test/java/sevenUnits/unit/UnitTest.java b/src/test/java/sevenUnits/unit/UnitTest.java index 4fb26a3..6ac0ebd 100644 --- a/src/test/java/sevenUnits/unit/UnitTest.java +++ b/src/test/java/sevenUnits/unit/UnitTest.java @@ -21,7 +21,6 @@ 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 java.math.RoundingMode; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; @@ -29,7 +28,6 @@ import org.junit.jupiter.api.Test; import sevenUnits.utils.DecimalComparison; import sevenUnits.utils.NameSymbol; -import sevenUnits.utils.UncertainDouble; /** * Testing the various Unit classes. This is NOT part of this program's public @@ -153,76 +151,4 @@ class UnitTest { assertEquals(generatedKilometre, actualKilometre); } - - /** - * Tests converting an uncertain LinearUnitValue to a string. - * - * @since 2021-11-04 - */ - @Test - public void testValueToString1() { - final LinearUnitValue value = LinearUnitValue.of(Metric.METRE, - UncertainDouble.of(10, 0.24)); - - assertEquals("(10.0 ± 0.2) m", value.toString()); - assertEquals("(10.0 ± 0.2) m", - value.toString(true, RoundingMode.HALF_EVEN)); - assertEquals("10.0 m", value.toString(false, RoundingMode.HALF_EVEN)); - } - - /** - * Tests converting a certain LinearUnitValue to a string. - * - * @since 2021-11-04 - */ - @Test - public void testValueToString2() { - final LinearUnitValue value = LinearUnitValue.of(Metric.METRE, - UncertainDouble.of(10, 0)); - - assertEquals("10.0 m", value.toString()); - assertEquals("(10.0 ± 0.0) m", - value.toString(true, RoundingMode.HALF_EVEN)); - assertEquals("10.0 m", value.toString(false, RoundingMode.HALF_EVEN)); - } - - /** - * Tests converting an unnamed LinearUnitValue to a string. - * - * @since 2021-11-04 - */ - @Test - public void testValueToString3() { - final LinearUnitValue value = LinearUnitValue.of( - Metric.METRE.withName(NameSymbol.EMPTY), - UncertainDouble.of(10, 0.24)); - - assertEquals("10.0 unnamed unit (= 10.0 m)", - value.toString(false, RoundingMode.HALF_EVEN)); - } - - /** - * Tests converting a named UnitValue to a string. - * - * @since 2021-11-04 - */ - @Test - public void testValueToString4() { - final UnitValue value = UnitValue.of(BritishImperial.FAHRENHEIT, 80); - - assertEquals("80.0 \u00B0F", value.toString()); - } - - /** - * Tests converting an unnamed UnitValue to a string. - * - * @since 2021-11-04 - */ - @Test - public void testValueToString5() { - final UnitValue value = UnitValue - .of(USCustomary.FAHRENHEIT.withName(NameSymbol.EMPTY), 50); - - assertEquals("50.0 unnamed unit (= 283.15 K)", value.toString()); - } } -- cgit v1.2.3