incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r942364 - in /incubator/ace/trunk/ace-repository-api: pom.xml src/test/java/org/apache/ace/repository/ src/test/java/org/apache/ace/repository/SortedRangeSetTest.java
Date Sat, 08 May 2010 11:37:36 GMT
Author: marrs
Date: Sat May  8 11:37:36 2010
New Revision: 942364

URL: http://svn.apache.org/viewvc?rev=942364&view=rev
Log:
Added unit tests.

Added:
    incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/
    incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/SortedRangeSetTest.java
Modified:
    incubator/ace/trunk/ace-repository-api/pom.xml

Modified: incubator/ace/trunk/ace-repository-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-repository-api/pom.xml?rev=942364&r1=942363&r2=942364&view=diff
==============================================================================
--- incubator/ace/trunk/ace-repository-api/pom.xml (original)
+++ incubator/ace/trunk/ace-repository-api/pom.xml Sat May  8 11:37:36 2010
@@ -49,5 +49,11 @@
         </plugins>
     </build>
 
-
+    <dependencies>
+        <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>ace-util</artifactId>
+            <version>${version}</version>
+        </dependency>
+    </dependencies>
 </project>
\ No newline at end of file

Added: incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/SortedRangeSetTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/SortedRangeSetTest.java?rev=942364&view=auto
==============================================================================
--- incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/SortedRangeSetTest.java
(added)
+++ incubator/ace/trunk/ace-repository-api/src/test/java/org/apache/ace/repository/SortedRangeSetTest.java
Sat May  8 11:37:36 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.repository;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+
+import org.testng.annotations.Test;
+
+public class SortedRangeSetTest {
+    @Test(groups = { UNIT })
+    public void manipulateSimpleRanges() {
+        Range r1 = new Range("5");
+        assert r1.getLow() == 5 : "Lowest value should be 5";
+        assert r1.getHigh() == 5 : "Highest value should be 5";
+        assert r1.contains(5) : "Range should contain 5";
+        assert !r1.contains(4) : "Range should not contain 4";
+        assert !r1.contains(6) : "Range should not contain 6";
+        assert "5".equals(r1.toRepresentation()) : "Representation should be 5";
+        Range r2 = new Range("2-6");
+        assert r2.getLow() == 2 : "Lowest value should be 2";
+        assert r2.getHigh() == 6 : "Highest value should be 6";
+        assert r2.contains(6) : "Range should contain 6";
+        assert !r2.contains(7) : "Range should not contain 7";
+        assert !r2.contains(0) : "Range should not contain 0";
+        assert "2-6".equals(r2.toRepresentation()) : "Representation should be 2-6";
+        Range r3 = new Range(5);
+        assert r3.getLow() == 5 : "Lowest value should be 5";
+        assert r3.getHigh() == 5 : "Highest value should be 5";
+        Range r4 = new Range(6,8);
+        assert r4.getLow() == 6 : "Lowest value should be 6";
+        assert r4.getHigh() == 8 : "Highest value should be 8";
+        Range r5 = new Range(5);
+        r5.setLow(8);
+        assert r5.getHigh() == 8 : "Highest value should be 8";
+        r5.setHigh(2);
+        assert r5.getLow() == 2 : "Lowest value should be 2";
+    }
+
+    @Test(groups = { UNIT })
+    public void manipulateSortedRangeSets() {
+        SortedRangeSet s1 = new SortedRangeSet("1,3,5-8");
+        RangeIterator ri1 = s1.iterator();
+        assert ri1.next() == 1 : "Illegal value in range iterator";
+        assert ri1.next() == 3 : "Illegal value in range iterator";
+        assert ri1.next() == 5 : "Illegal value in range iterator";
+        assert ri1.next() == 6 : "Illegal value in range iterator";
+        assert ri1.next() == 7 : "Illegal value in range iterator";
+        assert ri1.next() == 8 : "Illegal value in range iterator";
+        assert !ri1.hasNext() : "There should not be more values in the iterator";
+        assert new SortedRangeSet("1-20").diffDest(new SortedRangeSet("5-25")).toRepresentation().equals("21-25")
: "Result of diff should be 21-25";
+        assert new SortedRangeSet(new long[] {1,3,5,7,9}).diffDest(new SortedRangeSet("1-10")).toRepresentation().equals("2,4,6,8,10")
: "Result of diff should be 2,4,6,8,10";
+        assert new SortedRangeSet("1-5,8,12").diffDest(new SortedRangeSet("1-5,7,9,12,20")).toRepresentation().equals("7,9,20")
: "Result of diff should be 7,9,20";
+    }
+
+    @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class)
+    public void invalidRange() {
+        new SortedRangeSet("8-5");
+    }
+}



Mime
View raw message