
Untitled
By: a guest on
Aug 30th, 2012 | syntax:
None | size: 1.01 KB | hits: 16 | expires: Never
package foo;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static foo.Version.compare;
import org.junit.Before;
import org.junit.Test;
/**
* @author yclian
* @since 20120507
* @version 20120507
*/
public class VersionTest {
@Before
public void setUp() {}
@Test
public void testCompare() {
assertEquals(-1, compare("1.0.1").with("1.0.2"));
assertEquals(1, compare("1.0.2.1").with("1.0.2"));
assertTrue(compare("1.0.2").eq("1.0.2"));
}
@Test
public void testApproximation() {
assertTrue(compare("1.0.2").agt("1.0")); // ~> 1.0 => >= 1.0 && < 2.0
assertFalse(compare("2.0").agt("1.0"));
assertTrue(compare("1.9").agt("1.0")); // ~> 1.0 => >= 1.0 && < 2.0
assertFalse(compare("0.9").agt("1.0"));
assertTrue(compare("1.0.2").agt("1.0.2")); // ~> 1.0.2 => >= 1.0.2 && < 1.1
assertFalse(compare("1.2").agt("1.0.2"));
}
}