diff --git a/pom.xml b/pom.xml
index d5efcc3..9af879b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,6 +77,17 @@
org.hamcrest
hamcrest
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+ com.google.code.findbugs
+ findbugs-annotations
+ 3.0.1
+ provided
+
@@ -86,7 +97,6 @@
com.qulice
qulice-maven-plugin
- 0.18.19
de.thetaphi
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsComparableEqualTo.java b/src/main/java/org/llorllale/cactoos/matchers/IsComparableEqualTo.java
new file mode 100644
index 0000000..657e47e
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsComparableEqualTo.java
@@ -0,0 +1,61 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import java.util.Comparator;
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
+
+/**
+ * Is {@link Comparable} equal to.
+ *
+ * @param Underlying type.
+ * @since 1.0.0
+ */
+public final class IsComparableEqualTo> extends
+ MatcherEnvelope {
+ /**
+ * Ctor.
+ * @param expected The expected value
+ */
+ public IsComparableEqualTo(final T expected) {
+ this(new NaturalOrdering<>(), expected);
+ }
+
+ /**
+ * Ctor.
+ * @param comparator The comparator.
+ * @param expected The expected value
+ */
+ public IsComparableEqualTo(final Comparator super T> comparator, final T expected) {
+ super(
+ ComparatorMatcherBuilder
+ .comparedBy(comparator)
+ .comparesEqualTo(expected)
+ );
+ }
+
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThan.java b/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThan.java
new file mode 100644
index 0000000..ec688a7
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThan.java
@@ -0,0 +1,53 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
+
+/**
+ * Is {@link Comparable} object greater than.
+ *
+ * @param Underlying type.
+ * @since 1.0.0
+ */
+public final class IsComparableGreaterThan> extends
+ MatcherEnvelope {
+
+ /**
+ * Ctor.
+ *
+ * @param expected The expected value
+ */
+ public IsComparableGreaterThan(final T expected) {
+ super(
+ ComparatorMatcherBuilder
+ .comparedBy(new NaturalOrdering())
+ .greaterThan(expected)
+ );
+ }
+
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualTo.java b/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualTo.java
new file mode 100644
index 0000000..5de66f6
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualTo.java
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
+
+/**
+ * Is {@link Comparable} greater than or equal to.
+ *
+ * @param Underlying type.
+ * @since 1.0.0
+ */
+public final class IsComparableGreaterThanOrEqualTo> extends
+ MatcherEnvelope {
+ /**
+ * Ctor.
+ * @param expected The expected value
+ */
+ public IsComparableGreaterThanOrEqualTo(final T expected) {
+ super(
+ ComparatorMatcherBuilder
+ .comparedBy(new NaturalOrdering())
+ .greaterThanOrEqualTo(expected)
+ );
+ }
+
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThan.java b/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThan.java
new file mode 100644
index 0000000..a365872
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThan.java
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
+
+/**
+ * Is {@link Comparable} object greater than.
+ *
+ * @param Underlying type.
+ * @since 1.0.0
+ */
+public final class IsComparableLessThan> extends
+ MatcherEnvelope {
+ /**
+ * Ctor.
+ * @param expected The expected value
+ */
+ public IsComparableLessThan(final T expected) {
+ super(
+ ComparatorMatcherBuilder
+ .comparedBy(new NaturalOrdering())
+ .lessThan(expected)
+ );
+ }
+
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualTo.java b/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualTo.java
new file mode 100644
index 0000000..3385cd4
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualTo.java
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
+
+/**
+ * Is {@link Comparable} object less than or equal to.
+ *
+ * @param Underlying type.
+ * @since 1.0.0
+ */
+public final class IsComparableLessThanOrEqualTo> extends
+ MatcherEnvelope {
+ /**
+ * Ctor.
+ * @param expected The expected value
+ */
+ public IsComparableLessThanOrEqualTo(final T expected) {
+ super(
+ ComparatorMatcherBuilder
+ .comparedBy(new NaturalOrdering())
+ .lessThanOrEqualTo(expected)
+ );
+ }
+
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/IsNumber.java b/src/main/java/org/llorllale/cactoos/matchers/IsNumber.java
index 7494ff2..5ef922b 100644
--- a/src/main/java/org/llorllale/cactoos/matchers/IsNumber.java
+++ b/src/main/java/org/llorllale/cactoos/matchers/IsNumber.java
@@ -26,44 +26,24 @@
*/
package org.llorllale.cactoos.matchers;
-import java.util.Comparator;
+import org.hamcrest.comparator.ComparatorMatcherBuilder;
/**
- * Matcher for {@link Number}.
+ * Matcher for {@link Number} equality.
*
* @since 1.0.0
*/
public final class IsNumber extends MatcherEnvelope {
- /**
- * Comparator of numbers.
- */
- private static final Comparator FNC =
- Comparator
- .comparing(Number::doubleValue)
- .thenComparing(Number::intValue)
- .thenComparing(Number::longValue)
- .thenComparing(Number::floatValue);
-
/**
* Ctor.
* @param expected The expected value
- * @todo #165:30min Introduce a ComparatorMatcher that encapsulates comparison logic here.
- * It would only take a {@code Comparator} and an expected X for example.
*/
public IsNumber(final Number expected) {
super(
- new MatcherOf<>(
- actual -> IsNumber.FNC.compare(actual, expected) == 0,
- desc -> desc.appendText("equals ").appendValue(expected),
- (actual, desc) -> desc
- .appendText("comparator returns ")
- .appendValue(IsNumber.FNC.compare(actual, expected))
- .appendText(" when ")
- .appendValue(expected)
- .appendText(" compared to ")
- .appendValue(actual)
- )
+ ComparatorMatcherBuilder
+ .comparedBy(new NumberComparator())
+ .comparesEqualTo(expected)
);
}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/MatcherEnvelope.java b/src/main/java/org/llorllale/cactoos/matchers/MatcherEnvelope.java
index d9510fd..c0f2b61 100644
--- a/src/main/java/org/llorllale/cactoos/matchers/MatcherEnvelope.java
+++ b/src/main/java/org/llorllale/cactoos/matchers/MatcherEnvelope.java
@@ -40,13 +40,13 @@ public abstract class MatcherEnvelope extends BaseMatcher {
/**
* The matcher to test.
*/
- private final Matcher origin;
+ private final Matcher super T> origin;
/**
* Ctor.
* @param origin Encapsulated matcher.
*/
- protected MatcherEnvelope(final Matcher origin) {
+ protected MatcherEnvelope(final Matcher super T> origin) {
super();
this.origin = origin;
}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/NaturalOrdering.java b/src/main/java/org/llorllale/cactoos/matchers/NaturalOrdering.java
new file mode 100644
index 0000000..6b9f5d4
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/NaturalOrdering.java
@@ -0,0 +1,55 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * Type-safe re-implementation of {@link Comparator#naturalOrder()}.
+ *
+ * @param Type of comparable object.
+ * @since 1.0.0
+ */
+final class NaturalOrdering> implements
+ Comparator, Serializable {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = -1L;
+
+ @Override
+ public int compare(final T first, final T second) {
+ return first.compareTo(second);
+ }
+
+ @Override
+ public String toString() {
+ return "NaturalOrdering";
+ }
+}
diff --git a/src/main/java/org/llorllale/cactoos/matchers/NumberComparator.java b/src/main/java/org/llorllale/cactoos/matchers/NumberComparator.java
new file mode 100644
index 0000000..03fadf8
--- /dev/null
+++ b/src/main/java/org/llorllale/cactoos/matchers/NumberComparator.java
@@ -0,0 +1,82 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * Comparator for Numbers.
+ *
+ * @since 1.0.0
+ */
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED")
+final class NumberComparator implements Comparator, Serializable {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Comparator of numbers.
+ */
+ private final transient Comparator super Number> comparator;
+
+ /**
+ * Ctor.
+ * @param comparator Comparator.
+ */
+ private NumberComparator(
+ final Comparator super Number> comparator
+ ) {
+ this.comparator = comparator;
+ }
+
+ /**
+ * Ctor.
+ */
+ NumberComparator() {
+ this(
+ Comparator
+ .comparing(Number::doubleValue)
+ .thenComparing(Number::intValue)
+ .thenComparing(Number::longValue)
+ .thenComparing(Number::floatValue)
+ );
+ }
+
+ @Override
+ public int compare(final Number first, final Number second) {
+ return this.comparator.compare(first, second);
+ }
+
+ @Override
+ public String toString() {
+ return "NumberComparator";
+ }
+}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsComparableEqualToTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsComparableEqualToTest.java
new file mode 100644
index 0000000..deb1593
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsComparableEqualToTest.java
@@ -0,0 +1,62 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for {@link IsComparableEqualTo}.
+ *
+ * @since 1.0.0
+ */
+@SuppressWarnings("unchecked")
+final class IsComparableEqualToTest {
+
+ @Test
+ void matches() {
+ new Assertion<>(
+ "Must match",
+ 0,
+ new IsComparableEqualTo<>(0)
+ ).affirm();
+ }
+
+ @Test
+ void mismatches() {
+ new Assertion<>(
+ "Must mismatch",
+ new IsComparableEqualTo<>(0),
+ new Mismatches<>(
+ 1,
+ "a value equal to <0> when compared by ",
+ "<1> was greater than <0> when compared by "
+ )
+ ).affirm();
+ }
+
+}
+
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualToTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualToTest.java
new file mode 100644
index 0000000..2164417
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanOrEqualToTest.java
@@ -0,0 +1,62 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.core.AllOf;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for {@link IsComparableGreaterThanOrEqualTo}.
+ * @since 1.0.0
+ */
+@SuppressWarnings("unchecked")
+final class IsComparableGreaterThanOrEqualToTest {
+ @Test
+ void matches() {
+ new Assertion<>(
+ "Must match",
+ 1,
+ new AllOf<>(
+ new IsComparableGreaterThanOrEqualTo<>(0),
+ new IsComparableGreaterThanOrEqualTo<>(1)
+ )
+ ).affirm();
+ }
+
+ @Test
+ void mismatches() {
+ new Assertion<>(
+ "Must mismatch",
+ new IsComparableGreaterThanOrEqualTo<>(0),
+ new Mismatches<>(
+ -1,
+ "a value equal to or greater than <0> when compared by ",
+ "<-1> was less than <0> when compared by "
+ )
+ ).affirm();
+ }
+}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanTest.java
new file mode 100644
index 0000000..0b9128d
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsComparableGreaterThanTest.java
@@ -0,0 +1,62 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.core.AllOf;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for {@link IsComparableGreaterThan}.
+ * @since 1.0.0
+ */
+@SuppressWarnings("unchecked")
+final class IsComparableGreaterThanTest {
+ @Test
+ void matches() {
+ new Assertion<>(
+ "Must match",
+ 1,
+ new AllOf<>(
+ new IsComparableGreaterThan<>(0),
+ new IsComparableGreaterThan<>(-1)
+ )
+ ).affirm();
+ }
+
+ @Test
+ void mismatches() {
+ new Assertion<>(
+ "Must mismatch",
+ new IsComparableGreaterThan<>(0),
+ new Mismatches<>(
+ -1,
+ "a value greater than <0> when compared by ",
+ "<-1> was less than <0> when compared by "
+ )
+ ).affirm();
+ }
+}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualToOrEqualToTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualToOrEqualToTest.java
new file mode 100644
index 0000000..a96cc7f
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanOrEqualToOrEqualToTest.java
@@ -0,0 +1,65 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.core.AllOf;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for {@link IsComparableLessThanOrEqualTo}.
+ *
+ * @since 1.0.0
+ */
+@SuppressWarnings("unchecked")
+final class IsComparableLessThanOrEqualToOrEqualToTest {
+
+ @Test
+ void matches() {
+ new Assertion<>(
+ "Must match",
+ 0,
+ new AllOf<>(
+ new IsComparableLessThanOrEqualTo<>(0),
+ new IsComparableLessThanOrEqualTo<>(1)
+ )
+ ).affirm();
+ }
+
+ @Test
+ void mismatches() {
+ new Assertion<>(
+ "Must mismatch",
+ new IsComparableLessThanOrEqualTo<>(0),
+ new Mismatches<>(
+ 1,
+ "a value less than or equal to <0> when compared by ",
+ "<1> was greater than <0> when compared by "
+ )
+ ).affirm();
+ }
+
+}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanTest.java
new file mode 100644
index 0000000..5ee2f06
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsComparableLessThanTest.java
@@ -0,0 +1,62 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import org.hamcrest.core.AllOf;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test for {@link IsComparableLessThan}.
+ * @since 1.0.0
+ */
+@SuppressWarnings("unchecked")
+final class IsComparableLessThanTest {
+ @Test
+ void matches() {
+ new Assertion<>(
+ "Must match",
+ Integer.MIN_VALUE,
+ new AllOf<>(
+ new IsComparableLessThan<>(0),
+ new IsComparableLessThan<>(-1)
+ )
+ ).affirm();
+ }
+
+ @Test
+ void mismatches() {
+ new Assertion<>(
+ "Must mismatch",
+ new IsComparableLessThan<>(0),
+ new Mismatches<>(
+ 1,
+ "a value less than <0> when compared by ",
+ "<1> was greater than <0> when compared by "
+ )
+ ).affirm();
+ }
+}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/IsNumberTest.java b/src/test/java/org/llorllale/cactoos/matchers/IsNumberTest.java
index 1da119e..1da8b70 100644
--- a/src/test/java/org/llorllale/cactoos/matchers/IsNumberTest.java
+++ b/src/test/java/org/llorllale/cactoos/matchers/IsNumberTest.java
@@ -53,8 +53,8 @@ void mismatchesDouble() {
new IsNumber(Double.POSITIVE_INFINITY),
new Mismatches<>(
1234,
- "equals ",
- "comparator returns <-1> when compared to <1234>"
+ "a value equal to when compared by ",
+ "<1234> was less than when compared by "
)
).affirm();
}
diff --git a/src/test/java/org/llorllale/cactoos/matchers/NaturalOrderingTest.java b/src/test/java/org/llorllale/cactoos/matchers/NaturalOrderingTest.java
new file mode 100644
index 0000000..a7ec40a
--- /dev/null
+++ b/src/test/java/org/llorllale/cactoos/matchers/NaturalOrderingTest.java
@@ -0,0 +1,70 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) for portions of project cactoos-matchers are held by
+ * Yegor Bugayenko, 2017-2018, as part of project cactoos.
+ * All other copyright for project cactoos-matchers are held by
+ * George Aristy, 2018-2020.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.llorllale.cactoos.matchers;
+
+import java.util.Comparator;
+import java.util.stream.Stream;
+import org.hamcrest.core.IsEqual;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+/**
+ * Test for {@link NaturalOrdering}.
+ *
+ * @since 1.0.0
+ */
+final class NaturalOrderingTest implements ArgumentsProvider {
+
+ @Override
+ public Stream extends Arguments> provideArguments(
+ final ExtensionContext context
+ ) throws Exception {
+ return Stream.of(
+ Arguments.of(1, 2),
+ Arguments.of(1d, 2d),
+ Arguments.of(0, 1),
+ Arguments.of(0, 0)
+ );
+ }
+
+ @ArgumentsSource(NaturalOrderingTest.class)
+ @ParameterizedTest
+ > void actsTheSameAsNaturalOrder(
+ final T first, final T second
+ ) {
+ new Assertion<>(
+ "Must be the same",
+ new NaturalOrdering().compare(first, second),
+ new IsEqual<>(
+ Comparator.naturalOrder().compare(first, second)
+ )
+ ).affirm();
+ }
+}