| 1 | package be.nikiroo.utils.test; |
| 2 | |
| 3 | import be.nikiroo.utils.Version; |
| 4 | |
| 5 | class VersionTest extends TestLauncher { |
| 6 | public VersionTest(String[] args) { |
| 7 | super("Version test", args); |
| 8 | |
| 9 | addTest(new TestCase("String <-> int") { |
| 10 | @Override |
| 11 | public void test() throws Exception { |
| 12 | assertEquals("Cannot parse version 1.2.3 from int to String", |
| 13 | "1.2.3", new Version(1, 2, 3).toString()); |
| 14 | assertEquals( |
| 15 | "Cannot parse major version \"1.2.3\" from String to int", |
| 16 | 1, new Version("1.2.3").getMajor()); |
| 17 | assertEquals( |
| 18 | "Cannot parse minor version \"1.2.3\" from String to int", |
| 19 | 2, new Version("1.2.3").getMinor()); |
| 20 | assertEquals( |
| 21 | "Cannot parse patch version \"1.2.3\" from String to int", |
| 22 | 3, new Version("1.2.3").getPatch()); |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | addTest(new TestCase("Bad input") { |
| 27 | @Override |
| 28 | public void test() throws Exception { |
| 29 | assertEquals( |
| 30 | "Bad input should return an empty version", |
| 31 | true, |
| 32 | new Version( |
| 33 | "Doors 98 SE Special Deluxe Edition Pro++ Not-Home") |
| 34 | .isEmpty()); |
| 35 | } |
| 36 | }); |
| 37 | |
| 38 | addTest(new TestCase("Read current version") { |
| 39 | @Override |
| 40 | public void test() throws Exception { |
| 41 | assertNotNull("The version should not be NULL (in any case!)", |
| 42 | Version.getCurrentVersion()); |
| 43 | assertEquals("The current version should not be empty", false, |
| 44 | Version.getCurrentVersion().isEmpty()); |
| 45 | } |
| 46 | }); |
| 47 | } |
| 48 | } |