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


Java Assert.assertArrayEquals方法代码示例

本文整理汇总了Java中org.junit.Assert.assertArrayEquals方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertArrayEquals方法的具体用法?Java Assert.assertArrayEquals怎么用?Java Assert.assertArrayEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.Assert的用法示例。


在下文中一共展示了Assert.assertArrayEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLong

import org.junit.Assert; //导入方法依赖的package包/类
private void testLong(int generations, Life.Type type) {
    RLE acorn = RLE.getAcorn();
    System.out.print("Running " + type + " for " + generations +" generations with 1 thread");
    Life sample = Life.fromRLE(acorn, type, generations, 1, false);
    long start = System.currentTimeMillis();
    sample.execute();
    long time1 = System.currentTimeMillis() - start;
    System.out.println(", base time: " + time1 + " ms");
    String[] golden = sample.getResult();

    for (int p = 2; p <= 512; p *= 2) {
        System.out.print("Running " + type + " for " + generations +" generations with " + p + " threads");
        sample = Life.fromRLE(acorn, type, generations, p, false);
        start = System.currentTimeMillis();
        sample.execute();
        long time = System.currentTimeMillis() - start;

        Assert.assertArrayEquals(golden, sample.getResult());

        System.out.println(", time: " + time + " ms, speedup: " + (100 * time1 / time)/100d);
    }

}
 
开发者ID:OlegMazurov,项目名称:Koyaanisqatsi,代码行数:24,代码来源:LifeTest.java

