sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1449006 [2/2] - in /sis/trunk: ./ sis-utility/src/main/java/org/apache/sis/math/ sis-utility/src/main/java/org/apache/sis/measure/ sis-utility/src/main/java/org/apache/sis/util/ sis-utility/src/main/java/org/apache/sis/util/collection/ sis...
Date Fri, 22 Feb 2013 11:55:19 GMT
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java Fri Feb 22 11:55:18 2013
@@ -34,11 +34,11 @@ import static org.junit.Assert.*;
 @DependsOn(RangeTest.class)
 public final strictfp class NumberRangeTest extends TestCase {
     /**
-     * Tests the bounds values of a range of integers.
+     * Tests the endpoint values of a range of integers.
      */
     @Test
-    public void testIntegerBounds() {
-        final NumberRange<Integer> range = NumberRange.create(10, 20);
+    public void testIntegerEndpoints() {
+        final NumberRange<Integer> range = NumberRange.create(10, true, 20, true);
         assertEquals(10, range.getMinDouble(     ), 0);
         assertEquals(10, range.getMinDouble(true ), 0);
         assertEquals( 9, range.getMinDouble(false), 0);
@@ -52,15 +52,15 @@ public final strictfp class NumberRangeT
      */
     @Test
     public void testWithIntegers() {
-        NumberRange<Integer> r1 = NumberRange.create(10, 20);
-        NumberRange<Integer> r2 = NumberRange.create(15, 30);
+        NumberRange<Integer> r1 = NumberRange.create(10, true, 20, true);
+        NumberRange<Integer> r2 = NumberRange.create(15, true, 30, true);
         assertTrue (r1.equals(r1));
         assertTrue (r2.equals(r2));
         assertFalse(r1.equals(r2));
         assertEquals(Integer.class, r1.getElementType());
         assertEquals(Integer.class, r2.getElementType());
-        assertEquals(NumberRange.create(10, 30), r1.union(r2));
-        assertEquals(NumberRange.create(15, 20), r1.intersect(r2));
+        assertEquals(NumberRange.create(10, true, 30, true), r1.union(r2));
+        assertEquals(NumberRange.create(15, true, 20, true), r1.intersect(r2));
     }
 
     /**
@@ -68,12 +68,12 @@ public final strictfp class NumberRangeT
      */
     @Test
     public void testWithDoubles() {
-        NumberRange<Double> r1 = NumberRange.create(10.0, 20.0);
-        NumberRange<Double> r2 = NumberRange.create(15.0, 30.0);
+        NumberRange<Double> r1 = NumberRange.create(10.0, true, 20.0, true);
+        NumberRange<Double> r2 = NumberRange.create(15.0, true, 30.0, true);
         assertEquals(Double.class, r1.getElementType());
         assertEquals(Double.class, r2.getElementType());
-        assertEquals(NumberRange.create(10.0, 30.0), r1.union(r2));
-        assertEquals(NumberRange.create(15.0, 20.0), r1.intersect(r2));
+        assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.union(r2));
+        assertEquals(NumberRange.create(15.0, true, 20.0, true), r1.intersect(r2));
     }
 
     /**
@@ -81,15 +81,15 @@ public final strictfp class NumberRangeT
      */
     @Test
     public void testIntegerWithDoubleArguments() {
-        NumberRange<Integer> r1 = NumberRange.create(10, 20);
-        NumberRange<Double>  r2 = NumberRange.create(15.0, 30.0);
+        NumberRange<Integer> r1 = NumberRange.create(10,   true, 20,   true);
+        NumberRange<Double>  r2 = NumberRange.create(15.0, true, 30.0, true);
         assertEquals(Integer.class, r1.getElementType());
         assertEquals(Double .class, r2.getElementType());
-        assertEquals(NumberRange.create(10.0, 30.0), r1.unionAny(r2));
-        assertEquals(NumberRange.create(15, 20), r1.intersectAny(r2));
+        assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.unionAny(r2));
+        assertEquals(NumberRange.create(15,   true, 20,   true), r1.intersectAny(r2));
 
-        r2 = NumberRange.create(15.5, 30.0);
-        assertEquals(NumberRange.create(15.5f, 20.0f), r1.intersectAny(r2));
+        r2 = NumberRange.create(15.5, true, 30.0, true);
+        assertEquals(NumberRange.create(15.5f, true, 20.0f, true), r1.intersectAny(r2));
     }
 
     /**
@@ -97,15 +97,15 @@ public final strictfp class NumberRangeT
      */
     @Test
     public void testDoubleWithIntegerArguments() {
-        NumberRange<Double>  r1 = NumberRange.create(10.0, 20.0);
-        NumberRange<Integer> r2 = NumberRange.create(15, 30);
+        NumberRange<Double>  r1 = NumberRange.create(10.0, true, 20.0, true);
+        NumberRange<Integer> r2 = NumberRange.create(15,   true, 30,   true);
         assertEquals(Double .class, r1.getElementType());
         assertEquals(Integer.class, r2.getElementType());
-        assertEquals(NumberRange.create(10.0, 30.0), r1.unionAny(r2));
-        assertEquals(NumberRange.create(15, 20), r1.intersectAny(r2));
+        assertEquals(NumberRange.create(10.0, true, 30.0, true), r1.unionAny(r2));
+        assertEquals(NumberRange.create(15,   true, 20,   true), r1.intersectAny(r2));
 
-        r1 = NumberRange.create(10.0, 20.5);
-        assertEquals(NumberRange.create(15.0f, 20.5f), r1.intersectAny(r2));
+        r1 = NumberRange.create(10.0, true, 20.5, true);
+        assertEquals(NumberRange.create(15.0f, true, 20.5f, true), r1.intersectAny(r2));
     }
 
     /**
@@ -113,7 +113,7 @@ public final strictfp class NumberRangeT
      */
     @Test
     public void testCreateBestFit() {
-        assertEquals(NumberRange.create((short) 2, (short) 200),
+        assertEquals(NumberRange.create((short) 2, true, (short) 200, true),
                 NumberRange.createBestFit(2, true, 200.0, true));
     }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java Fri Feb 22 11:55:18 2013
@@ -102,7 +102,7 @@ public final strictfp class RangeFormatT
         maxPos = new FieldPosition(RangeFormat.Field.MAX_VALUE);
 
         // Closed range
-        assertEquals("[-10 … 20]", format(NumberRange.create(-10, 20)));
+        assertEquals("[-10 … 20]", format(NumberRange.create(-10, true, 20, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   4, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 7, maxPos.getBeginIndex());
@@ -130,63 +130,63 @@ public final strictfp class RangeFormatT
         assertEquals("maxPos.endIndex",   8, maxPos.getEndIndex());
 
         // Single value
-        assertEquals("300", format(NumberRange.create(300, 300)));
-        assertEquals("minPos.beginIndex", 0, minPos.getBeginIndex());
-        assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
-        assertEquals("maxPos.beginIndex", 0, maxPos.getBeginIndex());
-        assertEquals("maxPos.endIndex",   3, maxPos.getEndIndex());
+        assertEquals("{300}", format(NumberRange.create(300, true, 300, true)));
+        assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
+        assertEquals("minPos.endIndex",   4, minPos.getEndIndex());
+        assertEquals("maxPos.beginIndex", 1, maxPos.getBeginIndex());
+        assertEquals("maxPos.endIndex",   4, maxPos.getEndIndex());
 
         // Empty range
-        assertEquals("[]", format(NumberRange.create(300, true, 300, false)));
+        assertEquals("{}", format(NumberRange.create(300, true, 300, false)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   1, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 1, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   1, maxPos.getEndIndex());
 
         // Negative infinity
-        assertEquals("(-∞ … 30]", format(NumberRange.create(Double.NEGATIVE_INFINITY, 30)));
+        assertEquals("(-∞ … 30]", format(NumberRange.create(Double.NEGATIVE_INFINITY, true, 30, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 6, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   8, maxPos.getEndIndex());
 
         // Positive infinity
-        assertEquals("[50 … ∞)", format(NumberRange.create(50, Double.POSITIVE_INFINITY)));
+        assertEquals("[50 … ∞)", format(NumberRange.create(50, true, Double.POSITIVE_INFINITY, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 6, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   7, maxPos.getEndIndex());
 
         // Positive infinities
-        assertEquals("(-∞ … ∞)", format(NumberRange.create(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)));
+        assertEquals("(-∞ … ∞)", format(NumberRange.create(Double.NEGATIVE_INFINITY, true, Double.POSITIVE_INFINITY, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 6, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   7, maxPos.getEndIndex());
 
         // Positive infinity with integers
-        assertEquals("[50 … ∞)", format(new NumberRange<Integer>(Integer.class, 50, null)));
+        assertEquals("[50 … ∞)", format(new NumberRange<Integer>(Integer.class, 50, true, null, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 6, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   7, maxPos.getEndIndex());
 
         // Negative infinity with integers
-        assertEquals("(-∞ … 40]", format(new NumberRange<Integer>(Integer.class, null, 40)));
+        assertEquals("(-∞ … 40]", format(new NumberRange<Integer>(Integer.class, null, true, 40, true)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   3, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 6, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   8, maxPos.getEndIndex());
 
         // Measurement
-        assertEquals("[-10 … 20] m", format(MeasurementRange.create(-10, 20, SI.METRE)));
+        assertEquals("[-10 … 20] m", format(MeasurementRange.create(-10, true, 20, true, SI.METRE)));
         assertEquals("minPos.beginIndex", 1, minPos.getBeginIndex());
         assertEquals("minPos.endIndex",   4, minPos.getEndIndex());
         assertEquals("maxPos.beginIndex", 7, maxPos.getBeginIndex());
         assertEquals("maxPos.endIndex",   9, maxPos.getEndIndex());
 
         maxPos = new FieldPosition(RangeFormat.Field.UNIT);
-        assertEquals("[-1 … 2] km", format(MeasurementRange.create(-1, 2, SI.KILOMETRE)));
+        assertEquals("[-1 … 2] km", format(MeasurementRange.create(-1, true, 2, true, SI.KILOMETRE)));
         assertEquals("unitPos.beginIndex", 9, maxPos.getBeginIndex());
         assertEquals("unitPos.endIndex",  11, maxPos.getEndIndex());
     }
@@ -201,14 +201,16 @@ public final strictfp class RangeFormatT
         format   = new RangeFormat(Locale.CANADA, Integer.class);
         parsePos = new ParsePosition(0);
 
-        assertEquals(NumberRange.create(-10,         20       ), parse("[-10 … 20]" ));
+        assertEquals(NumberRange.create(-10, true,   20, true ), parse("[-10 … 20]" ));
         assertEquals(NumberRange.create( -3, false,   4, false), parse("( -3 …  4) "));
         assertEquals(NumberRange.create(  2, true,    8, false), parse("  [2 …  8) _"));
         assertEquals(NumberRange.create( 40, false,  90, true ), parse(" (40 … 90]_"));
-        assertEquals(NumberRange.create(300,        300       ), parse(" 300_"));
-        assertEquals(NumberRange.create(300,        300       ), parse("[300]"));
+        assertEquals(NumberRange.create(300, true,  300, true ), parse(" 300_"));
+        assertEquals(NumberRange.create(300, true,  300, true ), parse("[300]"));
         assertEquals(NumberRange.create(300, false, 300, false), parse("(300)"));
+        assertEquals(NumberRange.create(300, true,  300, true ), parse("{300}"));
         assertEquals(NumberRange.create(  0, true,    0, false), parse("[]"));
+        assertEquals(NumberRange.create(  0, true,    0, false), parse("{}"));
     }
 
     /**
@@ -221,9 +223,9 @@ public final strictfp class RangeFormatT
         format   = new RangeFormat(Locale.CANADA, Double.class);
         parsePos = new ParsePosition(0);
 
-        assertEquals(NumberRange.create(-10.0,             20.0), parse("[-10 … 20]" ));
-        assertEquals(NumberRange.create(NEGATIVE_INFINITY, 30.0), parse("[-∞ … 30]"));
-        assertEquals(NumberRange.create(50.0, POSITIVE_INFINITY), parse("[50 … ∞]"));
+        assertEquals(NumberRange.create(-10.0, true,             20.0, true), parse("[-10 … 20]" ));
+        assertEquals(NumberRange.create(NEGATIVE_INFINITY, true, 30.0, true), parse("[-∞ … 30]"));
+        assertEquals(NumberRange.create(50.0, true, POSITIVE_INFINITY, true), parse("[50 … ∞]"));
     }
 
     /**
@@ -235,11 +237,11 @@ public final strictfp class RangeFormatT
         format   = new RangeFormat(Locale.CANADA);
         parsePos = new ParsePosition(0);
 
-        assertEquals(NumberRange.create((byte)    -10, (byte)    20), parse("[  -10 …    20]" ));
-        assertEquals(NumberRange.create((short) -1000, (short) 2000), parse("[-1000 …  2000]" ));
-        assertEquals(NumberRange.create((int)      10, (int)  40000), parse("[   10 … 40000]" ));
-        assertEquals(NumberRange.create((int)       1, (int)  50000), parse("[ 1.00 … 50000]" ));
-        assertEquals(NumberRange.create((float)   8.5, (float)    4), parse("[ 8.50 …     4]" ));
+        assertEquals(NumberRange.create((byte)    -10, true, (byte)    20, true), parse("[  -10 …    20]" ));
+        assertEquals(NumberRange.create((short) -1000, true, (short) 2000, true), parse("[-1000 …  2000]" ));
+        assertEquals(NumberRange.create((int)      10, true, (int)  40000, true), parse("[   10 … 40000]" ));
+        assertEquals(NumberRange.create((int)       1, true, (int)  50000, true), parse("[ 1.00 … 50000]" ));
+        assertEquals(NumberRange.create((float)   8.5, true, (float)    4, true), parse("[ 8.50 …     4]" ));
     }
 
     /**
@@ -290,7 +292,9 @@ public final strictfp class RangeFormatT
         final long DAY  = 24L * HOUR;
         final long YEAR = round(365.25 * DAY);
 
-        DateRange range = new DateRange(new Date(15*DAY + 18*HOUR), new Date(20*YEAR + 15*DAY + 9*HOUR));
+        Range<Date> range = new Range<Date>(Date.class,
+                new Date(15*DAY + 18*HOUR), true,
+                new Date(20*YEAR + 15*DAY + 9*HOUR), true);
         AttributedCharacterIterator it = format.formatToCharacterIterator(range);
         String text = it.toString();
         findYears(it, RangeFormat.Field.MIN_VALUE, minPos);
@@ -302,9 +306,9 @@ public final strictfp class RangeFormatT
         assertEquals(26, maxPos.getEndIndex());
         assertEquals(range, parse(text));
         /*
-         * Try again with the infinity symbol in one bounds.
+         * Try again with the infinity symbol in one endpoint.
          */
-        range = new DateRange((Date) null, new Date(20*YEAR));
+        range = new Range<Date>(Date.class, (Date) null, true, new Date(20*YEAR), true);
         it    = format.formatToCharacterIterator(range);
         text  = it.toString();
         findYears(it, RangeFormat.Field.MAX_VALUE, maxPos);
@@ -313,7 +317,7 @@ public final strictfp class RangeFormatT
         assertEquals(14, maxPos.getEndIndex());
         assertEquals(range, parse(text));
 
-        range = new DateRange(new Date(20*YEAR), (Date) null);
+        range = new Range<Date>(Date.class, new Date(20*YEAR), true, (Date) null, true);
         it    = format.formatToCharacterIterator(range);
         text  = it.toString();
         findYears(it, RangeFormat.Field.MIN_VALUE, minPos);

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java Fri Feb 22 11:55:18 2013
@@ -37,7 +37,7 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testConstructor() {
-        Range<Integer> range = new Range<Integer>(Integer.class, 3, 5);
+        Range<Integer> range = new Range<Integer>(Integer.class, 3, true, 5, true);
         assertEquals(Integer.valueOf(3), range.getMinValue());
         assertEquals(Integer.valueOf(5), range.getMaxValue());
         assertTrue  (range.isMaxIncluded());
@@ -65,7 +65,7 @@ public final strictfp class RangeTest ex
         assertFalse (range.isMinIncluded());
         assertFalse (range.isEmpty());
 
-        range = new Range<Integer>(Integer.class, 10, 2);
+        range = new Range<Integer>(Integer.class, 10, true, 2, true);
         assertEquals(Integer.valueOf(10), range.getMinValue());
         assertEquals(Integer.valueOf( 2), range.getMaxValue());
         assertTrue (range.isEmpty());
@@ -83,7 +83,7 @@ public final strictfp class RangeTest ex
     @SuppressWarnings({"unchecked", "rawtypes"})
     public void testConstructorErrors00() {
         assumeTrue(Range.class.desiredAssertionStatus());
-        new Range(Double.class, "error", "blast");
+        new Range(Double.class, "error", true, "blast", true);
     }
 
     /**
@@ -98,7 +98,7 @@ public final strictfp class RangeTest ex
     @SuppressWarnings({"unchecked", "rawtypes"})
     public void testConstructorErrors01() {
         assumeTrue(Range.class.desiredAssertionStatus());
-        new Range(String.class, 123.233, 8740.09);
+        new Range(String.class, 123.233, true, 8740.09, true);
     }
 
     /**
@@ -106,7 +106,7 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testContains() {
-        final Range<Integer> range = new Range<Integer>(Integer.class, 3, 5);
+        final Range<Integer> range = new Range<Integer>(Integer.class, 3, true, 5, true);
         assertTrue (range.contains(4));
         assertFalse(range.contains(6));
         assertFalse(range.contains(2));
@@ -142,33 +142,33 @@ public final strictfp class RangeTest ex
     }
 
     /**
-     * Tests the {@link Range#contains(Comparable)} method without lower bound.
+     * Tests the {@link Range#contains(Comparable)} method without lower endpoint.
      */
     @Test
-    public void testContainsNoLowerBound() {
-        final Range<Integer> range = new Range<Integer>(Integer.class, null, 5);
+    public void testContainsNoLowerEndpoint() {
+        final Range<Integer> range = new Range<Integer>(Integer.class, null, true, 5, true);
         assertTrue (range.contains(-555));
         assertTrue (range.contains(5));
         assertFalse(range.contains(6));
     }
 
     /**
-     * Tests the {@link Range#contains(Comparable)} method without upper bound.
+     * Tests the {@link Range#contains(Comparable)} method without upper endpoint.
      */
     @Test
-    public void testContainsNoUpperBound() {
-        final Range<Integer> range = new Range<Integer>(Integer.class, 3, null);
+    public void testContainsNoUpperEndpoint() {
+        final Range<Integer> range = new Range<Integer>(Integer.class, 3, true, null, true);
         assertFalse(range.contains(1));
         assertTrue (range.contains(3));
         assertTrue (range.contains(10000));
     }
 
     /**
-     * Tests the {@link Range#contains(Comparable)} method without lower or upper bounds.
+     * Tests the {@link Range#contains(Comparable)} method without lower or upper endpoints.
      */
     @Test
-    public void testContainsNoBounds() {
-        final Range<Integer> range = new Range<Integer>(Integer.class, null, null);
+    public void testContainsNoEndpoints() {
+        final Range<Integer> range = new Range<Integer>(Integer.class, null, true, null, true);
         assertTrue(range.contains(-55555));
         assertTrue(range.contains(100000));
     }
@@ -178,32 +178,32 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testContainsRange() {
-        final Range<Integer> range  = new Range<Integer>(Integer.class, -10, 10);
-        final Range<Integer> inside = new Range<Integer>(Integer.class,  -5,  5);
+        final Range<Integer> range  = new Range<Integer>(Integer.class, -10, true, 10, true);
+        final Range<Integer> inside = new Range<Integer>(Integer.class,  -5, true,  5, true);
 
         assertTrue(range.contains(inside));
         assertFalse(inside.contains(range));
     }
 
     /**
-     * Tests the {@link Range#contains(Range)} method without lower bound.
+     * Tests the {@link Range#contains(Range)} method without lower endpoint.
      */
     @Test
-    public void testContainsRangeNoLowerBound() {
-        final Range<Integer> range  = new Range<Integer>(Integer.class,  null, 500);
-        final Range<Integer> inside = new Range<Integer>(Integer.class, -2500, 305);
+    public void testContainsRangeNoLowerEndpoint() {
+        final Range<Integer> range  = new Range<Integer>(Integer.class,  null, true, 500, true);
+        final Range<Integer> inside = new Range<Integer>(Integer.class, -2500, true, 305, true);
 
         assertTrue (range.contains(inside));
         assertFalse(inside.contains(range));
     }
 
     /**
-     * Tests the {@link Range#contains(Range)} method without upper bound.
+     * Tests the {@link Range#contains(Range)} method without upper endpoint.
      */
     @Test
-    public void testContainsRangeNoUpperBound() {
-        final Range<Integer> range  = new Range<Integer>(Integer.class, -2500, null);
-        final Range<Integer> inside = new Range<Integer>(Integer.class,    17,  305);
+    public void testContainsRangeNoUpperEndpoint() {
+        final Range<Integer> range  = new Range<Integer>(Integer.class, -2500, true, null, true);
+        final Range<Integer> inside = new Range<Integer>(Integer.class,    17, true,  305, true);
 
         assertTrue(range.contains(inside));
         assertFalse(inside.contains(range));
@@ -214,9 +214,9 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testIntersects() {
-        final Range<Character> range1 = new Range<Character>(Character.class, 'a', 'g');
-        final Range<Character> range2 = new Range<Character>(Character.class, 'c', 'm');
-        final Range<Character> range3 = new Range<Character>(Character.class, 'o', 'z');
+        final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'g', true);
+        final Range<Character> range2 = new Range<Character>(Character.class, 'c', true, 'm', true);
+        final Range<Character> range3 = new Range<Character>(Character.class, 'o', true, 'z', true);
 
         assertTrue (range1.intersects(range2));
         assertTrue (range2.intersects(range1));
@@ -229,8 +229,8 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testIntersection() {
-        final Range<Integer> range1 = new Range<Integer>(Integer.class, 1, 5);
-        final Range<Integer> range2 = new Range<Integer>(Integer.class, 4, 6);
+        final Range<Integer> range1 = new Range<Integer>(Integer.class, 1, true, 5, true);
+        final Range<Integer> range2 = new Range<Integer>(Integer.class, 4, true, 6, true);
 
         final Range<?> intersection = range1.intersect(range2);
         assertEquals(Integer.class, intersection.getElementType());
@@ -243,8 +243,8 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testIntersectionOfNonIntersectingRanges() {
-        final Range<Integer> range1 = new Range<Integer>(Integer.class, 1,  5);
-        final Range<Integer> range2 = new Range<Integer>(Integer.class, 8, 10);
+        final Range<Integer> range1 = new Range<Integer>(Integer.class, 1, true,  5, true);
+        final Range<Integer> range2 = new Range<Integer>(Integer.class, 8, true, 10, true);
 
         final Range<?> intersection = range1.intersect(range2);
         assertEquals(Integer.class, intersection.getElementType());
@@ -256,8 +256,8 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testUnion() {
-        final Range<Character> range1 = new Range<Character>(Character.class, 'a', 'f');
-        final Range<Character> range2 = new Range<Character>(Character.class, 'd', 'h');
+        final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+        final Range<Character> range2 = new Range<Character>(Character.class, 'd', true, 'h', true);
 
         final Range<?> union = range1.union(range2);
         assertFalse(union.isEmpty());
@@ -270,8 +270,8 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testDisjointUnion() {
-        final Range<Character> range1 = new Range<Character>(Character.class, 'a', 'f');
-        final Range<Character> range2 = new Range<Character>(Character.class, 'm', 'v');
+        final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+        final Range<Character> range2 = new Range<Character>(Character.class, 'm', true, 'v', true);
 
         final Range<?> unionRange = range1.union(range2);
         assertFalse(unionRange.isEmpty());
@@ -284,8 +284,8 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testSubtract() {
-        final Range<Integer> range1 = new Range<Integer>(Integer.class, 10, 40);
-        final Range<Integer> range2 = new Range<Integer>(Integer.class, 20, 25);
+        final Range<Integer> range1 = new Range<Integer>(Integer.class, 10, true, 40, true);
+        final Range<Integer> range2 = new Range<Integer>(Integer.class, 20, true, 25, true);
         final Range<Integer>[] subtract = range1.subtract(range2);
         assertEquals(2, subtract.length);
         assertEquals(new Range<Integer>(Integer.class, 10, true,  20, false), subtract[0]);
@@ -293,25 +293,38 @@ public final strictfp class RangeTest ex
     }
 
     /**
+     * Tests the {@link Range#toString()} method.
+     */
+    @Test
+    public void testToString() {
+        assertEquals("{}",        new Range<Integer>(Integer.class, 10, false, 10, false).toString());
+        assertEquals("{10}",      new Range<Integer>(Integer.class, 10, true,  10, true ).toString());
+        assertEquals("[10 … 20]", new Range<Integer>(Integer.class, 10, true,  20, true ).toString());
+        assertEquals("(10 … 20)", new Range<Integer>(Integer.class, 10, false, 20, false).toString());
+        assertEquals("[10 … 20)", new Range<Integer>(Integer.class, 10, true,  20, false).toString());
+        assertEquals("(10 … 20]", new Range<Integer>(Integer.class, 10, false, 20, true ).toString());
+    }
+
+    /**
      * Tests the {@link Range#equals(Object)} method.
      */
     @Test
     public void testEquality() {
         // Positive test - success case
-        final Range<Character> range1 = new Range<Character>(Character.class, 'a', 'f');
-        final Range<Character> range2 = new Range<Character>(Character.class, 'a', 'f');
+        final Range<Character> range1 = new Range<Character>(Character.class, 'a', true, 'f', true);
+        final Range<Character> range2 = new Range<Character>(Character.class, 'a', true, 'f', true);
         assertTrue(range1.equals(range2));
 
         // Positive test - failure case
-        final Range<Character> range3 = new Range<Character>(Character.class, 'a', 'g');
+        final Range<Character> range3 = new Range<Character>(Character.class, 'a', true, 'g', true);
         assertFalse(range1.equals(range3));
 
         // Failure due to type incompatibility
-        final Range<String> range4 = new Range<String>(String.class, "a", "g");
+        final Range<String> range4 = new Range<String>(String.class, "a", true, "g", true);
         assertFalse(range3.equals(range4));
 
-        final Range<Character> range5 = new Range<Character>(Character.class, 'g', 'a');
-        final Range<Character> range6 = new Range<Character>(Character.class, 'g', 'a');
+        final Range<Character> range5 = new Range<Character>(Character.class, 'g', true, 'a', true);
+        final Range<Character> range6 = new Range<Character>(Character.class, 'g', true, 'a', true);
         assertTrue(range5.isEmpty());
         assertTrue(range6.isEmpty());
         assertTrue(range5.equals(range6));
@@ -322,7 +335,7 @@ public final strictfp class RangeTest ex
      */
     @Test
     public void testSerialization() {
-        final Range<Integer> range  = new Range<Integer>(Integer.class, -10, 10);
+        final Range<Integer> range  = new Range<Integer>(Integer.class, -10, true, 10, true);
         assertNotSame(range, assertSerializedEquals(range));
     }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestCase.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestCase.java Fri Feb 22 11:55:18 2013
@@ -24,10 +24,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
-
 import org.apache.sis.util.logging.Logging;
-
-import org.junit.After;
 import org.junit.runner.RunWith;
 
 import static org.apache.sis.test.TestConfiguration.VERBOSE_OUTPUT_KEY;
@@ -37,27 +34,20 @@ import static org.apache.sis.test.TestCo
 /**
  * Base class of Apache SIS tests (except the ones that extend GeoAPI tests).
  * This base class provides an {@link #out} field that sub-classes can use
- * <strong>if non-null</strong> for printing debugging information. This {@code out}
- * field shall be used instead of {@link System#out} for the following reasons:
+ * for printing debugging information. This {@code out} field shall be used
+ * instead of {@link System#out} for the following reasons:
  *
  * <ul>
- *   <li>It is {@code null} by default and enabled only if a system property is set as
- *     described in the {@linkplain org.apache.sis.test package javadoc}. This allows more
- *     quiet (and sometime faster) Maven executions for those who are not SIS developers.</li>
- *   <li>The outputs are collected and printed only after each test completion.
+ *   <li>By default, the contents sent to {@code out} are ignored for successful tests
+ *     and printed only when a test fail. This avoid polluting the console output during
+ *     successful Maven builds, and print only the information related to failed tests.</li>
+ *   <li>Printing information for all tests can be enabled if a system property is set as
+ *     described in the {@linkplain org.apache.sis.test package javadoc}.</li>
+ *   <li>The outputs are collected and printed only after test completion.
  *     This avoid the problem of logging messages interleaved with the output.
  *     If such interleaving is really wanted, then use the logging framework instead.</li>
  * </ul>
  *
- * Usage example:
- *
- * {@preformat java
- *     if (out != null) {
- *         // Performs here some potentially costly calculation to be printed.
- *         out.println("Write here some information of particular interest.");
- *     }
- * }
- *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.16)
  * @version 0.3
@@ -82,11 +72,12 @@ public abstract strictfp class TestCase 
     public static final boolean PENDING_NEXT_GEOAPI_RELEASE = false;
 
     /**
-     * If non-null, the output writer where to print debugging information.
-     * This field is non-null if the {@value org.apache.sis.test.TestConfiguration#VERBOSE_OUTPUT_KEY}
-     * system property is set to {@code true}. This writer will use the system default encoding, unless
-     * the {@value org.apache.sis.test.TestConfiguration#OUTPUT_ENCODING_KEY} system property has been
-     * set to a different value.
+     * The output writer where to print debugging information (never {@code null}).
+     * Texts sent to this printer will be show only if the test fails, or if the
+     * {@value org.apache.sis.test.TestConfiguration#VERBOSE_OUTPUT_KEY} system property
+     * is set to {@code true}. This writer will use the system default encoding, unless
+     * the {@value org.apache.sis.test.TestConfiguration#OUTPUT_ENCODING_KEY} system
+     * property has been set to a different value.
      *
      * @see org.apache.sis.test
      * @see #flushVerboseOutput()
@@ -94,20 +85,22 @@ public abstract strictfp class TestCase 
     public static final PrintWriter out;
 
     /**
-     * The buffer which is backing the {@linkplain #out} stream, or {@code null} if none.
+     * The buffer which is backing the {@linkplain #out} stream.
      */
     private static final StringWriter buffer;
 
     /**
+     * {@code true} if the {@value org.apache.sis.test.TestConfiguration#VERBOSE_OUTPUT_KEY}
+     * system property is set to {@code true}.
+     */
+    static final boolean verbose;
+
+    /**
      * Sets the {@link #out} writer and its underlying {@link #buffer}.
      */
     static {
-        if (Boolean.getBoolean(VERBOSE_OUTPUT_KEY)) {
-            out = new PrintWriter(buffer = new StringWriter());
-        } else {
-            buffer = null;
-            out = null;
-        }
+        verbose = Boolean.getBoolean(VERBOSE_OUTPUT_KEY);
+        out = new PrintWriter(buffer = new StringWriter());
     }
 
     /**
@@ -144,21 +137,29 @@ public abstract strictfp class TestCase 
     }
 
     /**
-     * If verbose output is enabled, flushes the {@link #out} stream after each test.
-     * The stream will be flushed to the {@linkplain System#console() console} if
-     * available, or to the {@linkplain System#out standard output stream} otherwise.
+     * Invoked by {@link TestRunner} in order to clear the buffer before a new test begin.
+     * This is necessary when the previous test succeeded and the {@link #verbose} flag is
+     * {@code false}, since the {@link #flushOutput()} method has not been invoked in such
+     * case.
+     */
+    static void clearBuffer() {
+        synchronized (buffer) { // This is the lock used by the 'out' PrintWriter.
+            out.flush();
+            buffer.getBuffer().setLength(0);
+        }
+    }
+
+    /**
+     * Invoked by {@link TestRunner} in order to flush the {@link #out} stream.
+     * The stream content will be flushed to the {@linkplain System#console() console}
+     * if available, or to the {@linkplain System#out standard output stream} otherwise.
+     * This method clears the stream buffer.
      *
-     * <p>This method is invoked automatically by JUnit and doesn't need to be invoked
-     * explicitely, unless the developer wants to flush the output at some specific
-     * point.</p>
+     * @param success {@code true} if this method is invoked on build success,
      */
-    @After
-    public void flushVerboseOutput() {
+    static void flushOutput() {
         System.out.flush();
         System.err.flush();
-        if (out == null) {
-            return;
-        }
         synchronized (buffer) { // This is the lock used by the 'out' PrintWriter.
             out.flush();
             /*

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestConfiguration.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestConfiguration.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestConfiguration.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestConfiguration.java Fri Feb 22 11:55:18 2013
@@ -31,7 +31,7 @@ public final strictfp class TestConfigur
     /**
      * The {@value} system property for enabling verbose outputs.
      * If this {@linkplain System#getProperties() system property} is set to {@code true},
-     * then the {@link TestCase#out} field will be set to a non-null value.
+     * then the content sent to the {@link TestCase#out} field will be printed after each test.
      */
     public static final String VERBOSE_OUTPUT_KEY = "org.apache.sis.test.verbose";
 

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java Fri Feb 22 11:55:18 2013
@@ -93,16 +93,49 @@ public final class TestRunner extends Bl
      * The listener to use for keeping trace of methods that failed.
      */
     final RunListener listener = new RunListener() {
+        /**
+         * Clears the buffer if it was not already done by {@link #testFinished(Description)}.
+         */
+        @Override
+        public void testStarted(final Description description) {
+            if (!TestCase.verbose) {
+                TestCase.clearBuffer();
+            }
+        }
+
+        /**
+         * Prints output only in verbose mode.
+         * Otherwise silently discard the output.
+         */
+        @Override
+        public void testFinished(final Description description) {
+            if (TestCase.verbose) {
+                TestCase.flushOutput();
+            }
+        }
+
+        /**
+         * Remember that a test failed, and prints output if it was not already done
+         */
         @Override
         public void testFailure(final Failure failure) {
             addDependencyFailure(failure.getDescription().getMethodName());
+            if (!TestCase.verbose) {
+                TestCase.flushOutput();
+            }
         }
 
+        /**
+         * Silently record skipped test as if it failed, without printing the output.
+         */
         @Override
         public void testAssumptionFailure(final Failure failure) {
             addDependencyFailure(failure.getDescription().getMethodName());
         }
 
+        /**
+         * Silently record ignored test as if it failed, without printing the output.
+         */
         @Override
         public void testIgnored(final Description description) {
             addDependencyFailure(description.getMethodName());
@@ -110,13 +143,13 @@ public final class TestRunner extends Bl
     };
 
     /**
-     * Creates a {@code Corollaries} to run {@code klass}.
+     * Creates a new test runner for the given class.
      *
-     * @param  klass The class to run.
+     * @param  testClass The class to run.
      * @throws InitializationError If the test class is malformed.
      */
-    public TestRunner(final Class<?> klass) throws InitializationError {
-        super(klass);
+    public TestRunner(final Class<?> testClass) throws InitializationError {
+        super(testClass);
     }
 
     /**
@@ -253,7 +286,7 @@ public final class TestRunner extends Bl
 
     /**
      * Returns the {@link Statement} which will execute all the tests in the class given
-     * to the constructor.
+     * to the {@linkplain #TestRunner(Class) constructor}.
      *
      * @param  notifier The object to notify about test results.
      * @return The statement to execute for running the tests.

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java Fri Feb 22 11:55:18 2013
@@ -20,6 +20,7 @@ import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.Iterator;
+import java.util.Random;
 import java.util.concurrent.Callable;
 import java.io.PrintWriter;
 import java.lang.reflect.UndeclaredThrowableException;
@@ -79,14 +80,16 @@ public final strictfp class TestUtilitie
     }
 
     /**
-     * Prints the given title to {@link TestCase#out} in a box. This method is invoked for
-     * writing a clear visual separator between the verbose output of different test cases.
+     * If verbose output are enabled, prints the given title to {@link TestCase#out} in a box.
+     * This method is invoked for writing a clear visual separator between the verbose output
+     * of different test cases. This method does nothing if verbose output is not enabled,
+     * because only the output of failed tests should be printed in such case.
      *
      * @param title The title to write.
      */
     public static void printSeparator(final String title) {
-        final PrintWriter out = TestCase.out;
-        if (out != null) {
+        if (TestCase.verbose) {
+            final PrintWriter out = TestCase.out;
             final boolean isAnsiSupported = X364.isAnsiSupported();
             if (isAnsiSupported) {
                 out.print(X364.FOREGROUND_CYAN.sequence());
@@ -114,6 +117,38 @@ public final strictfp class TestUtilitie
     }
 
     /**
+     * Returns a new random number generator with a random seed. This method logs the seed value
+     * to the {@link TestCase#out} stream, in order to allow reproducing a test in case of failure.
+     *
+     * <p>This method doesn't need to be used in every cases. For example test cases using
+     * {@link Random#nextGaussian()} should create their own random numbers generator with
+     * the {@link Random#Random(long)} constructor instead
+     * (see {@link org.apache.sis.math.StatisticsTest} for more explanation).
+     * Or test cases that are mostly insensitive to the exact sequence of numbers
+     * can use the {@link Random#Random()} constructor instead.</p>
+     *
+     * <p>This method is rather for testing relatively complex code which are likely to behave
+     * differently depending on the exact sequence of numbers. We want to use random sequence
+     * of numbers in order to test the code in a wider range of scenarios. However in case of
+     * test failure, we need to know the <cite>seed</cite> which has been used in order to allow
+     * the developer to reproduce the test with the exact same sequence of numbers.
+     * Using this method, the seed can be retrieved in the messages sent to the output stream.</p>
+     *
+     * @param  testMethod The name of the method which need a random number generator.
+     * @return A new random number generator initialized with a random seed.
+     */
+    public static Random createRandomNumberGenerator(final String testMethod) {
+        final long seed = Math.round(Math.random() * (1L << 48));
+        final PrintWriter out = TestCase.out;
+        out.print("Random number generator for ");
+        out.print(testMethod);
+        out.print(" created with seed ");
+        out.print(seed);
+        out.println('.');
+        return new Random(seed);
+    }
+
+    /**
      * Parses the date for the given string using the {@code "yyyy-MM-dd HH:mm:ss"} pattern
      * in UTC timezone.
      *

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/package-info.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/package-info.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/package-info.java Fri Feb 22 11:55:18 2013
@@ -17,7 +17,7 @@
 
 /**
  * Tools for SIS tests. This package defines a base class, {@link org.apache.sis.test.TestCase},
- * which is extended directly or indirectly by many (but not all) SIS tests.
+ * which is extended directly or indirectly by most (but not all) SIS tests.
  * This package defines also an {@link org.apache.sis.test.Assert} class which extend the GeoAPI
  * {@link org.opengis.test.Assert} (which itself extends the JUnit {@link org.junit.Assert} class)
  * with the addition of assertion methods commonly used in SIS tests.

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Fri Feb 22 11:55:18 2013
@@ -87,6 +87,7 @@ import org.junit.runners.Suite;
     org.apache.sis.io.WordWrapWithLineSeparatorTest.class,
     org.apache.sis.io.TableAppenderTest.class,
     org.apache.sis.util.collection.TreeTableFormatTest.class,
+    org.apache.sis.util.collection.RangeSetTest.class,
 
     // XML most basic types.
     org.apache.sis.xml.XLinkTest.class,

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java Fri Feb 22 11:55:18 2013
@@ -67,4 +67,116 @@ public final strictfp class ArraysExtTes
         final int[] union = ArraysExt.unionOfSorted(array1, array2);
         assertArrayEquals(new int[] {1, 2, 3, 4, 6, 9, 12, 13, 18, 22}, union);
     }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(char[], boolean)}.
+     */
+    @Test
+    public void testIsSortedCharacters() {
+        final char[] array = new char[] {1, 4, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[2] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[2] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(byte[], boolean)}.
+     */
+    @Test
+    public void testIsSortedBytes() {
+        final byte[] array = new byte[] {1, 4, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[2] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[2] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(short[], boolean)}.
+     */
+    @Test
+    public void testIsSortedShorts() {
+        final short[] array = new short[] {1, 4, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[2] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[2] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(int[], boolean)}.
+     */
+    @Test
+    public void testIsSortedIntegers() {
+        final int[] array = new int[] {1, 4, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[2] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[2] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(long[], boolean)}.
+     */
+    @Test
+    public void testIsSortedLongs() {
+        final long[] array = new long[] {1, 4, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[2] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[2] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(float[], boolean)}.
+     */
+    @Test
+    public void testIsSortedFloats() {
+        final float[] array = new float[] {1, Float.NaN, 4, Float.NaN, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[3] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[3] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(double[], boolean)}.
+     */
+    @Test
+    public void testIsSortedDoubles() {
+        final double[] array = new double[] {1, Double.NaN, 4, Double.NaN, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[3] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[3] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
+
+    /**
+     * Tests {@link ArraysExt#isSorted(Comparable[], boolean)}.
+     */
+    @Test
+    public void testIsSortedComparables() {
+        final Integer[] array = new Integer[] {1, null, 4, null, 7, 9};
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertTrue (ArraysExt.isSorted(array, true));  array[3] = 4;
+        assertTrue (ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));  array[3] = 3;
+        assertFalse(ArraysExt.isSorted(array, false));
+        assertFalse(ArraysExt.isSorted(array, true));
+    }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java Fri Feb 22 11:55:18 2013
@@ -31,6 +31,7 @@ import org.apache.sis.test.TestUtilities
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.Performance;
 import org.junit.Test;
 
 import static java.lang.StrictMath.*;
@@ -203,6 +204,7 @@ public final strictfp class CacheTest ex
      * @throws InterruptedException If the test has been interrupted.
      */
     @Test
+    @Performance
     @DependsOnMethod("testThreadBlocking")
     public void stress() throws InterruptedException {
         final int count = 10000;
@@ -269,34 +271,31 @@ public final strictfp class CacheTest ex
          * properly tuned, most values should be non-zero.
          */
         final PrintWriter out = CacheTest.out;
-        if (out != null) {
-            TestUtilities.printSeparator("CacheTest.stress() - testing concurrent accesses");
-            out.print("There is "); out.print(threads.length); out.print(" threads, each of them"
-                    + " fetching or creating "); out.print(count); out.println(" values.");
-            out.println("Number of times a new value has been created, for each thread:");
-            for (int i=0; i<threads.length;) {
-                final String n = String.valueOf(threads[i++].addCount);
-                out.print(CharSequences.spaces(6 - n.length()));
-                out.print(n);
-                if ((i % 10) == 0) {
-                    out.println();
-                }
+        TestUtilities.printSeparator("CacheTest.stress() - testing concurrent accesses");
+        out.print("There is "); out.print(threads.length); out.print(" threads, each of them"
+                + " fetching or creating "); out.print(count); out.println(" values.");
+        out.println("Number of times a new value has been created, for each thread:");
+        for (int i=0; i<threads.length;) {
+            final String n = String.valueOf(threads[i++].addCount);
+            out.print(CharSequences.spaces(6 - n.length()));
+            out.print(n);
+            if ((i % 10) == 0) {
+                out.println();
             }
-            out.println();
-            out.println("Now observe how the background thread cleans the cache.");
-            long time = System.nanoTime();
-            for (int i=0; i<10; i++) {
-                final long t = System.nanoTime();
-                out.printf("Cache size: %4d (after %3d ms)%n", cache.size(), round((t - time) / 1E+6));
-                time = t;
-                Thread.sleep(250);
-                if (i >= 2) {
-                    System.gc();
-                }
+        }
+        out.println();
+        out.println("Now observe how the background thread cleans the cache.");
+        long time = System.nanoTime();
+        for (int i=0; i<10; i++) {
+            final long t = System.nanoTime();
+            out.printf("Cache size: %4d (after %3d ms)%n", cache.size(), round((t - time) / 1E+6));
+            time = t;
+            Thread.sleep(250);
+            if (i >= 2) {
+                System.gc();
             }
-            out.println();
-            out.flush();
         }
+        out.println();
         /*
          * Gets the statistics of key values after garbage collection. The mean value should
          * be higher, because oldest values (which should have been garbage collected first)
@@ -304,18 +303,15 @@ public final strictfp class CacheTest ex
          * before to perform the actual check in order to allow the developer to have more
          * information in case of failure.
          */
-        System.gc();
         final Statistics afterGC = validateStressEntries("After GC", cache);
-        if (out != null) {
-            out.println("Statistics on the keys before and after garbage collection.");
-            out.println("The minimum and the mean values should be greater after GC.");
-            final StatisticsFormat format = StatisticsFormat.getInstance();
-            format.setBorderWidth(1);
-            try {
-                format.format(new Statistics[] {beforeGC, afterGC}, out);
-            } catch (IOException e) {
-                throw new AssertionError(e);
-            }
+        out.println("Statistics on the keys before and after garbage collection.");
+        out.println("The minimum and the mean values should be greater after GC.");
+        final StatisticsFormat format = StatisticsFormat.getInstance();
+        format.setBorderWidth(1);
+        try {
+            format.format(new Statistics[] {beforeGC, afterGC}, out);
+        } catch (IOException e) {
+            throw new AssertionError(e);
         }
         assertTrue("Mean key value should be greater after garbage collection.", afterGC.mean() >= beforeGC.mean());
     }

Modified: sis/trunk/src/main/docbook/fr.xml
URL: http://svn.apache.org/viewvc/sis/trunk/src/main/docbook/fr.xml?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/src/main/docbook/fr.xml (original)
+++ sis/trunk/src/main/docbook/fr.xml Fri Feb 22 11:55:18 2013
@@ -33,5 +33,6 @@
   <xi:include href="fr/XML.xml"/>
   <xi:include href="fr/utility.xml"/>
   <xi:include href="fr/geometry.xml"/>
+  <xi:include href="fr/coverage.xml"/>
 
 </book>



Mime
View raw message