本文整理了Java中org.apache.sis.test.Assert.assertEquals()
方法的一些代码示例,展示了Assert.assertEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertEquals()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertEquals
[英]Asserts that the two given objects are equal ignoring metadata. See ComparisonMode#IGNORE_METADATA for more information.
[中]断言两个给定对象相等,忽略元数据。有关详细信息,请参阅ComparisonMode#IGNORE_元数据。
代码示例来源:origin: apache/sis
/**
* Verifies that parsing the given fraction produces the given numerator and denominator.
*
* @param numerator the expected numerator.
* @param denominator the expected denominator.
* @param s the text to parse.
*/
private static void verifyParsing(final int numerator, final int denominator, final String s) {
final Fraction f = new Fraction(s);
assertEquals("numerator", numerator, f.numerator);
assertEquals("denominator", denominator, f.denominator);
}
代码示例来源:origin: apache/sis
/**
* Verifies the values of the given vertical extent.
*/
private static void verifyVerticalExtent(final CommonCRS.Vertical expectedCRS, final VerticalExtent extent) {
assertEquals(-10, extent.getMinimumValue(), STRICT);
assertEquals( 70, extent.getMaximumValue(), STRICT);
assertEqualsIgnoreMetadata(expectedCRS.crs(), extent.getVerticalCRS());
}
代码示例来源:origin: apache/sis
/**
* Ensures that the given matrix is an instance of the expected type.
*/
@Override
void validate(final MatrixSIS matrix) {
super.validate(matrix);
assertEquals(Matrix4.class, matrix.getClass());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link MatrixParametersAlphaNum#indicesToName(int[])}.
*/
@Test
@Override
public void testIndicesToName() {
assertEquals("E8", param.indicesToName(new int[] {4, 8}));
assertEquals("H2", param.indicesToName(new int[] {7, 2}));
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link Units#toStandardUnit(Unit)}.
*/
@Test
public void testToStandardUnit() {
assertEquals(1000.0, toStandardUnit(KILOMETRE), 1E-15);
assertEquals(0.017453292519943295, toStandardUnit(DEGREE), 1E-15);
}
代码示例来源:origin: apache/sis
/**
* Asserts that conversion of the given {@code source} value produces the given {@code target} value.
* The conversion is not expected to be invertible. This method is used for testing rounding behavior.
*/
private static <S extends Number, T extends Number> void runConversion(
final ObjectConverter<S,T> c, final S source, final T target, final S inverse)
throws UnconvertibleObjectException
{
assertFalse(source.equals(inverse));
assertEquals("Forward conversion.", target, c.apply(source));
assertEquals("Inverse conversion.", inverse, c.inverse().apply(target));
}
代码示例来源:origin: apache/sis
/**
* Validates the given matrix.
* The default implementation verifies only the matrix size. Subclasses should override this method
* for additional checks, typically ensuring that it is an instance of the expected class.
*/
void validate(final MatrixSIS matrix) {
assertEquals("numRow", getNumRow(), matrix.getNumRow());
assertEquals("numCol", getNumCol(), matrix.getNumCol());
}
代码示例来源:origin: apache/sis
/**
* Asserts that an element from the given matrix is equals to the expected value, using a relative threshold.
*/
private static void assertEqualsRelative(final String message, final double expected,
final MatrixSIS matrix, final int row, final int column)
{
assertEquals(message, expected, matrix.getElement(row, column), StrictMath.abs(expected) * 1E-12);
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link Range#subtract(Range)} method.
*/
@Test
public void testSubtract() {
final Range<Integer> range1 = new Range<>(Integer.class, 10, true, 40, true);
final Range<Integer> range2 = new Range<>(Integer.class, 20, true, 25, true);
final Range<Integer>[] subtract = range1.subtract(range2);
assertEquals(2, subtract.length);
assertEquals(new Range<>(Integer.class, 10, true, 20, false), subtract[0]);
assertEquals(new Range<>(Integer.class, 25, false, 40, true), subtract[1]);
}
代码示例来源:origin: apache/sis
/**
* Tests EPSG:3395 on a point.
*/
static void testMercatorProjection(final MathTransform mt) throws TransformException {
DirectPosition pt = new DirectPosition2D(20, 40);
pt = mt.transform(pt, pt);
assertEquals("Easting", 2226389.816, pt.getOrdinate(0), 0.01);
assertEquals("Northing", 4838471.398, pt.getOrdinate(1), 0.01);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link DirectPosition1D#clone()}.
*/
@Test
public void testClone() {
final DirectPosition1D p1 = new DirectPosition1D(20);
final DirectPosition1D p2 = p1.clone();
assertEquals("Expected the same CRS and ordinates.", p1, p2);
assertEquals("Expected the same ordinates.", 20.0, p2.ordinate, 0.0);
validate(p2);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link Scalar#toString()}.
*/
@Test
public void testToString() {
assertEquals("toString()", "24 km", new Scalar.Length (24.00, Units.KILOMETRE).toString());
assertEquals("toString()", "10.25 h", new Scalar.Time (10.25, Units.HOUR) .toString());
assertEquals("toString()", "0.25", new Scalar.Dimensionless( 0.25, Units.UNITY) .toString());
}
代码示例来源:origin: apache/sis
/**
* Verifies the conversion factory of {@link Units#PSU}.
*
* @see <a href="https://issues.apache.org/jira/browse/SIS-413">SIS-413</a>
*
* @throws IncommensurableException if the conversion can not be applied.
*/
@Test
public void testSalinityConversionFactor() throws IncommensurableException {
assertEquals(0.001, PSU.getConverterToAny(UNITY) .convert(1), STRICT);
assertEquals(0.1, PSU.getConverterToAny(PERCENT).convert(1), STRICT);
}
代码示例来源:origin: apache/sis
/**
* Same tests than {@link #testAutoConversions()} but using the {@code *Any} methods.
*/
@Test
public void testAutoConversionsOfAny() {
final MeasurementRange<?> r1 = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
final MeasurementRange<?> r2 = MeasurementRange.create(1.5f, true, 3f, true, Units.KILOMETRE);
assertEquals(MeasurementRange.create(1000f, true, 3000f, true, Units.METRE ), r1.unionAny (r2));
assertEquals(MeasurementRange.create( 1f, true, 3f, true, Units.KILOMETRE), r2.unionAny (r1));
assertEquals(MeasurementRange.create(1500f, true, 2000f, true, Units.METRE ), r1.intersectAny(r2));
assertEquals(MeasurementRange.create( 1.5f, true, 2f, true, Units.KILOMETRE), r2.intersectAny(r1));
}
代码示例来源:origin: apache/sis
/**
* Tests {@link SingletonAttribute#toString()}.
*/
@Test
@DependsOnMethod("testValue")
public void testToString() {
final AbstractAttribute<String> city = city();
assertEquals("Attribute[“city” : String] = Utopia", city.toString());
city.setValue("Dystopia");
assertEquals("Attribute[“city” : String] = Dystopia", city.toString());
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link DefaultAttributeType#toString()}.
*/
@Test
public void testToString() {
final DefaultAttributeType<String> city = city();
assertEquals("AttributeType[“city” : String]", city.toString());
}
}
代码示例来源:origin: apache/sis
/**
* Tests the string representation of <cite>ED87 to WGS 84</cite> parameters (EPSG:1146).
*/
@Test
@DependsOnMethod("testGetValues")
public void testToString() {
assertEquals("ToWGS84[-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143]", createED87_to_WGS84().toString());
assertEquals("ToWGS84[-168.0, -60.0, 320.0]", createNTF_to_WGS84().toString());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link LinearConverter#convert(Number)} with a value of type {@link Float}.
* This method indirectly tests {@link org.apache.sis.math.DecimalFunctions#floatToDouble(float)}.
*/
@Test
@DependsOnMethod("testConvertDouble")
public void testConvertFloat() {
LinearConverter c = LinearConverter.offset(27315, 100);
final Number n = c.convert(Float.valueOf(27.01f));
assertInstanceOf("convert(Float)", Double.class, n);
assertEquals(300.16, n.doubleValue(), STRICT); // Really want STRICT; see testConvertDouble()
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link GeneralDirectPosition#formatTo(Formatter)} method.
* Contrarily to {@code toString()}, the precision depends on the CRS.
*/
@Test
public void testFormatWKT() {
final GeneralDirectPosition position = new GeneralDirectPosition(6, 10);
assertEquals("POINT[6 10]", position.toWKT());
position.setCoordinateReferenceSystem(WGS84);
assertEquals("POINT[6.00000000 10.00000000]", position.toWKT()); // 1 cm precision on Earth.
validate(position);
}
代码示例来源:origin: apache/sis
/**
* Tests the {@link DirectPosition1D#toString()} method.
*/
@Test
public void testWktFormatting() {
final DirectPosition1D position = new DirectPosition1D(8.5);
assertEquals("POINT(8.5)", position.toString());
validate(position);
}
内容来源于网络,如有侵权,请联系作者删除!