diff options
author | Adrien Hopkins <ahopk127@my.yorku.ca> | 2022-07-09 13:53:26 -0500 |
---|---|---|
committer | Adrien Hopkins <ahopk127@my.yorku.ca> | 2022-07-09 13:53:26 -0500 |
commit | 8b124b2437d53d70444f31ef52e00b8d7463c636 (patch) | |
tree | c828b80287bb2a058b2812125b9461f5a56d94b8 /src | |
parent | 39668f4b274f0e7996f65b4f432a48ae0d88daca (diff) |
Added documentation to undocumented tests
Diffstat (limited to 'src')
3 files changed, 50 insertions, 29 deletions
diff --git a/src/test/java/sevenUnits/unit/MultiUnitTest.java b/src/test/java/sevenUnits/unit/MultiUnitTest.java index 39ee21c..30f2941 100644 --- a/src/test/java/sevenUnits/unit/MultiUnitTest.java +++ b/src/test/java/sevenUnits/unit/MultiUnitTest.java @@ -32,30 +32,34 @@ import org.junit.jupiter.api.Test; */ class MultiUnitTest { + /** + * Ensures that the {@code MultiUnit} can convert properly. + */ @Test final void testConvert() { final Random rng = ThreadLocalRandom.current(); final MultiUnit footInch = MultiUnit.of(BritishImperial.Length.FOOT, BritishImperial.Length.INCH); - assertEquals(1702.0, footInch.convertTo(Metric.METRE.withPrefix(Metric.MILLI), - Arrays.asList(5.0, 7.0)), 1.0); + assertEquals(1702.0, + footInch.convertTo(Metric.METRE.withPrefix(Metric.MILLI), + Arrays.asList(5.0, 7.0)), + 1.0); for (int i = 0; i < 1000; i++) { final double feet = rng.nextInt(1000); final double inches = rng.nextDouble() * 12; final double millimetres = feet * 304.8 + inches * 25.4; - final List<Double> feetAndInches = Metric.METRE.withPrefix(Metric.MILLI) - .convertTo(footInch, millimetres); + final List<Double> feetAndInches = Metric.METRE + .withPrefix(Metric.MILLI).convertTo(footInch, millimetres); assertEquals(feet, feetAndInches.get(0), 1e-10); assertEquals(inches, feetAndInches.get(1), 1e-10); } } /** - * Test method for - * {@link sevenUnits.unit.MultiUnit#convertFromBase(double)}. + * Test method for {@link sevenUnits.unit.MultiUnit#convertFromBase(double)}. */ @Test final void testConvertFromBase() { diff --git a/src/test/java/sevenUnits/utils/ConditionalExistenceCollectionsTest.java b/src/test/java/sevenUnits/utils/ConditionalExistenceCollectionsTest.java index d653848..6b5f9cf 100644 --- a/src/test/java/sevenUnits/utils/ConditionalExistenceCollectionsTest.java +++ b/src/test/java/sevenUnits/utils/ConditionalExistenceCollectionsTest.java @@ -34,13 +34,16 @@ import org.junit.jupiter.api.Test; import sevenUnits.utils.ConditionalExistenceCollections.ConditionalExistenceIterator; /** - * Tests the {@link #ConditionalExistenceCollections}. + * Tests the {@link #ConditionalExistenceCollections}. Specifically, it runs + * normal operations on conditional existence collections and ensures that + * elements that do not pass the existence condition are not included in the + * results. * * @author Adrien Hopkins * @since 2019-10-16 */ class ConditionalExistenceCollectionsTest { - + /** * The returned iterator ignores elements that don't start with "a". * @@ -54,7 +57,7 @@ class ConditionalExistenceCollectionsTest { .conditionalExistenceIterator(it, s -> s.startsWith("a")); return cit; } - + /** * The returned map ignores mappings where the value is zero. * @@ -67,13 +70,14 @@ class ConditionalExistenceCollectionsTest { map.put("two", 2); map.put("zero", 0); map.put("ten", 10); - final Map<String, Integer> conditionalMap = ConditionalExistenceCollections.conditionalExistenceMap(map, - e -> !Integer.valueOf(0).equals(e.getValue())); + final Map<String, Integer> conditionalMap = ConditionalExistenceCollections + .conditionalExistenceMap(map, + e -> !Integer.valueOf(0).equals(e.getValue())); return conditionalMap; } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#containsKey(java.lang.Object)}. + * Test method for the ConditionalExistenceMap's containsKey method. */ @Test void testContainsKeyObject() { @@ -83,9 +87,9 @@ class ConditionalExistenceCollectionsTest { assertFalse(map.containsKey("five")); assertFalse(map.containsKey("zero")); } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#containsValue(java.lang.Object)}. + * Test method for the ConditionalExistenceMap's containsValue method. */ @Test void testContainsValueObject() { @@ -95,9 +99,9 @@ class ConditionalExistenceCollectionsTest { assertFalse(map.containsValue(5)); assertFalse(map.containsValue(0)); } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#entrySet()}. + * Test method for the ConditionalExistenceMap's entrySet method. */ @Test void testEntrySet() { @@ -106,9 +110,9 @@ class ConditionalExistenceCollectionsTest { assertTrue(e.getValue() != 0); } } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#get(java.lang.Object)}. + * Test method for the ConditionalExistenceMap's get method. */ @Test void testGetObject() { @@ -118,43 +122,47 @@ class ConditionalExistenceCollectionsTest { assertEquals(null, map.get("five")); assertEquals(null, map.get("zero")); } - + + /** + * Test method for the ConditionalExistenceCollection's iterator. + */ @Test void testIterator() { - final ConditionalExistenceIterator<String> testIterator = this.getTestIterator(); - + final ConditionalExistenceIterator<String> testIterator = this + .getTestIterator(); + assertTrue(testIterator.hasNext); assertTrue(testIterator.hasNext()); assertEquals("aa", testIterator.nextElement); assertEquals("aa", testIterator.next()); - + assertTrue(testIterator.hasNext); assertTrue(testIterator.hasNext()); assertEquals("ab", testIterator.nextElement); assertEquals("ab", testIterator.next()); - + assertFalse(testIterator.hasNext); assertFalse(testIterator.hasNext()); assertEquals(null, testIterator.nextElement); assertThrows(NoSuchElementException.class, testIterator::next); } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#keySet()}. + * Test method for the ConditionalExistenceMap's keySet operation. */ @Test void testKeySet() { final Map<String, Integer> map = this.getTestMap(); assertFalse(map.keySet().contains("zero")); } - + /** - * Test method for {@link org.unitConverter.math.ZeroIsNullMap#values()}. + * Test method for the ConditionalExistenceMap's values operation. */ @Test void testValues() { final Map<String, Integer> map = this.getTestMap(); assertFalse(map.values().contains(0)); } - + } diff --git a/src/test/java/sevenUnits/utils/UncertainDoubleTest.java b/src/test/java/sevenUnits/utils/UncertainDoubleTest.java index 0e18461..5ccef28 100644 --- a/src/test/java/sevenUnits/utils/UncertainDoubleTest.java +++ b/src/test/java/sevenUnits/utils/UncertainDoubleTest.java @@ -34,6 +34,9 @@ import org.junit.jupiter.api.Test; * @since 2021-11-29 */ class UncertainDoubleTest { + /** + * Ensures that the compareTo function behaves correctly. + */ @Test final void testCompareTo() { assertTrue(of(2.0, 0.5).compareTo(of(2.0, 0.1)) == 0); @@ -41,6 +44,9 @@ class UncertainDoubleTest { assertTrue(of(2.0, 0.5).compareTo(of(3.0, 0.1)) < 0); } + /** + * Tests the ___exact operations + */ @Test final void testExactOperations() { final UncertainDouble x = UncertainDouble.of(Math.PI, 0.1); @@ -77,6 +83,9 @@ class UncertainDoubleTest { assertEquals(of(12345.678, 0.001), fromRoundedString("12345.678")); } + /** + * Test for {@link UncertainDouble#fromString} + */ @Test final void testFromString() { // valid strings |