org.opengis.test.Assert.assertBetween()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中org.opengis.test.Assert.assertBetween()方法的一些代码示例,展示了Assert.assertBetween()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertBetween()方法的具体详情如下:
包路径:org.opengis.test.Assert
类名称:Assert
方法名:assertBetween

Assert.assertBetween介绍

[英]Asserts that the given value is inside the given range. If the given value is Double#NaN, then this test passes silently. This method does not test the validity of the given [ minimum … maximum] range.
[中]断言给定值在给定范围内。如果给定的值是Double#NaN,则此测试将以静默方式通过。此方法不测试给定[最小…最大]范围的有效性。

代码示例

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the geographic bounding box.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final GeographicBoundingBox object) {
  if (object == null) {
    return;
  }
  final double west  = object.getWestBoundLongitude();
  final double east  = object.getEastBoundLongitude();
  final double south = object.getSouthBoundLatitude();
  final double north = object.getNorthBoundLatitude();
  assertBetween("GeographicBoundingBox: illegal west bound.",  -180, +180, west);
  assertBetween("GeographicBoundingBox: illegal east bound.",  -180, +180, east);
  assertBetween("GeographicBoundingBox: illegal south bound.", -90,   +90, south);
  assertBetween("GeographicBoundingBox: illegal north bound.", -90,   +90, north);
  assertFalse("GeographicBoundingBox: invalid range of latitudes.",  south > north);          // Accept NaN.
  // Do not require west <= east, as this condition is not specified in ISO 19115.
  // Some implementations may use west > east for box spanning the anti-meridian.
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the geographic bounding box.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final GeographicBoundingBox object) {
  if (object == null) {
    return;
  }
  final double west  = object.getWestBoundLongitude();
  final double east  = object.getEastBoundLongitude();
  final double south = object.getSouthBoundLatitude();
  final double north = object.getNorthBoundLatitude();
  assertBetween("GeographicBoundingBox: illegal west bound.",  -180, +180, west);
  assertBetween("GeographicBoundingBox: illegal east bound.",  -180, +180, east);
  assertBetween("GeographicBoundingBox: illegal south bound.", -90,   +90, south);
  assertBetween("GeographicBoundingBox: illegal north bound.", -90,   +90, north);
  assertTrue("GeographicBoundingBox: invalid range of longitudes.", west <= east);
  assertTrue("GeographicBoundingBox: invalid range of latitudes.",  south <= north);
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given coordinate system.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final UserDefinedCS object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  validateAxes(object);
  final int dimension = object.getDimension();
  assertBetween("UserDefinedCS: wrong number of dimensions.", 2, 3, dimension);
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given coordinate system.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final EllipsoidalCS object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  validateAxes(object);
  final int dimension = object.getDimension();
  assertBetween("EllipsoidalCS: wrong number of dimensions.", 2, 3, dimension);
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given coordinate system.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final EllipsoidalCS object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  validateAxes(object);
  final int dimension = object.getDimension();
  assertBetween("EllipsoidalCS: wrong number of dimensions.", 2, 3, dimension);
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given coordinate system.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final UserDefinedCS object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  validateAxes(object);
  final int dimension = object.getDimension();
  assertBetween("UserDefinedCS: wrong number of dimensions.", 2, 3, dimension);
}

代码示例来源:origin: apache/sis

/**
   * Forces release of JDBC connections after the tests in a class.
   *
   * @throws FactoryException if an error occurred while closing the connections.
   */
  public static synchronized void close() throws FactoryException {
    final EPSGFactory af = factory;
    if (af != null) {
      factory = null;
      final int n = ((ConcurrentAuthorityFactory) af).countAvailableDataAccess();
      af.close();
      assertBetween("Since we ran all tests sequentially, should have no more than 1 Data Access Object (DAO).", 0, 1, n);
    }
  }
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given prime meridian.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final PrimeMeridian object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  final Unit<Angle> unit = object.getAngularUnit();
  mandatory("PrimeMeridian: shall have a unit of measurement.", unit);
  double longitude = object.getGreenwichLongitude();
  if (unit != null) {
    final Unit<Angle> degree = units.degree();
    assertTrue("PrimeMeridian: unit must be compatible with degrees.", unit.isCompatible(degree));
    longitude = unit.getConverterTo(degree).convert(longitude);
  }
  assertBetween("PrimeMeridian: expected longitude in [-180 … +180]° range.", -180, +180, longitude);
}

