org.junit.jupiter.api.Assertions#assertArrayEquals()源码实例Demo

下面列出了org.junit.jupiter.api.Assertions#assertArrayEquals() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: workcraft   文件: VisualModelTests.java
@Test
public void testGroupingDontGroupConnectionsSimple() {
    VisualModel model = createModel();

    VisualGroup root = (VisualGroup) model.getRoot();
    VisualComponent c1 = createComponent(root);
    VisualComponent c2 = createComponent(root);
    VisualComponent c3 = createComponent(root);
    VisualConnection con1 = createConnection(c1, c2, root);
    VisualConnection con2 = createConnection(c2, c3, root);

    model.addToSelection(con1);
    model.addToSelection(con2);
    model.groupSelection();

    Assertions.assertArrayEquals(new VisualNode[] {c1, c2, c3, con1, con2 },
            root.getChildren().toArray(new VisualNode[0]));
}
 
源代码2 项目: Prism   文件: PrimitiveArrayTest.java
@Test
public void testLongArrayFromJsonObject() {
    JsonArray jsonArray = new JsonArray();
    for (long number : LONG_ARRAY) {
        jsonArray.add(number);
    }

    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("key", PrimitiveArray.LONG_ARRAY_ID);
    jsonObject.add("value", jsonArray);

    PrimitiveArray primitiveArray = PrimitiveArray.of(jsonObject);

    Assertions.assertNotNull(primitiveArray);
    Assertions.assertEquals(primitiveArray.getKey(), PrimitiveArray.LONG_ARRAY_ID);
    Assertions.assertArrayEquals(LONG_ARRAY, (long[]) primitiveArray.getArray());
}
 
源代码3 项目: SimpleNet   文件: PacketTest.java
@ParameterizedTest
@ValueSource(strings = { "Hello World!" })
void testPutStringBigEndianUTF16IntoPacket(String s) {
    packet.putString(s, StandardCharsets.UTF_16);

    byte[] bytes = s.getBytes(StandardCharsets.UTF_16);
    short length = (short) bytes.length;
    
    Assertions.assertEquals(packet.getSize(), Short.BYTES + length);
    Assertions.assertEquals(packet.getQueue().size(), 2);

    ByteBuffer buffer = ByteBuffer.allocate(Short.BYTES + length);
    packet.getQueue().poll().accept(buffer);
    packet.getQueue().poll().accept(buffer);
    buffer.flip();
    Assertions.assertEquals(length, buffer.getShort());

    byte[] data = new byte[length];
    buffer.get(data);
    Assertions.assertArrayEquals(bytes, data);
}
 
源代码4 项目: rapidoid   文件: RapidoidTest.java
protected void eq(double[] expected, double[] actual, double delta) {
	try {
		Assertions.assertArrayEquals(expected, actual, delta);
	} catch (AssertionError e) {
		registerError(e);
		throw e;
	}
}
 
源代码5 项目: Slimefun4   文件: TestMultiBlocks.java
@Test
public void testValidConstructor() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test"));
    MultiBlock multiblock = new MultiBlock(item, new Material[9], BlockFace.DOWN);

    Assertions.assertEquals(item, multiblock.getSlimefunItem());
    Assertions.assertArrayEquals(new Material[9], multiblock.getStructure());
    Assertions.assertEquals(BlockFace.DOWN, multiblock.getTriggerBlock());
}
 
源代码6 项目: camel-quarkus   文件: PlatformHttpTest.java
@Test
public void multipart() {
    final byte[] bytes = new byte[] { 0xc, 0x0, 0xf, 0xe, 0xb, 0xa, 0xb, 0xe };
    final byte[] returnedBytes = RestAssured.given().contentType("multipart/form-data")
            .multiPart("file", "bytes.bin", bytes)
            .formParam("description", "cofe babe")
            .post("/platform-http/multipart")
            .then()
            .statusCode(200)
            .extract().body().asByteArray();
    Assertions.assertArrayEquals(bytes, returnedBytes);
}
 
源代码7 项目: reposilite   文件: MetadataComparatorTest.java
@Test
void testMetadataComparator() {
    List<String> strings = new ArrayList<>(Arrays.asList(STRINGS));
    Collections.shuffle(strings);

    String[] sorted = strings.stream()
            .map(string -> new Pair<>(string.split("[-.]"), string))
            .sorted(METADATA_COMPARATOR)
            .map(Pair::getValue)
            .toArray(String[]::new);

    System.out.println(Arrays.toString(STRINGS));
    System.out.println(Arrays.toString(sorted));
    Assertions.assertArrayEquals(STRINGS, sorted);
}
 
