sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1554591 - in /sis/branches/JDK7/core: sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
Date Tue, 31 Dec 2013 23:06:46 GMT
Author: desruisseaux
Date: Tue Dec 31 23:06:45 2013
New Revision: 1554591

URL: http://svn.apache.org/r1554591
Log:
Added tests.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1554591&r1=1554590&r2=1554591&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] Tue Dec 31 23:06:45 2013
@@ -57,6 +57,8 @@ public final strictfp class BursaWolfPar
         bursaWolf.rZ = 0.554;
         bursaWolf.dS = 0.219;
         bursaWolf.verify();
+        assertFalse("isIdentity",    bursaWolf.isIdentity());
+        assertFalse("isTranslation", bursaWolf.isTranslation());
         return bursaWolf;
     }
 
@@ -75,6 +77,24 @@ public final strictfp class BursaWolfPar
         bursaWolf.rZ =    0.3898;
         bursaWolf.dS =   -0.3143;
         bursaWolf.verify();
+        assertFalse("isIdentity",    bursaWolf.isIdentity());
+        assertFalse("isTranslation", bursaWolf.isTranslation());
+        return bursaWolf;
+    }
+
+    /**
+     * Returns the parameters for the <cite>NTF to WGS 84 (1)</cite> transformation
(EPSG:1193).
+     * Area of validity is France - onshore - mainland and Corsica.
+     * This transformation uses only translation parameters.
+     */
+    static BursaWolfParameters createNTF_to_WGS84() {
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, Extents.WORLD);
+        bursaWolf.tX = -168;
+        bursaWolf.tY =  -60;
+        bursaWolf.tZ =  320;
+        bursaWolf.verify();
+        assertFalse("isIdentity",    bursaWolf.isIdentity());
+        assertTrue ("isTranslation", bursaWolf.isTranslation());
         return bursaWolf;
     }
 
@@ -112,6 +132,15 @@ public final strictfp class BursaWolfPar
         final MatrixSIS target  = Matrices.create(4, 1, new double[] {3657660.78, 255778.43,
5201387.75, 1});
         assertMatrixEquals("toWGS84", target, toWGS84.multiply(source), 0.01);
         assertMatrixEquals("toWGS72", source, toWGS72.multiply(target), 0.01);
+        /*
+         * Tests the optimized path for translation-only parameters.
+         * Matrices having only translation terms are much easier to predict.
+         */
+        assertMatrixEquals("Translation only", new Matrix4(
+                1, 0, 0, -168,
+                0, 1, 0,  -60,
+                0, 0, 1,  320,
+                0, 0, 0,    1), getPositionVectorTransformation(createNTF_to_WGS84()), 0);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1554591&r1=1554590&r2=1554591&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
[UTF-8] Tue Dec 31 23:06:45 2013
@@ -73,6 +73,8 @@ public final strictfp class CharSequence
         assertEquals(0, count(new StringBuilder("An ordinary sentence."),   '-'));
         assertEquals(4, count(new StringBuilder("- this one has -dashs--"), '-'));
         assertEquals(2, count(new StringBuilder("An ordinary sentence."),  "en"));
