You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2019/02/18 14:57:04 UTC

[ant] branch master updated: additional testcases

This is an automated email from the ASF dual-hosted git repository.

jhm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new b5044ca  additional testcases
b5044ca is described below

commit b5044cad48898a946129258127401a2fc2aa5448
Author: Jan Matèrne <jh...@apache.org>
AuthorDate: Mon Feb 18 15:56:31 2019 +0100

    additional testcases
---
 .../apache/tools/ant/util/DeweyDecimalTest.java    | 56 +++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java b/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java
index d16ba15..2ea6d34 100644
--- a/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java
@@ -23,6 +23,7 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 public class DeweyDecimalTest {
 
@@ -72,6 +73,59 @@ public class DeweyDecimalTest {
         assertEquals(0, new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.0")));
     }
 
-    // TODO isGreaterThan, ...
+    @Test
+    public void intConstructor() {
+        int[] args = {1,2,3};
+        assertEquals("1.2.3", new DeweyDecimal(args).toString());
+    }
+
+    @Test
+    public void intConstructorNegativeValues() {
+        int[] args = {-1,-2,-3};
+        assertEquals("-1.-2.-3", new DeweyDecimal(args).toString());
+    }
 
+    @Test
+    public void details() {
+         DeweyDecimal dd = new DeweyDecimal("1.2.3");
+         assertEquals(3, dd.getSize());
+         assertEquals(2, dd.get(1));
+    }
+
+    @Test
+    public void isGreaterThanOrEqual() {
+         DeweyDecimal first = new DeweyDecimal("1.2.3");
+         assertTrue(first.isGreaterThanOrEqual(new DeweyDecimal("1")));
+         assertTrue(first.isGreaterThanOrEqual(new DeweyDecimal("1.2")));
+         assertTrue(first.isGreaterThanOrEqual(new DeweyDecimal("1.2.3")));
+         assertTrue(first.isGreaterThanOrEqual(new DeweyDecimal("1.2.3.0")));
+         assertFalse(first.isGreaterThanOrEqual(new DeweyDecimal("1.2.4")));
+         assertFalse(first.isGreaterThanOrEqual(new DeweyDecimal("1.3")));
+         assertFalse(first.isGreaterThanOrEqual(new DeweyDecimal("2")));
+    }
+
+    @Test
+    public void equals() {
+         DeweyDecimal dd = new DeweyDecimal("1.2.3");
+         assertFalse(dd.equals("other"));
+         assertFalse(dd.equals(null));
+         assertTrue(dd.equals(new DeweyDecimal("1.2.3")));
+         assertTrue(dd.equals(new DeweyDecimal("1.2.3.0")));
+    }
+
+    @Test
+    public void isLessThan() {
+         DeweyDecimal dd = new DeweyDecimal("1.2.3");
+         assertTrue(dd.isLessThan(new DeweyDecimal("2")));
+         assertFalse(dd.isLessThan(new DeweyDecimal("1")));
+         assertFalse(dd.isLessThan(new DeweyDecimal("1.2.3")));
+    }
+
+    @Test
+    public void isLessThanOrEqual() {
+         DeweyDecimal dd = new DeweyDecimal("1.2.3");
+         assertTrue(dd.isLessThanOrEqual(new DeweyDecimal("2")));
+         assertFalse(dd.isLessThanOrEqual(new DeweyDecimal("1")));
+         assertTrue(dd.isLessThanOrEqual(new DeweyDecimal("1.2.3")));
+    }
 }