use of com.revolsys.junit.RunnableTestCase in project com.revolsys.open by revolsys.
the class RecordIoTestSuite method addGeometryTestSuites.
public static void addGeometryTestSuites(final TestSuite suite, final String namePrefix, final GeometryTestFunction<GeometryFactory, Geometry, DataType> testFunction) {
final List<DataType> geometryDataTypes = Arrays.asList(DataTypes.POINT, DataTypes.LINE_STRING, DataTypes.POLYGON, DataTypes.MULTI_POINT, DataTypes.MULTI_LINE_STRING, DataTypes.MULTI_POLYGON);
for (final DataType dataType : geometryDataTypes) {
final TestSuite dataTypeSuite = new TestSuite(namePrefix + " " + dataType.toString());
suite.addTest(dataTypeSuite);
for (int axisCount = 2; axisCount < 5; axisCount++) {
int maxGeometryCount = 1;
if (dataType.toString().startsWith("Multi")) {
maxGeometryCount = 3;
}
for (int geometryCount = 0; geometryCount <= maxGeometryCount; geometryCount++) {
int maxVertexCount = 2;
if (dataType.toString().contains("Line")) {
maxVertexCount = 4;
}
for (int vertexCount = 2; vertexCount <= maxVertexCount; vertexCount++) {
int maxRingCount = 0;
if (dataType.toString().contains("Polygon")) {
maxRingCount = 3;
}
if (geometryCount == 0) {
maxRingCount = 0;
}
for (int ringCount = 0; ringCount <= maxRingCount; ringCount++) {
final GeometryFactory geometryFactory = GeometryFactory.floating(4326, axisCount);
double delta = 1.0;
if (geometryFactory.isProjected()) {
delta = 1000.0;
}
final Geometry geometry = GeometryTestUtil.geometry(geometryFactory, dataType, geometryCount, ringCount, vertexCount, delta);
String name = namePrefix + " " + dataType + " A=" + axisCount + " G=" + geometryCount;
if (maxVertexCount > 2) {
name += " V=" + vertexCount;
}
if (maxRingCount > 2) {
name += " R=" + ringCount;
}
final TestCase testCase = new RunnableTestCase(name, () -> testFunction.apply(geometryFactory, geometry, dataType));
dataTypeSuite.addTest(testCase);
}
}
}
}
}
}
Aggregations