+        assertEquals(0, count("",   '-'));
+        assertEquals(0, count(null, '-'));
     }
 
     /**
@@ -97,6 +99,8 @@ public final strictfp class CharSequence
             assertEquals(12, indexOf(string, "sentence.", 0, length));
             assertEquals(-1, indexOf(string, "sentence;", 0, length));
         }
+        assertEquals(-1, indexOf("",   "An", 0, 0));
+        assertEquals(-1, indexOf(null, "An", 0, 0));
     }
 
     /**
@@ -130,6 +134,8 @@ public final strictfp class CharSequence
             assertEquals(13,           indexOf(string, 'e', 0, length));
             assertEquals(19,       lastIndexOf(string, 'e', 0, length));
         }
+        assertEquals(-1, indexOf("",   'A', 0, 0));
+        assertEquals(-1, indexOf(null, 'A', 0, 0));
     }
 
     /**
@@ -155,6 +161,8 @@ public final strictfp class CharSequence
     public void testSplit() {
         assertArrayEquals(new String[] {"lundi", "mardi", "", "mercredi"}, split("lundi ,
mardi,,mercredi ", ','));
         assertArrayEquals(new String[] {"lundi", "mardi", "", "mercredi"}, split("lundi \n
mardi\r\n\nmercredi ", '\n'));
+        assertArrayEquals(new String[] {""}, split("",   ','));
+        assertArrayEquals(new String[] {},   split(null, ','));
     }
 
     /**
@@ -164,9 +172,9 @@ public final strictfp class CharSequence
     @DependsOnMethod("testIndexOfChar")
     public void testSplitOnEOL() {
         final CharSequence[] splitted = splitOnEOL("\nOne\r\nTwo\rThree \rFour\n Five\n\r
Six \n");
-        assertArrayEquals(new String[] {
-            "", "One", "Two", "Three ", "Four", " Five", "", " Six ", ""
-        }, splitted);
+        assertArrayEquals(new String[] {"", "One", "Two", "Three ", "Four", " Five", "",
" Six ", ""}, splitted);
+        assertArrayEquals(new String[] {""}, splitOnEOL(""));
+        assertArrayEquals(new String[] {},   splitOnEOL(null));
     }
 
     /**
@@ -230,6 +238,7 @@ public final strictfp class CharSequence
     public void testToString() {
         assertEquals("4, 8, 12, 9", CharSequences.toString(Arrays.asList(4, 8, 12, 9), ",
"));
         assertSame  ("singleton",   CharSequences.toString(Arrays.asList("singleton"), ",
"));
+        assertNull  (               CharSequences.toString(null, ", "));
     }
 
     /**
@@ -240,6 +249,7 @@ public final strictfp class CharSequence
         final String metre = "metre";
         assertSame  (metre, toASCII(metre));
         assertEquals(metre, toASCII("mètre").toString());
+        assertNull  (       toASCII(null));
     }
 
     /**
@@ -251,6 +261,8 @@ public final strictfp class CharSequence
         assertEquals("A text.", trimWhitespaces((CharSequence) "  A text. "));
         assertEquals("",        trimWhitespaces(               "          "));
         assertEquals("",        trimWhitespaces((CharSequence) "          "));
+        assertNull  (           trimWhitespaces((CharSequence) null));
+        assertNull  (           trimWhitespaces((String)       null));
     }
 
     /**
@@ -263,6 +275,7 @@ public final strictfp class CharSequence
         assertEquals("4",    trimFractionalPart("4.0"));
         assertEquals("4",    trimFractionalPart("4.00"));
         assertEquals("4.10", trimFractionalPart("4.10"));
+        assertNull  (        trimFractionalPart(null));
     }
 
     /**
@@ -272,6 +285,7 @@ public final strictfp class CharSequence
     public void testShortSentence() {
         assertEquals("This sentence given (…) in a short name.", String.valueOf(
                 shortSentence("This sentence given as an example is way too long to be included
in a short name.", 40)));
+        assertNull(shortSentence(null, 40));
     }
 
     /**
@@ -279,8 +293,8 @@ public final strictfp class CharSequence
      */
     @Test
     public void testUpperCaseToSentence() {
-        final CharSequence convert = upperCaseToSentence("HALF_DOWN");
-        assertEquals("Half down", convert.toString());
+        assertEquals("Half down", upperCaseToSentence("HALF_DOWN").toString());
+        assertNull(upperCaseToSentence(null));
     }
 
     /**
@@ -290,6 +304,7 @@ public final strictfp class CharSequence
     public void testCamelCaseToWords() {
         final CharSequence convert = camelCaseToWords("PixelInterleavedSampleModel", true);
         assertEquals("Pixel interleaved sample model", convert.toString());
+        assertNull(camelCaseToWords(null, true));
     }
 
     /**
@@ -303,6 +318,7 @@ public final strictfp class CharSequence
         assertEquals("NE",  camelCaseToAcronym("North-East").toString());
         assertEquals("NE",  camelCaseToAcronym("NORTH_EAST").toString());
         assertEquals("NE",  camelCaseToAcronym("northEast").toString());
+        assertNull(camelCaseToAcronym(null));
     }
 
     /**
@@ -351,6 +367,7 @@ public final strictfp class CharSequence
         assertTrue(isAcronymForWords("versionhistory",            "[Version History]"));
         assertTrue(isAcronymForWords("change",                    "[Change]"));
         assertTrue(isAcronymForWords("deprecation",               "[Deprecation]"));
+        assertFalse(isAcronymForWords(null,                       "[Deprecation]"));
         /*
          * It is important the the following is not recognized as an acronym,
          * otherwise it leads to a confusion in DirectEpsgFactory.
@@ -365,6 +382,7 @@ public final strictfp class CharSequence
     public void testIsUnicodeIdentifier() {
         assertTrue ("A123", isUnicodeIdentifier("A123"));
         assertFalse("123A", isUnicodeIdentifier("123A"));
+        assertFalse(        isUnicodeIdentifier(null));
     }
 
     /**
@@ -385,6 +403,8 @@ public final strictfp class CharSequence
         assertTrue (equalsIgnoreCase("Test", "TEST"));
         assertTrue (equalsIgnoreCase("Test", new StringBuilder("TEST")));
         assertFalse(equalsIgnoreCase("Test1", "Test2"));
+        assertFalse(equalsIgnoreCase(null,    "Test2"));
+        assertFalse(equalsIgnoreCase("Test1", null));
     }
 
     /**
@@ -398,6 +418,7 @@ public final strictfp class CharSequence
         assertFalse(equalsFiltered("UTF-8", " utf 16", Characters.Filter.LETTERS_AND_DIGITS,
true));
         assertTrue (equalsFiltered("WGS84", "WGS_84",  Characters.Filter.LETTERS_AND_DIGITS,
true));
         assertFalse(equalsFiltered("WGS84", "WGS_84",  Characters.Filter.UNICODE_IDENTIFIER,
true));
+        assertFalse(equalsFiltered(null,    "WGS_84",  Characters.Filter.UNICODE_IDENTIFIER,
true));
     }
 
     /**
@@ -407,6 +428,8 @@ public final strictfp class CharSequence
     public void testEquals() {
         assertTrue (CharSequences.equals("Test", new StringBuilder("Test")));
         assertFalse(CharSequences.equals("Test1", "Test2"));
+        assertFalse(CharSequences.equals(null,    "Test2"));
+        assertFalse(CharSequences.equals("Test1", null));
     }
 
     /**
@@ -472,6 +495,7 @@ public final strictfp class CharSequence
         assertSame(text, replace(text, "pineapple", "orange"));
         assertEquals("One orange, two orange oranges", replace(text, "apple", "orange").toString());
         assertEquals("One apple, two apple apples",    replace(text, "orange", "apple").toString());
+        assertNull(replace(null, "orange", "apple"));
     }
 
     /**



Mime
View raw message