elharo commented on a change in pull request #12:
URL: https://github.com/apache/maven-gpg-plugin/pull/12#discussion_r583832637
##########
File path: src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
##########
@@ -48,4 +50,22 @@ public void testOpposite()
assertFalse( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" )
.isBefore( GpgVersion.parse( "2.0.26" ) ) );
}
+
+ @Test
+ public void testEquality()
+ {
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ),
GpgVersion.parse( "gpg (GnuPG) 2.2.1" ) );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ),
GpgVersion.parse( "2.2.1" ) );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG/MacGPG2) 2.2.10" ),
GpgVersion.parse( "2.2.10" ) );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)"
), GpgVersion.parse( "2.0.26" ) );
+
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).hashCode(),
GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).hashCode() );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).hashCode(),
GpgVersion.parse( "2.2.1" ).hashCode() );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG/MacGPG2) 2.2.10"
).hashCode(), GpgVersion.parse( "2.2.10" ).hashCode() );
+ assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)"
).hashCode(), GpgVersion.parse( "2.0.26" ).hashCode() );
+
+ assertNotEquals( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ),
GpgVersion.parse( "2.2.0" ) );
Review comment:
It is indeed expected to a very high degree of probability, specifically
one in 4.2 billion. It is also expected that hashcodes are deterministic and
not random so if this case is not equal now it should not be equal on the next
run. Finally it's expected that a good hash algorithm move nearby values far
apart so this one should definitely be different.
----------------------------------------------------------------
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:
[email protected]