elharo commented on a change in pull request #8:
URL: https://github.com/apache/maven-gpg-plugin/pull/8#discussion_r414075252



##########
File path: src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
##########
@@ -19,19 +19,30 @@
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.maven.plugins.gpg.GpgVersion;
 import org.junit.Test;
 
+/**
+ * Tests for {@link GpgVersion}.
+ */
 public class GpgVersionTest
 {
     @Test
     public void test()
     {
-        assertTrue( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).isAtLeast( 
GpgVersion.parse( "gpg (GnuPG) 2.2.1" ) ) );
-        assertTrue( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).isAtLeast( 
GpgVersion.parse( "2.1" ) ) );
-        assertTrue( GpgVersion.parse( "gpg (GnuPG/MacGPG2) 2.2.10" 
).isAtLeast( GpgVersion.parse( "2.2.10" ) ) );
+        assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" )
+                .compareTo( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ) ), 0 );
+
+        assertTrue( GpgVersion.parse( "gpg (GnuPG) 2.2.1" )
+                .isAtLeast( GpgVersion.parse( "2.1" ) ) );
+
+        assertEquals( GpgVersion.parse( "gpg (GnuPG/MacGPG2) 2.2.10" )
+                .compareTo( GpgVersion.parse( "2.2.10" ) ), 0 );
+
+        assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" )

Review comment:
       If equals isn't implemented, I don't trust the Comparable interface; nor 
would I trust a unit test based on it.
   
   "The natural ordering for a class C is said to be consistent with equals if 
and only if e1.compareTo(e2) == 0 has the same boolean value as e1.equals(e2) 
for every e1 and e2 of class C. Note that null is not an instance of any class, 
and e.compareTo(null) should throw a NullPointerException even though 
e.equals(null) returns false.
   
   It is strongly recommended (though not required) that natural orderings be 
consistent with equals. This is so because sorted sets (and sorted maps) 
without explicit comparators behave "strangely" when they are used with 
elements (or keys) whose natural ordering is inconsistent with equals. In 
particular, such a sorted set (or sorted map) violates the general contract for 
set (or map), which is defined in terms of the equals method."
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to