diff options
-rwxr-xr-x | .gitignore | 3 | ||||
-rwxr-xr-x | api/src/main/java/org/semver/Version.java | 18 | ||||
-rwxr-xr-x | api/src/test/java/org/semver/VersionTest.java | 1 |
3 files changed, 14 insertions, 8 deletions
@@ -1 +1,4 @@ target/ +.classpath +.project +.settings diff --git a/api/src/main/java/org/semver/Version.java b/api/src/main/java/org/semver/Version.java index e5c1156..7629250 100755 --- a/api/src/main/java/org/semver/Version.java +++ b/api/src/main/java/org/semver/Version.java @@ -170,16 +170,18 @@ public final class Version implements Comparable<Version> { } else if (this.minor == other.minor) { if (this.patch < other.patch) { return -1; - } else if (this.special != null && other.special != null) { - return this.special.compareTo(other.special); - } else if (other.special != null) { - return -1; - } else if (this.special != null) { - return 1; - } // else handled by previous equals check + } else if (this.patch == other.patch) { + if (this.special != null && other.special != null) { + return this.special.compareTo(other.special); + } else if (other.special != null) { + return -1; + } else if (this.special != null) { + return 1; + } // else handled by previous equals check + } } } - return 1; + return 1; //if this (major, minor or patch) is > than other } @Override diff --git a/api/src/test/java/org/semver/VersionTest.java b/api/src/test/java/org/semver/VersionTest.java index 0acf85c..8f4ac79 100755 --- a/api/src/test/java/org/semver/VersionTest.java +++ b/api/src/test/java/org/semver/VersionTest.java @@ -93,6 +93,7 @@ public class VersionTest { @Test public void isNewer() { + Assert.assertTrue(Version.parse("3.2.3").compareTo(Version.parse("3.2-M1-SNAPSHOT")) > 0); Assert.assertTrue(Version.parse("1.0.0").compareTo(Version.parse("0.0.0")) > 0); Assert.assertTrue(Version.parse("0.0.0").compareTo(Version.parse("1.0.0")) < 0); Assert.assertTrue(Version.parse("1.1.0").compareTo(Version.parse("1.0.0")) > 0); |