diff options
Diffstat (limited to 'src/test/java/sevenUnits/utils')
-rw-r--r-- | src/test/java/sevenUnits/utils/ConditionalExistenceCollectionsTest.java | 54 | ||||
-rw-r--r-- | src/test/java/sevenUnits/utils/UncertainDoubleTest.java | 9 |
2 files changed, 40 insertions, 23 deletions
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 |