diff options
author | Julien Eluard <[email protected]> | 2010-11-21 13:03:58 +0100 |
---|---|---|
committer | Julien Eluard <[email protected]> | 2010-11-21 13:03:58 +0100 |
commit | 86bcc9a108a5ba4454f40fe7df7745fb01627341 (patch) | |
tree | bdf11e61afad4fb9c6893092b5e5550fe7bca107 /api/src/test | |
parent | b61abf614ac91f0efe8416b8066009f7796928ab (diff) |
Added tests.
Diffstat (limited to 'api/src/test')
-rw-r--r-- | api/src/test/java/org/semver/VersionTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/api/src/test/java/org/semver/VersionTest.java b/api/src/test/java/org/semver/VersionTest.java index 73f3b76..0923c5f 100644 --- a/api/src/test/java/org/semver/VersionTest.java +++ b/api/src/test/java/org/semver/VersionTest.java @@ -68,6 +68,11 @@ public class VersionTest { Version.parse("1.2"); } + @Test(expected=IllegalArgumentException.class) + public void shouldInvalidVersion5NotBeParsed() { + Version.parse("a.2.3"); + } + @Test public void shouldDevelopmentBeInDevelopment() { Assert.assertTrue(Version.parse("0.1.1").isInDevelopment()); @@ -83,11 +88,36 @@ public class VersionTest { @Test public void isNewer() { 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); + Assert.assertTrue(Version.parse("1.0.0").compareTo(Version.parse("1.1.0")) > 0); Assert.assertTrue(Version.parse("1.0.1").compareTo(Version.parse("1.0.0")) < 0); + Assert.assertTrue(Version.parse("1.0.0").compareTo(Version.parse("1.0.1")) > 0); Assert.assertTrue(Version.parse("1.0.0Beta").compareTo(Version.parse("1.0.0Alpha")) < 0); Assert.assertFalse(Version.parse("0.0.0").compareTo(Version.parse("0.0.0")) < 0); Assert.assertFalse(Version.parse("0.0.0").compareTo(Version.parse("0.0.1")) < 0); } + @Test + public void next() { + final int major = 1; + final int minor = 2; + final int patch = 3; + final Version version = new Version(major, minor, patch); + + Assert.assertEquals(version.next(Version.Element.MAJOR), new Version(major+1, 0, 0)); + Assert.assertEquals(version.next(Version.Element.MINOR), new Version(major, minor+1, 0)); + Assert.assertEquals(version.next(Version.Element.PATCH), new Version(major, minor, patch+1)); + } + + @Test(expected=IllegalArgumentException.class) + public void shouldNextWithNullComparisonTypeFail() { + final int major = 1; + final int minor = 2; + final int patch = 3; + final Version version = new Version(major, minor, patch); + + version.next(null); + } + } |