-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from davidmoten/master
Update with DaveMoten last commits
- Loading branch information
Showing
9 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/java/com/github/davidmoten/rtree/ComparatorsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.davidmoten.rtree; | ||
|
||
import org.junit.Test; | ||
|
||
import com.github.davidmoten.util.TestingUtil; | ||
|
||
public class ComparatorsTest { | ||
|
||
@Test | ||
public void testConstructorIsPrivate() { | ||
TestingUtil.callConstructorAndCheckIsPrivate(Comparators.class); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/test/java/com/github/davidmoten/rtree/FunctionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.davidmoten.rtree; | ||
|
||
import org.junit.Test; | ||
|
||
import com.github.davidmoten.util.TestingUtil; | ||
|
||
public class FunctionsTest { | ||
|
||
@Test | ||
public void testConstructorIsPrivate() { | ||
TestingUtil.callConstructorAndCheckIsPrivate(Functions.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.github.davidmoten.util; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Modifier; | ||
|
||
/** | ||
* Utility methods for unit tests. | ||
* | ||
* @author dave | ||
* | ||
*/ | ||
public class TestingUtil { | ||
|
||
/** | ||
* Checks that a class has a no-argument private constructor and calls that | ||
* constructor to instantiate the class. | ||
* | ||
* @param cls | ||
*/ | ||
public static <T> void callConstructorAndCheckIsPrivate(Class<T> cls) { | ||
Constructor<T> constructor; | ||
try { | ||
constructor = cls.getDeclaredConstructor(); | ||
} catch (NoSuchMethodException e1) { | ||
throw new RuntimeException(e1); | ||
} catch (SecurityException e1) { | ||
throw new RuntimeException(e1); | ||
} | ||
assertTrue(Modifier.isPrivate(constructor.getModifiers())); | ||
constructor.setAccessible(true); | ||
try { | ||
constructor.newInstance(); | ||
} catch (InstantiationException e) { | ||
throw new RuntimeException(e); | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} catch (IllegalArgumentException e) { | ||
throw new RuntimeException(e); | ||
} catch (InvocationTargetException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |