This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit ec4f7b66a649539e90d08388ac2cc681070e86e6 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Sep 18 14:44:18 2019 +0200 Add a test for an issue reported when running units of measurement TCK. --- .../java/org/apache/sis/measure/QuantitiesTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/QuantitiesTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/QuantitiesTest.java index 5d726d2..bfab6bf 100644 --- a/core/sis-utility/src/test/java/org/apache/sis/measure/QuantitiesTest.java +++ b/core/sis-utility/src/test/java/org/apache/sis/measure/QuantitiesTest.java @@ -110,4 +110,21 @@ public final strictfp class QuantitiesTest extends TestCase { r = q1.multiply(1); assertSame(q1, r); } + + /** + * Tests {@link Scalar#equals(Object)} and {@link Scalar#hashCode()}. + * This test uses a unit without specific {@link Scalar} subclass, in order to + * verify that tested methods work even though the {@link ScalarFallback} proxy. + */ + @Test + public void testEqualsAndHashcode() { + Quantity<?> q1 = Quantities.create(2, Units.VOLT); + Quantity<?> q2 = Quantities.create(2, Units.VOLT); + Quantity<?> q3 = Quantities.create(3, Units.VOLT); + assertTrue (q1.hashCode() == q2.hashCode()); + assertFalse(q1.hashCode() == q3.hashCode()); + assertTrue (q1.hashCode() != 0); + assertTrue (q1.equals(q2)); + assertFalse(q1.equals(q3)); + } }