X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Ftest%2FVersionTest.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Ftest%2FVersionTest.java;h=8dc3ba32ad1e6d0c2fb3b880bd1cbf2d03d66c13;hb=32ae20790403c7bce40bf278db8ca0258623945c;hp=0000000000000000000000000000000000000000;hpb=16d593780fa5a4c39cc36b29382da610eae951da;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/test/VersionTest.java b/src/be/nikiroo/utils/test/VersionTest.java new file mode 100644 index 0000000..8dc3ba3 --- /dev/null +++ b/src/be/nikiroo/utils/test/VersionTest.java @@ -0,0 +1,48 @@ +package be.nikiroo.utils.test; + +import be.nikiroo.utils.Version; + +class VersionTest extends TestLauncher { + public VersionTest(String[] args) { + super("Version test", args); + + addTest(new TestCase("String <-> int") { + @Override + public void test() throws Exception { + assertEquals("Cannot parse version 1.2.3 from int to String", + "1.2.3", new Version(1, 2, 3).toString()); + assertEquals( + "Cannot parse major version \"1.2.3\" from String to int", + 1, new Version("1.2.3").getMajor()); + assertEquals( + "Cannot parse minor version \"1.2.3\" from String to int", + 2, new Version("1.2.3").getMinor()); + assertEquals( + "Cannot parse patch version \"1.2.3\" from String to int", + 3, new Version("1.2.3").getPatch()); + } + }); + + addTest(new TestCase("Bad input") { + @Override + public void test() throws Exception { + assertEquals( + "Bad input should return an empty version", + true, + new Version( + "Doors 98 SE Special Deluxe Edition Pro++ Not-Home") + .isEmpty()); + } + }); + + addTest(new TestCase("Read current version") { + @Override + public void test() throws Exception { + assertNotNull("The version should not be NULL (in any case!)", + Version.getCurrentVersion()); + assertEquals("The current version should not be empty", false, + Version.getCurrentVersion().isEmpty()); + } + }); + } +}