From a17886f406d2aa7673e98812e3c3dfe4c6e8459b Mon Sep 17 00:00:00 2001 From: Satyarth Shankar <55573874+satyarth9@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:18:53 +0530 Subject: [PATCH] list vs set unit test (#12807) * BAEL-5751 test commit for checkin builds * BAEL-5751 compiled with java 8 * BAEL-5751 small update * BAEL-5751 added the core code * BAEL-5751 moved code to a different module * BAEL-5751 using assertArrayEquals * BAEL-5751 new line at the end of file --- .../baeldung/listandset/ListAndSetUnitTest.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java index abf275865d..c57c1f96b8 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.listandset; import org.junit.Test; +import org.junit.Assert; import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -37,15 +38,6 @@ public class ListAndSetUnitTest { set2.add(2); set2.add(3); set2.add(4); - boolean ordered = true; - Object[] arr1 = set1.toArray(); - Object[] arr2 = set2.toArray(); - for(int i=0; i < arr1.length; i++){ - if (!arr1[i].equals(arr2[i])) { - ordered = false; - break; - } - } - assertTrue(ordered); + Assert.assertArrayEquals(set1.toArray(), set2.toArray()); } -} \ No newline at end of file +}