示例2: noRetrieval

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void noRetrieval() throws Exception {
  ScrollableResponse<List<Integer>> scrollableResponse = new ScrollableResponse<>();
  scrollableResponse.setValue(Arrays.asList(1, 2, 3, 4, 5));
  scrollableResponse.setScrollToEnd(true);

  EsIterator<Integer> l = new EsIterator<>(scrollableResponse, s -> scrollableResponse);
  int count = 0;
  ArrayList<Integer> result = new ArrayList<>();
  while (l.hasNext()) {
    result.add(l.next());
    count++;
  }
  Assert.assertArrayEquals(new int[]{1, 2, 3, 4, 5},
      ArrayUtils.toPrimitive(result.toArray(new Integer[0])));
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:17,代码来源:EsIteratorTest.java

示例3: deleteOneHundredLongValuesGivesTheSameHash

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void deleteOneHundredLongValuesGivesTheSameHash() {
    Trie trie1 = new TrieImpl();

    for (int k = 0; k < 200; k++)
        trie1 = trie1.put("key" + k, TrieImplValueTest.makeValue(k + 100));

    for (int k = 1; k < 200; k += 2)
        trie1 = trie1.delete("key" + k);

    Trie trie2 = new TrieImpl();

    for (int k = 0; k < 200; k += 2)
        trie2 = trie2.put("key" + k, TrieImplValueTest.makeValue(k + 100));

    Assert.assertArrayEquals(trie1.getHash(), trie2.getHash());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:TrieImplDeleteTest.java

示例4: assertArrayEquals

import org.junit.Assert; //导入方法依赖的package包/类
protected void assertArrayEquals(final String message, final float[] expecteds, final float[] actuals, final float delta) throws ArrayComparisonFailure {
    checkThread();
    try {
        Assert.assertArrayEquals(message, expecteds, actuals, delta);
    } catch (final AssertionError e) {
        handleThrowable(e);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:9,代码来源:AsyncTestBase.java

示例5: testScoredSortedSetValueRangeNegativeInf

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testScoredSortedSetValueRangeNegativeInf() {
    RScoredSortedSet<String> set = redisson.<String>getScoredSortedSet("simple");

    set.add(0, "a");
    set.add(1, "b");
    set.add(2, "c");
    set.add(3, "d");
    set.add(4, "e");

    Collection<String> r = set.valueRange(Double.NEGATIVE_INFINITY, true, 4, false, 1, 2);
    String[] a = r.toArray(new String[0]);
    Assert.assertArrayEquals(new String[]{"b", "c"}, a);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:RedissonScoredSortedSetTest.java

示例6: decodeHexadecimalPathThreeNibbles

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void decodeHexadecimalPathThreeNibbles() {
    byte[] encoded = new byte[] { 0x6d, (byte)0x80 };

    byte[] path = PathEncoder.decode(encoded, 16, 3);

    Assert.assertNotNull(path);
    Assert.assertArrayEquals(new byte[] { 0x06, 0x0d, 0x08 }, path);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:PathEncoderTest.java

示例7: testSort

import org.junit.Assert; //导入方法依赖的package包/类
private void testSort(int[] inputNeighbourIds, short[] inputNeighbourTypes,
    long[] inputNeighbourEdgeIds, int[] sortedNeighbourIds, short[] sortedNeighbourTypes,
    long[] sortedNeighbourEdgeIds) {
    SortedAdjacencyList adjacencyList = getPopulatedAdjacencyList(inputNeighbourIds,
        inputNeighbourTypes, inputNeighbourEdgeIds);
    int expectedSize = inputNeighbourIds.length;
    Assert.assertEquals(expectedSize, adjacencyList.getSize());
    Assert.assertTrue(expectedSize <= adjacencyList.neighbourIds.length); // Check capacity.
    Assert.assertArrayEquals(sortedNeighbourIds, Arrays.copyOf(adjacencyList.neighbourIds,
        adjacencyList.getSize()));
    Assert.assertArrayEquals(sortedNeighbourTypes, Arrays.copyOf(adjacencyList.edgeTypes,
        adjacencyList.getSize()));
    Assert.assertArrayEquals(sortedNeighbourEdgeIds, Arrays.copyOf(adjacencyList.edgeIds,
        adjacencyList.getSize()));
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:16,代码来源:SortedAdjacencyListTest.java

示例8: generatePatchTest

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void generatePatchTest() throws Exception {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  byte[] oldData = readTestData("BsDiffInternalTestOld.txt");
  byte[] newData = readTestData("BsDiffInternalTestNew.txt");
  byte[] expectedPatch = readTestData("BsDiffInternalTestPatchExpected.patch");

  BsDiffPatchWriter.generatePatch(oldData, newData, out);

  byte[] actualPatch = out.toByteArray();
  Assert.assertEquals(actualPatch.length, expectedPatch.length);
  Assert.assertArrayEquals(actualPatch, expectedPatch);
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:14,代码来源:BsDiffTest.java

示例9: createWithBlockHash

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void createWithBlockHash() {
    byte[] hash = BlockGenerator.getInstance().getGenesisBlock().getHash();
    BodyRequestMessage message = new BodyRequestMessage(100, hash);

    Assert.assertEquals(100, message.getId());
    Assert.assertArrayEquals(hash, message.getBlockHash());
    Assert.assertEquals(MessageType.BODY_REQUEST_MESSAGE, message.getMessageType());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:BodyRequestMessageTest.java

示例10: test4

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test4() throws Exception {
    HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("charArrayCopyTest", Object.class, Object.class, Object.class);
    StringContainer1 source1 = new StringContainer1();
    StringContainer2 source2 = new StringContainer2();
    char[] result = new char[source1.value.length + source2.value.length];
    installedBenchmarkCode.executeVarargs(source1.value, source2.value, result);
    Assert.assertArrayEquals(new char[]{'T', 'e', 's', 't', ' ', 'S', 't', 'r', 'i', 'n', 'g'}, result);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:CompressedOopTest.java

示例11: inputOneExpectZero

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void inputOneExpectZero() {
	network.clear();
	network.setInput(new double[] {1});
	network.calculate();
	double[] expected = new double[] {0};
	double[] actual = network.getOutput();
	for (int i = 0; i < actual.length; i++) {
		actual[i] = Math.round(actual[i]);
	}
	
	Assert.assertArrayEquals(expected, actual, 0);
}
 
开发者ID:hkamran,项目名称:HooIsNeural,代码行数:14,代码来源:NOTGateTest.java

示例12: testCommandLineAgrumentsParser_6

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testCommandLineAgrumentsParser_6() {

    String[] expectedArgs = new String[]{ "/bin/bash", "-c", "/tmp/test script.sh", "start", "-test",
                                          "last test arg" };
    String[] actualArgs = StringUtils.parseCommandLineArguments("/bin/bash -c \"/tmp/test script.sh\" start -test 'last test arg'");

    Assert.assertArrayEquals(getArrayNotEqualsMsg(expectedArgs, actualArgs), expectedArgs,
                             actualArgs);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:11,代码来源:Test_Utils.java

示例13: seekCheck

import org.junit.Assert; //导入方法依赖的package包/类
private void seekCheck(InputStream in, int pos) throws Exception {
  byte[] result = new byte[dataLen];
  ((Seekable) in).seek(pos);
  int n = readAll(in, result, 0, dataLen);
  
  Assert.assertEquals(dataLen, n + pos);
  byte[] readData = new byte[n];
  System.arraycopy(result, 0, readData, 0, n);
  byte[] expectedData = new byte[n];
  System.arraycopy(data, pos, expectedData, 0, n);
  Assert.assertArrayEquals(readData, expectedData);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:CryptoStreamsTestBase.java

示例14: testGetXAttrFromJson

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testGetXAttrFromJson() throws IOException {
  String jsonString = 
      "{\"XAttrs\":[{\"name\":\"user.a1\",\"value\":\"0x313233\"}," +
      "{\"name\":\"user.a2\",\"value\":\"0x313131\"}]}";
  ObjectReader reader = new ObjectMapper().reader(Map.class);
  Map<?, ?> json = reader.readValue(jsonString);

  // Get xattr: user.a2
  byte[] value = JsonUtil.getXAttr(json, "user.a2");
  Assert.assertArrayEquals(XAttrCodec.decodeValue("0x313131"), value);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestJsonUtil.java

示例15: test04

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test04() {
    String regular = "^pt=*";

    List<String> matched = FilterUtil.filterByRegular(ALL_STRS, regular);

    System.out.println("matched:" + matched);
    List<String> expected = new ArrayList<String>(ALL_STRS);

    Assert.assertEquals(expected.size(), matched.size());

    Collections.sort(expected);
    Collections.sort(matched);
    Assert.assertArrayEquals(expected.toArray(), matched.toArray());
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:16,代码来源:FilterUtilTest.java


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