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
This commit is contained in:
Satyarth Shankar 2022-10-03 12:18:53 +05:30 committed by GitHub
parent da104783ec
commit a17886f406
1 changed files with 3 additions and 11 deletions

View File

@ -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());
}
}
}