|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ package org.openide.modules; import junit.framework.*; import junit.textui.TestRunner; import org.netbeans.junit.*; /** Test parsing of specification versions. * @author Jesse Glick */ public class SpecificationVersionTest extends NbTestCase { public SpecificationVersionTest(String name) { super(name); } public static void main(String[] args) { TestRunner.run(new NbTestSuite(SpecificationVersionTest.class)); } public void testParseAndCompare() throws Exception { SpecificationVersion v = new SpecificationVersion("1.2.3"); assertEquals("1.2.3", v.toString()); assertTrue(v.compareTo(new SpecificationVersion("1.2.3")) == 0); assertTrue(v.compareTo(new SpecificationVersion("2.4.6")) < 0); assertTrue(v.compareTo(new SpecificationVersion("1.2.4")) < 0); assertTrue(v.compareTo(new SpecificationVersion("1.2.0")) > 0); assertTrue(v.compareTo(new SpecificationVersion("1.2")) > 0); assertTrue(v.compareTo(new SpecificationVersion("1.3")) < 0); assertTrue(v.compareTo(new SpecificationVersion("1.2.3.0")) == 0); assertTrue(v.compareTo(new SpecificationVersion("1.2.2.99")) > 0); assertTrue(v.compareTo(new SpecificationVersion("1.3.0")) < 0); assertTrue(v.compareTo(new SpecificationVersion("1")) > 0); assertTrue(v.compareTo(new SpecificationVersion("2")) < 0); v = new SpecificationVersion("10.99.3"); assertTrue(v.compareTo(new SpecificationVersion("10.9.4")) > 0); assertTrue(v.compareTo(new SpecificationVersion("10.100")) < 0); } public void testMisparse() throws Exception { misparse(""); misparse("1."); misparse(".1"); misparse("-1"); misparse("0x13"); misparse("2..4"); misparse("2...4"); misparse("13.8."); misparse("1.4.0beta"); misparse("hello"); } private void misparse(String s) throws Exception { try { new SpecificationVersion(s); assertTrue("Should have misparsed: " + s, false); } catch (NumberFormatException nfe) { // OK, expected. } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.