本文整理了Java中org.apache.sis.test.Assert.assertArrayEquals()
方法的一些代码示例,展示了Assert.assertArrayEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertArrayEquals()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertArrayEquals
[英]Asserts that the two given arrays contains objects that are equal ignoring metadata. See ComparisonMode#IGNORE_METADATA for more information.
[中]断言两个给定数组包含相等的对象,忽略元数据。有关详细信息,请参阅ComparisonMode#IGNORE_元数据。
代码示例来源:origin: apache/sis
/**
* Tests {@link AbstractDirectPosition#parse(CharSequence)}.
*/
@Test
public void testParse() {
assertArrayEquals(new double[] {6, 10, 2}, AbstractDirectPosition.parse("POINT(6 10 2)"), STRICT);
assertArrayEquals(new double[] {3, 14, 2}, AbstractDirectPosition.parse("POINT M [ 3 14 2 ] "), STRICT);
assertArrayEquals(new double[] {2, 10, 8}, AbstractDirectPosition.parse("POINT Z 2 10 8"), STRICT);
assertArrayEquals(new double[] {}, AbstractDirectPosition.parse("POINT()"), STRICT);
assertArrayEquals(new double[] {}, AbstractDirectPosition.parse("POINT ( ) "), STRICT);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link MatrixParameters#aliasToIndices(String)}.
*/
@Test
@Override
public void testAliasToIndices() {
assertArrayEquals(new int[] {0, 0}, MatrixParameters.aliasToIndices("A0"));
assertArrayEquals(new int[] {0, 1}, MatrixParameters.aliasToIndices("A1"));
assertArrayEquals(new int[] {0, 2}, MatrixParameters.aliasToIndices("A2"));
assertArrayEquals(new int[] {1, 0}, MatrixParameters.aliasToIndices("B0"));
assertArrayEquals(new int[] {1, 1}, MatrixParameters.aliasToIndices("B1"));
assertArrayEquals(new int[] {1, 2}, MatrixParameters.aliasToIndices("B2"));
}
代码示例来源:origin: apache/sis
/**
* Sets all values in the given record using the {@link DefaultRecord#setAll(Object[])} method,
* then checks that the values were correctly stored.
*/
private static void setAllAndCompare(final DefaultRecord record, final Object... values) {
record.setAll(values);
assertArrayEquals("attributes.values", values, record.getAttributes().values().toArray());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link ResidualGrid#interpolateAt(double...)} at other locations.
*
* @throws TransformException if an error occurred while transforming a coordinate.
*/
@Test
@DependsOnMethod("testInterpolateAtIntersection")
public void testInterpolateAt() throws TransformException {
assertArrayEquals(new double[] {0.25, 2 }, grid.interpolateAt(0.25, 0 ), STRICT);
assertArrayEquals(new double[] {1.75, 1.25}, grid.interpolateAt(1.75, 0 ), STRICT);
assertArrayEquals(new double[] {1.25, 2 }, grid.interpolateAt(1, 0.25), STRICT);
assertArrayEquals(new double[] {1.625, 1.25}, grid.interpolateAt(1.75, 0.25), STRICT);
}
代码示例来源:origin: apache/sis
/**
* Implementation of {@link #testCreateFromCombinedURNs()} and {@link #testCreateFromCombinedHTTPs()}.
*/
private static void testCreateFromCombinedURIs(final MultiAuthoritiesFactory factory, final String heightOnWGS84)
throws FactoryException
{
CompoundCRS crs = factory.createCompoundCRS(heightOnWGS84);
assertArrayEquals("WGS 84 + MSL height", new SingleCRS[] {
HardCodedCRS.WGS84_φλ, HardCodedCRS.GRAVITY_RELATED_HEIGHT
}, crs.getComponents().toArray());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link CollectionsExt#toArray(Collection, Class)}.
*
* @since 0.6
*/
@Test
public void testToArray() {
final String[] expected = new String[] {"One", "Two", "Three"};
final String[] actual = CollectionsExt.toArray(Arrays.asList(expected), String.class);
assertArrayEquals(expected, actual);
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link MetadataReader#split(String)}.
*/
@Test
public void testSplit() {
assertArrayEquals(new String[] {"John Doe", "Foo \" Bar", "Jane Lee", "L J Smith, Jr."},
MetadataReader.split("John Doe, \"Foo \" Bar\" ,Jane Lee,\"L J Smith, Jr.\"").toArray());
}
代码示例来源:origin: apache/sis
/**
* Tests unmarshalling of a few locales.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testUnmarshalling() throws JAXBException {
final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class, XML2016+FILENAME);
assertArrayEquals(locales, metadata.getLanguages().toArray());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link BursaWolfParameters#getValues()}.
*/
@Test
public void testGetValues() {
assertArrayEquals("Translation only", new double[] {-168, -60, 320},
createNTF_to_WGS84().getValues(), STRICT);
assertArrayEquals("All 7 params", new double[] {-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143},
createED87_to_WGS84().getValues(), STRICT);
assertArrayEquals("Mixed", new double[] {0, 0, 4.5, 0, 0, 0.554, 0.219},
createWGS72_to_WGS84().getValues(), STRICT);
}
代码示例来源:origin: apache/sis
/**
* Tests unmarshalling from legacy ISO 19139:2007 schema.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testUnmarshallingLegacy() throws JAXBException {
final DefaultMetadata metadata = unmarshalFile(DefaultMetadata.class, XML2007+FILENAME);
assertArrayEquals(locales, metadata.getLanguages().toArray());
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link MatrixParameters#aliasToIndices(String)}.
*/
@Test
public void testAliasToIndices() {
assertArrayEquals(new int[] {10, 0}, MatrixParameters.aliasToIndices("K0"));
assertArrayEquals(new int[] { 0, 6}, MatrixParameters.aliasToIndices("A6"));
assertArrayEquals(new int[] { 6, 4}, MatrixParameters.aliasToIndices("G4"));
assertNull(MatrixParameters.aliasToIndices("2B"));
assertNull(MatrixParameters.aliasToIndices("elt_1_2"));
}
代码示例来源:origin: apache/sis
/**
* Delegates to the tested implementation and verifies that the values are equal
* to the ones provided by the reference implementation.
*/
@Override
public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException {
final double[] expected = new double[numPts * reference.getTargetDimensions()];
reference.transform(srcPts, srcOff, expected, 0, numPts);
tested.transform(srcPts, srcOff, dstPts, dstOff, numPts);
assertArrayEquals("transform(float[], …, double[], …)", expected,
Arrays.copyOfRange(dstPts, dstOff, dstOff + numPts * tested.getTargetDimensions()), tolerance);
}
代码示例来源:origin: apache/sis
/**
* Delegates to the tested implementation and verifies that the values are equal
* to the ones provided by the reference implementation.
*/
@Override
public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException {
final float[] expected = new float[numPts * reference.getTargetDimensions()];
reference.transform(srcPts, srcOff, expected, 0, numPts);
tested.transform(srcPts, srcOff, dstPts, dstOff, numPts);
assertArrayEquals("transform(double[], …, float[], …)", expected,
Arrays.copyOfRange(dstPts, dstOff, dstOff + numPts * tested.getTargetDimensions()), (float) tolerance);
}
代码示例来源:origin: apache/sis
/**
* Delegates to the tested implementation and verifies that the values are equal
* to the ones provided by the reference implementation.
*/
@Override
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException {
final double[] expected = new double[numPts * reference.getTargetDimensions()];
reference.transform(srcPts, srcOff, expected, 0, numPts);
tested.transform(srcPts, srcOff, dstPts, dstOff, numPts);
assertArrayEquals("transform(double[], …, double[], …)", expected,
Arrays.copyOfRange(dstPts, dstOff, dstOff + numPts * tested.getTargetDimensions()), tolerance);
}
代码示例来源:origin: apache/sis
/**
* Delegates to the tested implementation and verifies that the values are equal
* to the ones provided by the reference implementation.
*/
@Override
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException {
final float[] expected = new float[numPts * reference.getTargetDimensions()];
reference.transform(srcPts, srcOff, expected, 0, numPts);
tested.transform(srcPts, srcOff, dstPts, dstOff, numPts);
assertArrayEquals("transform(float[], …, float[], …)", expected,
Arrays.copyOfRange(dstPts, dstOff, dstOff + numPts * tested.getTargetDimensions()), (float) tolerance);
}
代码示例来源:origin: apache/sis
/**
* Tests conversions between wrapper classes.
*/
@Test
public void testWrapperTypes() {
final ArrayConverter<Integer[], Double[]> converter = create(Integer[].class, Double[].class);
final Integer[] source = {4, 8, -6};
final Double [] expected = {4.0, 8.0, -6.0};
final Double [] actual = converter.apply(source);
assertArrayEquals(expected, actual);
}
代码示例来源:origin: apache/sis
/**
* Delegates to the tested implementation and verifies that the value is equals
* to the one provided by the reference implementation.
*/
@Override
public DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws TransformException {
final double[] expected = reference.transform(ptSrc, ptDst).getCoordinate();
final DirectPosition value = tested.transform(ptSrc, ptDst);
assertArrayEquals("transform(DirectPosition, …)", expected, value.getCoordinate(), tolerance);
return value;
}
代码示例来源:origin: apache/sis
/**
* Tests {@link AttributeTypeBuilder#setValidValues(Object...)} and the corresponding getter method.
*/
@Test
@DependsOnMethod("testBuilder")
public void testSetValidValues() {
final AttributeTypeBuilder<String> builder = new FeatureTypeBuilder().addAttribute(String.class);
assertEquals("length", 0, builder.getValidValues().length);
assertSame(builder, builder.setValidValues("Blue", "Green", "Red"));
assertArrayEquals(new String[] {"Blue", "Green", "Red"}, builder.getValidValues());
assertSame(builder, builder.setValidValues("Yellow", "Cyan", "Magenta"));
assertArrayEquals(new String[] {"Yellow", "Cyan", "Magenta"}, builder.getValidValues());
}
代码示例来源:origin: apache/sis
/**
* Tests {@link TreeTableView#toString()}.
* Since the result is locale-dependent, we can not compare against an exact string.
* We will only compare the beginning of each line.
*/
@Test
public void testToString() {
final TreeTableView metadata = create(ValueExistencePolicy.COMPACT);
assertMultilinesEquals(EXPECTED, formatMetadata(metadata)); // Locale-independent
assertArrayEquals(toTreeStructure(EXPECTED), toTreeStructure(metadata.toString())); // Locale-dependent.
}
代码示例来源:origin: apache/sis
/**
* Asserts that the given matrix is equals to the given expected values, up to the given tolerance threshold.
* This method compares the elements values in two slightly redundant ways.
*/
static void assertEqualsElements(final double[] expected, final int numRow, final int numCol,
final MatrixSIS actual, final double tolerance)
{
assertEquals("numRow", numRow, actual.getNumRow());
assertEquals("numCol", numCol, actual.getNumCol());
assertArrayEquals(expected, actual.getElements(), tolerance); // First because more informative in case of failure.
assertTrue(Matrices.create(numRow, numCol, expected).equals(actual, tolerance));
}
内容来源于网络,如有侵权,请联系作者删除!