代码示例来源:origin: org.opengis/geoapi-conformance

if (def != null) {
  assertInstanceOf("ParameterDescriptor: getDefaultValue() returns unexpected value.", valueClass, def);
  assertBetween("ParameterDescriptor: getDefaultValue() out of range.", min, max, def);
assertBetween("ParameterDescriptor: getMinimumOccurs() shall returns 0 or 1.", 0, 1, object.getMinimumOccurs());
assertEquals("ParameterDescriptor: getMaximumOccurs() shall returns exactly 1.", 1, object.getMaximumOccurs());

代码示例来源:origin: opengeospatial/geoapi

if (def != null) {
  assertInstanceOf("ParameterDescriptor: getDefaultValue() returns unexpected value.", valueClass, def);
  assertBetween("ParameterDescriptor: getDefaultValue() out of range.", min, max, def);
assertBetween("ParameterDescriptor: getMinimumOccurs() shall returns 0 or 1.", 0, 1, object.getMinimumOccurs());
assertEquals("ParameterDescriptor: getMaximumOccurs() shall returns exactly 1.", 1, object.getMaximumOccurs());

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given prime meridian.
 *
 * @param object The object to validate, or {@code null}.
 */
public void validate(final PrimeMeridian object) {
  if (object == null) {
    return;
  }
  validateIdentifiedObject(object);
  final Unit<Angle> unit = object.getAngularUnit();
  mandatory("PrimeMeridian: must have a unit of measurement.", unit);
  if (unit != null) {
    assertTrue("PrimeMeridian: unit must be compatible with degrees.",
        unit.isCompatible(units.degree()));
  }
  double longitude = object.getGreenwichLongitude();
  if (unit != null) {
    longitude = unit.getConverterTo(units.degree()).convert(longitude);
  }
  assertBetween("PrimeMeridian: expected longitude in [-180 ... +180°] range.", -180, +180, longitude);
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given "pass through" operation.
 *
 * @param  object  the object to validate, or {@code null}.
 */
public void validate(final PassThroughOperation object) {
  if (object == null) {
    return;
  }
  validateCoordinateOperation(object);
  final MathTransform transform = object.getMathTransform();
  mandatory("PassThroughOperation: shall have a MathTransform.", transform);
  final CoordinateOperation operation = object.getOperation();
  mandatory("PassThroughOperation: getOperation() is mandatory.", operation);
  assertNotSame("PassThroughOperation: getOperation() can't be this.", object, operation);
  dispatch(operation);
  final int[] index = object.getModifiedCoordinates();
  mandatory("PassThroughOperation: modified coordinates are mandatory.", index);
  if (operation == null || index == null) {
    return;
  }
  final int sourceDimension = transform.getSourceDimensions();
  for (int i : index) {
    assertBetween("PassThroughOperation: invalid modified ordinate index.", 0, sourceDimension-1, i);
  }
}

代码示例来源:origin: org.opengis/geoapi-conformance

/**
 * Validates the given parameter value.
 *
 * @param <T> The class of parameter values.
 * @param object The object to validate, or {@code null}.
 */
public <T> void validate(final ParameterValue<T> object) {
  if (object == null) {
    return;
  }
  final ParameterDescriptor<T> descriptor = object.getDescriptor();
  mandatory("ParameterValue: must have a descriptor.", descriptor);
  validate(descriptor);
  final T value = object.getValue();
  if (value != null) {
    if (descriptor != null) {
      final Class<T> valueClass = descriptor.getValueClass();
      assertInstanceOf("ParameterValue: getValue() returns unexpected value.", valueClass, value);
      final Set<T> validValues = descriptor.getValidValues();
      if (validValues != null) {
        assertContains("ParameterValue: getValue() not a member of getValidValues() set.",
            validValues, value);
      }
      assertBetween("ParameterValue: getValue() is out of bounds.",
          descriptor.getMinimumValue(), descriptor.getMaximumValue(), value);
    }
  }
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Validates the given parameter value.
 *
 * @param  <T>     the class of parameter values.
 * @param  object  the object to validate, or {@code null}.
 */
public <T> void validate(final ParameterValue<T> object) {
  if (object == null) {
    return;
  }
  final ParameterDescriptor<T> descriptor = object.getDescriptor();
  mandatory("ParameterValue: shall have a descriptor.", descriptor);
  validate(descriptor);
  final T value = object.getValue();
  if (value != null) {
    if (descriptor != null) {
      final Class<T> valueClass = descriptor.getValueClass();
      assertInstanceOf("ParameterValue: getValue() returns unexpected value.", valueClass, value);
      final Set<T> validValues = descriptor.getValidValues();
      if (validValues != null) {
        validate(validValues);
        assertContains("ParameterValue: getValue() not a member of getValidValues() set.",
            validValues, value);
      }
      assertBetween("ParameterValue: getValue() is out of bounds.",
          descriptor.getMinimumValue(), descriptor.getMaximumValue(), value);
    }
  }
}

代码示例来源:origin: org.opengis/geoapi-conformance

assertBetween("PassThroughOperation: invalid modified ordinate index.", 0, sourceDimension-1, i);

代码示例来源:origin: opengeospatial/geoapi

final double minimum  = axis.getMinimumValue();
final double maximum  = axis.getMaximumValue();
assertBetween("DirectPosition: ordinate out of axis bounds.", minimum, maximum, ordinate);

代码示例来源:origin: opengeospatial/geoapi

assertBetween   ("Envelope: invalid lower ordinate.",     minimum, maximum, lower);
assertBetween   ("Envelope: invalid upper ordinate.",     minimum, maximum, upper);
assertBetween   ("Envelope: invalid median ordinate.",    minimum, maximum, median);

代码示例来源:origin: org.opengis/geoapi-conformance

final double maximum  = axis.getMaximumValue();
final double eps = (maximum - minimum) * tolerance;
assertBetween("DirectPosition: ordinate out of axis bounds.",
    minimum - eps, maximum + eps, ordinate);

代码示例来源:origin: apache/sis

/**
 * Tests the projection at some special latitudes (0, ±π/2, NaN).
 *
 * @throws ProjectionException if an error occurred while projecting a point.
 */
@Test
public void testSpecialLatitudes() throws ProjectionException {
  if (transform == null) {                    // May have been initialized by 'testSphericalCase'.
    createNormalizedProjection(true);       // Elliptical case
  }
  assertEquals ("Not a number",     NaN,                    transform(NaN),           tolerance);
  assertEquals ("Out of range",     NaN,                    transform(+2),            tolerance);
  assertEquals ("Out of range",     NaN,                    transform(-2),            tolerance);
  assertEquals ("Forward 0°N",      0,                      transform(0),             tolerance);
  assertEquals ("Forward 90°N",     POSITIVE_INFINITY,      transform(+PI/2),         tolerance);
  assertEquals ("Forward 90°S",     NEGATIVE_INFINITY,      transform(-PI/2),         tolerance);
  assertEquals ("Forward (90+ε)°N", POSITIVE_INFINITY,      transform(nextUp  ( PI/2)), tolerance);
  assertEquals ("Forward (90+ε)°S", NEGATIVE_INFINITY,      transform(nextDown(-PI/2)), tolerance);
  assertBetween("Forward (90-ε)°N", +MIN_VALUE, +MAX_VALUE, transform(nextDown( PI/2)));
  assertBetween("Forward (90-ε)°S", -MAX_VALUE, -MIN_VALUE, transform(nextUp  (-PI/2)));
  assertEquals ("Not a number",     NaN,   inverseTransform(NaN),                tolerance);
  assertEquals ("Inverse 0 m",      0,     inverseTransform(0),                  tolerance);
  assertEquals ("Inverse +∞",       +PI/2, inverseTransform(POSITIVE_INFINITY),  tolerance);
  assertEquals ("Inverse +∞ appr.", +PI/2, inverseTransform(LN_INFINITY + 1),    tolerance);
  assertEquals ("Inverse −∞",       -PI/2, inverseTransform(NEGATIVE_INFINITY),  tolerance);
  assertEquals ("Inverse −∞ appr.", -PI/2, inverseTransform(-(LN_INFINITY + 1)), tolerance);
}

相关文章