1   /*
2    *  XNap
3    *
4    *  A pure java file sharing client.
5    *
6    *  See AUTHORS for copyright information.
7    *
8    *  This program is free software; you can redistribute it and/or modify
9    *  it under the terms of the GNU General Public License as published by
10   *  the Free Software Foundation; either version 2 of the License, or
11   *  (at your option) any later version.
12   *
13   *  This program is distributed in the hope that it will be useful,
14   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   *  GNU General Public License for more details.
17   *
18   *  You should have received a copy of the GNU General Public License
19   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21   *
22   */
23  package org.xnap.util;
24  
25  import junit.framework.TestCase;
26  
27  /***
28   * @author Steffen Pingel
29   */
30  public class VersionParserTest extends TestCase {
31      
32      public VersionParserTest(String name) 
33      {
34  		super(name);
35      }
36  
37      protected void setUp()
38      {
39      }
40  
41      protected void tearDown()
42      {
43      }
44  
45      public void testEquals() 
46      {
47  		assertTrue(VersionParser.compare("1.3", "  1 .  3") == 0);
48  		assertTrue(VersionParser.compare("1.3", "  1 .  3") == 0);
49  		assertTrue(VersionParser.compare("1.3", "1.4") < 0);
50  		assertTrue(VersionParser.compare("1.4", "1.3") > 0);
51  		assertTrue(VersionParser.compare("1.3r1", "1.3") > 0);
52  		assertTrue(VersionParser.compare("1.3.1", "1.3") > 0);
53  		assertTrue(VersionParser.compare("1.3", "1.3-r2") < 0);
54  		assertTrue(VersionParser.compare("r2", "r1") > 0);
55  		assertTrue(VersionParser.compare("1.3-r2", "1.3-r1") > 0);
56  		assertTrue(VersionParser.compare("1:bbb", "2:aaa") < 0);
57  		assertEquals(new VersionParser("1.2-abc Version").toString(), 
58  					 "1.2-abc Version");
59      }
60  
61  	public void testPostfixes()
62  	{
63  		assertTrue(VersionParser.compare("1.0.0", "1.0-beta1") > 0);
64  		assertTrue(VersionParser.compare("1.0-beta1", "1.0.0") < 0);
65  		assertTrue(VersionParser.compare("3.0-pre4", "3.0.0") < 0);
66  	}
67  
68  }