private void assertExistingJarFile(Path mtaArchiveFile, String fileName, byte[] expectedContent) throws IOException {
    try (JarInputStream in = new JarInputStream(Files.newInputStream(mtaArchiveFile))) {
        for (ZipEntry e; (e = in.getNextEntry()) != null;) {
            if (fileName.equals(e.getName()) && !e.isDirectory()) {
                Assertions.assertArrayEquals(expectedContent, IOUtils.toByteArray(in));
                return;
            }
        }
        throw new AssertionError(MessageFormat.format("Zip archive file \"{0}\" could not be found", fileName));
    }
}
 
源代码9 项目: rapidoid   文件: TestCommons.java
protected void eq(byte[] actual, byte[] expected) {
	try {
		Assertions.assertArrayEquals(expected, actual);
	} catch (AssertionError e) {
		registerError(e);
		throw e;
	}
}
 
源代码10 项目: workcraft   文件: VisualNodeTests.java
@Test
public void testGetPath() {
    VisualGroup root = createGroup(null);
    Assertions.assertEquals(1, Hierarchy.getPath(root).length);
    VisualGroup node1 = createGroup(root);
    Assertions.assertArrayEquals(new VisualGroup[]{root, node1}, Hierarchy.getPath(node1));
    VisualGroup node2 = createGroup(node1);
    Assertions.assertArrayEquals(new VisualGroup[]{root, node1, node2}, Hierarchy.getPath(node2));
}
 
源代码11 项目: adaptive-radix-tree   文件: ARTUnitTest.java
@Test
public void testRemovePessimisticLCPFromOptimisticCompressedPath1() {
	InnerNode node = new Node4();
	// number of optimistic equal characters in all children of this InnerNode
	int optimisticCPLength = 10, lcp = 3;
	String compressedPath = "abcdefgh"; // pessimistic compressed path
	System.arraycopy(compressedPath.getBytes(), 0, node.prefixKeys, 0, compressedPath.length());
	node.prefixLen = compressedPath
			.length() + optimisticCPLength;
	int expectedNewPrefixLen = compressedPath.length() + optimisticCPLength - lcp - 1;

	InnerNode nodeLeft = new Node4();
	node.addChild((byte) 'i', nodeLeft);
	node.addChild((byte) 'j', Mockito.spy(Node.class));

	String prevDepth = "prevdepthbytes";
	String optimisticPath = "0123456789";
	String key = prevDepth + compressedPath + optimisticPath + "ik";
	LeafNode<String, String> nodeLeftLeft = new LeafNode<>(BinaryComparables.forString().get(key), key, "value");
	nodeLeft.addChild((byte) 'k', nodeLeftLeft);
	nodeLeft.addChild((byte) 'l', Mockito.spy(Node.class));

	AdaptiveRadixTree.removePessimisticLCPFromCompressedPath(node, prevDepth.length() + lcp, lcp);
	Assertions.assertEquals(expectedNewPrefixLen, node.prefixLen);


	Assertions.assertArrayEquals("efgh0123".getBytes(), getValidPrefixKey(node));
}
 
源代码12 项目: commons-dbcp   文件: TestPStmtKey.java
/**
 * Tests {@link org.apache.commons.dbcp2.PStmtKey#PStmtKey(String, String, String, int[])}.
 *
 * See https://issues.apache.org/jira/browse/DBCP-494
 */
@Test
public void testCtorStringStringArrayOfNullInts() {
    final int[] input = null;
    final PStmtKey pStmtKey = new PStmtKey("", "", "", input);
    Assertions.assertArrayEquals(input, pStmtKey.getColumnIndexes());
}
 
