当前位置: 首页>>代码示例>>Java>>正文


Java ArrayComparisonFailure类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:AuraDevelopmentTeam,项目名称:VersionLib,代码行数:19,代码来源:TestUtils.java

示例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));
    }
  }
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:29,代码来源:BrokerUtilsTest.java

示例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);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:21,代码来源:BlockSumFilterTest.java

示例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);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:21,代码来源:IntBlockSumFilterTest.java

示例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);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:22,代码来源:AverageFilterTest.java

示例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);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:21,代码来源:BlockMeanFilterTest.java

示例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);
    }
}
 
开发者ID:osglworks,项目名称:java-unit,代码行数:11,代码来源:TestBase.java

示例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);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:9,代码来源:AsyncTestBase.java

示例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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:LLDPTest.java

示例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;
	}
}
 
开发者ID:jkschneider,项目名称:java-power-assert,代码行数:10,代码来源:Assert.java

示例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());
}
 
开发者ID:Acosix,项目名称:alfresco-utility,代码行数:37,代码来源:BeanDefinitionFromPropertiesPostProcessorTest.java

示例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;
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:11,代码来源:TestUtils.java

示例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));
                }
            }
        }
    }
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:29,代码来源:OrderedComparisonCriteria.java

示例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));
}
 
开发者ID:exxeleron,项目名称:qJava,代码行数:13,代码来源:TestQWriter.java

示例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());
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:41,代码来源:ResultsManagerTest.java


注:本文中的org.junit.internal.ArrayComparisonFailure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。