本文整理汇总了Java中org.junit.internal.ArrayComparisonFailure类的典型用法代码示例。如果您正苦于以下问题:Java ArrayComparisonFailure类的具体用法?Java ArrayComparisonFailure怎么用?Java ArrayComparisonFailure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayComparisonFailure类属于org.junit.internal包,在下文中一共展示了ArrayComparisonFailure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertSortsCorrectly
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> void assertSortsCorrectly(T[] expectedOrder, Comparator<T> comparator)
throws ArrayComparisonFailure {
List<T> versions = new ArrayList<>(Arrays.asList(expectedOrder));
T[] sortedVersions;
for (int i = 0; i < SHUFFLES; ++i) {
Collections.shuffle(versions);
sortedVersions = (T[]) versions.stream().sorted(comparator).toArray(Object[]::new);
try {
assertArrayEquals(expectedOrder, sortedVersions);
} catch (ArrayComparisonFailure e) {
assertArrayEquals("Sorting failed for shuffle:\n" + versions + "\nSorted result:\n"
+ Arrays.toString(sortedVersions) + '\n', expectedOrder, sortedVersions);
}
}
}
示例2: myAssertMapsEqual
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
/**
* as assert function I added that compares hash maps
* @param msg
*
* @param twoLevelMap
* @param expectedMap
* @throws ArrayComparisonFailure
*/
private <K1, K2, V> void myAssertMapsEqual(
String msg,
HashMap<K1, HashMap<K2, V>> expectedMap,
HashMap<K1, HashMap<K2, V>> revertedTwoLevelMap
)
throws ArrayComparisonFailure {
// compare key1
assertTrue(msg, expectedMap.keySet().equals(revertedTwoLevelMap.keySet()));
// for each key1, compare all <key2, value>s
for (K1 key1 : expectedMap.keySet()) {
assertTrue(msg + " comparing key2", expectedMap.get(key1).keySet().equals(revertedTwoLevelMap.get(key1).keySet()));
for (K2 key2 : expectedMap.get(key1).keySet()) {
assertEquals(msg + " comparing values", expectedMap.get(key1).get(key2), revertedTwoLevelMap.get(key1).get(key2));
}
}
}
示例3: sumIsCorrect
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private void sumIsCorrect(float[] data, int width, int height, float boxSize, boolean internal,
BlockSumDataFilter filter) throws ArrayComparisonFailure
{
float[] data1 = data.clone();
float[] data2 = data.clone();
sum(data1, width, height, boxSize);
if (internal)
{
filter.filterInternal(data2, width, height, boxSize);
floatArrayEquals(String.format("Internal arrays do not match: [%dx%d] @ %.1f", width, height, boxSize),
data1, data2, width, height, boxSize);
}
else
{
filter.filter(data2, width, height, boxSize);
floatArrayEquals(String.format("Arrays do not match: [%dx%d] @ %.1f", width, height, boxSize), data1, data2,
width, height, 0);
}
}
示例4: sumIsCorrect
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private void sumIsCorrect(int[] data, int width, int height, int boxSize, boolean internal,
BlockSumDataFilter filter) throws ArrayComparisonFailure
{
int[] data1 = data.clone();
int[] data2 = data.clone();
sum(data1, width, height, boxSize);
if (internal)
{
filter.filterInternal(data2, width, height, boxSize);
intArrayEquals(String.format("Internal arrays do not match: [%dx%d] @ %d", width, height, boxSize), data1,
data2, width, height, boxSize);
}
else
{
filter.filter(data2, width, height, boxSize);
intArrayEquals(String.format("Arrays do not match: [%dx%d] @ %d", width, height, boxSize), data1, data2,
width, height, 0);
}
}
示例5: averageIsCorrect
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private void averageIsCorrect(int width, int height, float boxSize, boolean internal, DataFilter filter)
throws ArrayComparisonFailure
{
rand = new gdsc.core.utils.Random(-30051976);
float[] data1 = createData(width, height);
float[] data2 = data1.clone();
AverageFilterTest.average(data1, width, height, boxSize);
if (internal)
{
filter.filterInternal(data2, width, height, boxSize);
floatArrayEquals(String.format("Internal arrays do not match: [%dx%d] @ %.1f", width, height, boxSize),
data1, data2, width, height, boxSize);
}
else
{
filter.filter(data2, width, height, boxSize);
floatArrayEquals(String.format("Arrays do not match: [%dx%d] @ %.1f", width, height, boxSize), data1,
data2, width, height, 0);
}
}
示例6: meanIsCorrect
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private void meanIsCorrect(float[] data, int width, int height, float boxSize, boolean internal, BlockMeanDataFilter filter)
throws ArrayComparisonFailure
{
float[] data1 = data.clone();
float[] data2 = data.clone();
mean(data1, width, height, boxSize);
if (internal)
{
filter.filterInternal(data2, width, height, boxSize);
floatArrayEquals(String.format("Internal arrays do not match: [%dx%d] @ %.1f", width, height, boxSize),
data1, data2, width, height, boxSize);
}
else
{
filter.filter(data2, width, height, boxSize);
floatArrayEquals(String.format("Arrays do not match: [%dx%d] @ %.1f", width, height, boxSize), data1, data2,
width, height, 0);
}
}
示例7: arrayNotEquals
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private static void arrayNotEquals(String message, Object expecteds, Object actuals)
throws ArrayComparisonFailure {
if (expecteds == actuals
|| Arrays.deepEquals(new Object[] {expecteds}, new Object[] {actuals})) {
// The reflection-based loop below is potentially very slow, especially for primitive
// arrays. The deepEquals check allows us to circumvent it in the usual case where
// the arrays are exactly equal.
fail(message);
}
}
示例8: assertArrayEquals
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
protected void assertArrayEquals(final String message, final char[] expecteds, final char[] actuals) throws ArrayComparisonFailure {
checkThread();
try {
Assert.assertArrayEquals(message, expecteds, actuals);
} catch (final AssertionError e) {
handleThrowable(e);
}
}
示例9: checkTLV
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private static int checkTLV(final byte[] serializedData, final int offset, final byte typeTLVBits, final String typeTLVName,
final short lengthTLV, final byte[] valueTLV, final byte... bytesBeforeValue) throws ArrayComparisonFailure {
byte[] concreteTlvAwaited = awaitedBytes(typeTLVBits, lengthTLV, valueTLV, bytesBeforeValue);
int concreteTlvAwaitLength = concreteTlvAwaited.length;
assertArrayEquals("Serialization problem " + typeTLVName, concreteTlvAwaited,
ArrayUtils.subarray(serializedData, offset, offset + concreteTlvAwaitLength));
return offset + concreteTlvAwaitLength;
}
示例10: assertArrayEquals
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
public static boolean assertArrayEquals(boolean[] expecteds, boolean[] actuals) {
try {
org.junit.Assert.assertArrayEquals(expecteds, actuals);
return true;
}
catch(ArrayComparisonFailure ignored) {
return false;
}
}
示例11: verifyBean
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
protected void verifyBean(final TestDummyBean beanToVerify, final TestDummyBean refBean1, final TestDummyBean refBean2,
final TestDummyBean refBean3) throws ArrayComparisonFailure
{
Assert.assertArrayEquals("stringList does not contain expected values", new String[] { "value 1", "value 2" },
beanToVerify.getStringList().toArray(new String[0]));
Assert.assertArrayEquals("numberList does not contain expected values", new Integer[] { Integer.valueOf(1), Integer.valueOf(2) },
beanToVerify.getIntegerList().toArray(new Integer[0]));
Assert.assertArrayEquals("booleanList does not contain expected values", new Boolean[] { Boolean.TRUE, Boolean.FALSE },
beanToVerify.getBooleanList().toArray(new Boolean[0]));
Assert.assertArrayEquals("beanList does not contain expected bean", new Object[] { refBean1, refBean2 },
beanToVerify.getBeanList().toArray(new Object[0]));
Assert.assertTrue("stringMap does not contain expected keys",
beanToVerify.getStringMap().keySet().containsAll(Arrays.asList("strkey1", "strkey2")));
Assert.assertEquals("stringMap[strkey1] does match expected value", "value 1", beanToVerify.getStringMap().get("strkey1"));
Assert.assertEquals("stringMap[strkey2] does match expected value", "value 2", beanToVerify.getStringMap().get("strkey2"));
Assert.assertTrue("integerMap does not contain expected keys",
beanToVerify.getIntegerMap().keySet().containsAll(Arrays.asList("intkey1", "intkey2")));
Assert.assertEquals("integerMap[intkey1] does match expected value", Integer.valueOf(1),
beanToVerify.getIntegerMap().get("intkey1"));
Assert.assertEquals("integerMap[intkey2] does match expected value", Integer.valueOf(2),
beanToVerify.getIntegerMap().get("intkey2"));
Assert.assertTrue("booleanMap does not contain expected keys",
beanToVerify.getBooleanMap().keySet().containsAll(Arrays.asList("boolkey1", "boolkey2")));
Assert.assertEquals("booleanMap[boolkey1] does match expected value", Boolean.TRUE, beanToVerify.getBooleanMap().get("boolkey1"));
Assert.assertEquals("booleanMap[boolkey2] does match expected value", Boolean.FALSE, beanToVerify.getBooleanMap().get("boolkey2"));
Assert.assertTrue("beanMap does not contain expected keys",
beanToVerify.getBeanMap().keySet().containsAll(Arrays.asList("beankey1", "beankey2")));
Assert.assertSame("beanMap[beankey1] does match expected bean", refBean1, beanToVerify.getBeanMap().get("beankey1"));
Assert.assertSame("beanMap[beankey2] does match expected bean", refBean2, beanToVerify.getBeanMap().get("beankey2"));
Assert.assertEquals("stringValue does not match expected value", "dummy", beanToVerify.getStringValue());
Assert.assertEquals("numberValue does not match expected value", Integer.valueOf(3), beanToVerify.getIntegerValue());
Assert.assertEquals("booleanValue does not match expected value", Boolean.TRUE, beanToVerify.getBooleanValue());
Assert.assertSame("beanReference does not match expected bean", refBean3, beanToVerify.getBeanReference());
}
示例12: elementsAreEqual
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
@Override
protected boolean elementsAreEqual(Suggestion o1, Suggestion o2) {
if (!o1.getText().equals(o2.getText())) return false;
try {
new UnorderedSuggestionParamComparison().arrayEquals("Suggestion.params not equal", o1.paramsArray(), o2.paramsArray());
} catch (ArrayComparisonFailure ignored) {
return false;
}
return true;
}
示例13: arrayEquals
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
@Override
public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure {
if (expecteds != actuals) {
String header = message == null ? "" : message + "\n: ";
int expectedsLength = this.assertArraysAreSameLength(expecteds, actuals, header);
for (int i = 0; i < expectedsLength; ++i) {
Object expected = Array.get(expecteds, i);
Object actual = Array.get(actuals, i);
if (this.isArray(expected) && this.isArray(actual)) {
try {
this.arrayEquals(message, expected, actual);
} catch (ArrayComparisonFailure var10) {
//var10.addDimension(i);
//throw var10;
throw new ComparisonFailure(header + "array differed first at element [" + i + "]\n", TestUtils.arrayAsString(expected), TestUtils.arrayAsString(actual));
}
} else {
try {
this.assertElementsEqual(expected, actual);
} catch (AssertionError var11) {
//throw new ArrayComparisonFailure(header, var11, i);
throw new ComparisonFailure(header + "array differed first at element [" + i + "]\n", TestUtils.arrayAsString(expecteds), TestUtils.arrayAsString(actuals));
}
}
}
}
}
示例14: serializeObject
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
protected void serializeObject( final Object referenceObject, final QExpressions qe, final String expr ) throws IOException, QException,
ArrayComparisonFailure {
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final QWriter writer = new DefaultQWriter();
writer.setStream(stream);
writer.setEncoding("ISO-8859-1");
writer.write(referenceObject, QConnection.MessageType.SYNC);
final byte[] out = stream.toByteArray();
assertArrayEquals("Serialization failed for q expression: " + expr, qe.getBinaryExpression(expr), copyOfRange(out, 8, out.length));
}
示例15: checkEqual
import org.junit.internal.ArrayComparisonFailure; //导入依赖的package包/类
private void checkEqual(Spot[] spots, int channel, int slice, int position, int type,
MemoryPeakResults actualResults) throws ArrayComparisonFailure
{
Assert.assertNotNull("Input results are null", actualResults);
MemoryPeakResults expectedResults = extract(spots, channel, slice, position, type);
Assert.assertEquals("Size differ", expectedResults.size(), actualResults.size());
final float delta = 0;
PeakResult[] expected = expectedResults.toArray();
PeakResult[] actual = actualResults.toArray();
for (int i = 0; i < actualResults.size(); i++)
{
PeakResult p1 = expected[i];
PeakResult p2 = actual[i];
Assert.assertEquals("Peak mismatch @ " + i, p1.getFrame(), p2.getFrame());
Assert.assertEquals("Orig X mismatch @ " + i, p1.getOrigX(), p2.getOrigX());
Assert.assertEquals("Orig Y mismatch @ " + i, p1.getOrigY(), p2.getOrigY());
Assert.assertEquals("Orig value mismatch @ " + i, p1.getOrigValue(), p2.getOrigValue(), delta);
Assert.assertEquals("Error mismatch @ " + i, p1.getError(), p2.getError(), 1e-6);
Assert.assertEquals("Noise mismatch @ " + i, p1.getNoise(), p2.getNoise(), delta);
Assert.assertNotNull("Params is null @ " + i, p2.getParameters());
Assert.assertEquals("Background mismatch @ " + i, p1.getBackground(), p2.getBackground(), delta);
Assert.assertEquals("Signal mismatch @ " + i, p1.getSignal(), p2.getSignal(), delta);
Assert.assertEquals("XPosition mismatch @ " + i, p1.getXPosition(), p2.getXPosition(), delta);
Assert.assertEquals("YPosition mismatch @ " + i, p1.getYPosition(), p2.getYPosition(), delta);
Assert.assertEquals("ZPosition mismatch @ " + i, p1.getZPosition(), p2.getZPosition(), delta);
for (int j = PeakResult.STANDARD_PARAMETERS, size = p1.getNumberOfParameters(); j < size; j++)
{
Assert.assertEquals("Parameter mismatch @ " + i, p1.getParameter(j), p2.getParameter(j), 1e-6);
}
Assert.assertEquals("ID mismatch @ " + i, p1.getId(), p2.getId());
}
}