Author: tchemit Date: 2008-02-02 16:33:12 +0000 (Sat, 02 Feb 2008) New Revision: 589 Modified: trunk/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java Log: ajout tests sur l'ordre des versions Modified: trunk/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java =================================================================== --- trunk/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java 2008-02-02 16:32:36 UTC (rev 588) +++ trunk/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java 2008-02-02 16:33:12 UTC (rev 589) @@ -1,3 +1,20 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais, Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ package fr.cemagref.simexplorer.is.entities.metadata; import junit.framework.TestCase; @@ -71,8 +88,31 @@ } public void testOrder() throws Exception { + v0 = Version.valueOf("1"); + v1 = Version.valueOf("1"); + assertEqualsVersion(v0,v1); + v1 = Version.valueOf("1.0"); + assertSmallerVersion(v0,v1); + v1 = Version.valueOf("2"); + assertSmallerVersion(v0,v1); + + v1 = Version.valueOf("0"); + assertGreaterVersion(v0,v1); + v1 = Version.valueOf("0.1"); + assertGreaterVersion(v0,v1); } + private void assertEqualsVersion(Version v0, Version v1) { + assertEquals(0, v0.compareTo(v1)); + } + private void assertSmallerVersion(Version v0, Version v1) { + assertEquals(-1, v0.compareTo(v1)); + } + + private void assertGreaterVersion(Version v0, Version v1) { + assertEquals(1, v0.compareTo(v1)); + } + }