源代码13 项目: commons-numbers   文件: ComplexUtilsTest.java
@Test
void testComplexToInterleaved() {
    setArrays();
    Assertions.assertArrayEquals(di, ComplexUtils.complex2Interleaved(c), Math.ulp(1.0), msg);
    // Interleaved complex to float, whole array
    Assertions.assertArrayEquals(fi, ComplexUtils.complex2InterleavedFloat(c), Math.ulp(1.0f), msg);

    // 2d
    TestUtils.assertEquals(msg, di2d0, ComplexUtils.complex2Interleaved(c2d, 0), 0);
    TestUtils.assertEquals(msg, di2d1, ComplexUtils.complex2Interleaved(c2d, 1), 0);
    TestUtils.assertEquals(msg, di2d1, ComplexUtils.complex2Interleaved(c2d), 0);

    TestUtils.assertEquals(msg, fi2d0, ComplexUtils.complex2InterleavedFloat(c2d, 0), 0);
    TestUtils.assertEquals(msg, fi2d1, ComplexUtils.complex2InterleavedFloat(c2d, 1), 0);
    TestUtils.assertEquals(msg, fi2d1, ComplexUtils.complex2InterleavedFloat(c2d), 0);

    // 3d
    TestUtils.assertEquals(msg, di3d0, ComplexUtils.complex2Interleaved(c3d, 0), 0);
    TestUtils.assertEquals(msg, di3d1, ComplexUtils.complex2Interleaved(c3d, 1), 0);
    TestUtils.assertEquals(msg, di3d2, ComplexUtils.complex2Interleaved(c3d, 2), 0);
    TestUtils.assertEquals(msg, di3d2, ComplexUtils.complex2Interleaved(c3d), 0);

    TestUtils.assertEquals(msg, fi3d0, ComplexUtils.complex2InterleavedFloat(c3d, 0), 0);
    TestUtils.assertEquals(msg, fi3d1, ComplexUtils.complex2InterleavedFloat(c3d, 1), 0);
    TestUtils.assertEquals(msg, fi3d2, ComplexUtils.complex2InterleavedFloat(c3d, 2), 0);
    TestUtils.assertEquals(msg, fi3d2, ComplexUtils.complex2InterleavedFloat(c3d), 0);

    // 4d
    TestUtils.assertEquals(msg, di4d0, ComplexUtils.complex2Interleaved(c4d, 0), 0);
    TestUtils.assertEquals(msg, di4d1, ComplexUtils.complex2Interleaved(c4d, 1), 0);
    TestUtils.assertEquals(msg, di4d2, ComplexUtils.complex2Interleaved(c4d, 2), 0);
    TestUtils.assertEquals(msg, di4d3, ComplexUtils.complex2Interleaved(c4d, 3), 0);
    TestUtils.assertEquals(msg, di4d3, ComplexUtils.complex2Interleaved(c4d), 0);
}
 
public static void main(String[] args) {
    TreeNode tree = TreeUtils.buildTree(3, 9, 20, null, null, 15, 7);
    List<List<Integer>> resultList = levelOrderBottom(tree);
    List<List<Integer>> expectList = new LinkedList<>();
    expectList.add(Arrays.asList(15, 7));
    expectList.add(Arrays.asList(9, 20));
    expectList.add(Arrays.asList(3));
    Assertions.assertArrayEquals(expectList.toArray(), resultList.toArray());
}
 
源代码15 项目: javageci   文件: TestArrayTools.java
@Test
@DisplayName("Appending zero length arrays returns new array")
void appendZeroLengthArray() {
    final var a = new String[]{"a", "b", "c"};
    final var b = new String[0];
    final var result = ArrayTools.join(a, b);
    Assertions.assertNotSame(a, result);
    Assertions.assertArrayEquals(a, result);
}
 
源代码16 项目: Prism   文件: PrimitiveArrayTest.java
@Test
public void testIntArrayFromIntArray() {
    PrimitiveArray primitiveArray = new PrimitiveArray(INT_ARRAY);

    Assertions.assertEquals(primitiveArray.getKey(), PrimitiveArray.INT_ARRAY_ID);
    Assertions.assertArrayEquals(INT_ARRAY, (int[]) primitiveArray.getArray());
}
 
public static void main(String[] args) {
    ListNode head1 = ListUtil.buildList(1, 4, 5);
    ListNode head2 = ListUtil.buildList(1, 3, 4);
    ListNode head3 = ListUtil.buildList(2, 6);
    ListNode[] array = new ListNode[] { head1, head2, head3 };
    ListNode result = mergeKLists(array);
    List<Integer> list = ListUtil.toList(result);
    System.out.println(list);
    Assertions.assertArrayEquals(new Integer[] { 1, 1, 2, 3, 4, 4, 5, 6 }, list.toArray(new Integer[0]));
}
 
源代码18 项目: panda   文件: FileUtilsTest.java
@Test
void getContentAsLines() throws IOException {
    Assertions.assertArrayEquals(CONTENT.split(System.lineSeparator()), FileUtils.getContentAsLines(content));
}
 
源代码19 项目: panda   文件: LinearPatternTest.java
@Test
void testIdentifiers() {
    Assertions.assertArrayEquals(ArrayUtils.of("a", "b", "c"), identifiersOf("a:unit b:unit c:unit", "unit unit unit"));
    Assertions.assertArrayEquals(ArrayUtils.of("a", "b", "c"), identifiersOf("a:unit b:* c:unit", "unit random unit"));
}
 
public static void main(String[] args) {
    TreeNode tree = TreeUtils.buildTree(1, 2, 3, 5);
    System.out.println("result = " + binaryTreePaths(tree));
    Assertions.assertArrayEquals(Arrays.asList("1->2->5", "1->3").toArray(),
        binaryTreePaths(tree).toArray(new String[0]));
}