diff --git a/unsorted_list/unsortedlist/.project b/unsorted_list/unsortedlist/.project index 1e897a7..4aec80a 100644 --- a/unsorted_list/unsortedlist/.project +++ b/unsorted_list/unsortedlist/.project @@ -14,4 +14,15 @@ org.eclipse.jdt.core.javanature + + + 1709718469011 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/unsorted_list/unsortedlist/bin/datastruct/EmptyListException.class b/unsorted_list/unsortedlist/bin/datastruct/EmptyListException.class new file mode 100644 index 0000000..6ff1b2e Binary files /dev/null and b/unsorted_list/unsortedlist/bin/datastruct/EmptyListException.class differ diff --git a/unsorted_list/unsortedlist/bin/datastruct/ListManipulator.class b/unsorted_list/unsortedlist/bin/datastruct/ListManipulator.class new file mode 100644 index 0000000..4ce591c Binary files /dev/null and b/unsorted_list/unsortedlist/bin/datastruct/ListManipulator.class differ diff --git a/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList$Link.class b/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList$Link.class new file mode 100644 index 0000000..0baebe5 Binary files /dev/null and b/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList$Link.class differ diff --git a/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList.class b/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList.class new file mode 100644 index 0000000..8a3b079 Binary files /dev/null and b/unsorted_list/unsortedlist/bin/datastruct/MyUnsortedList.class differ diff --git a/unsorted_list/unsortedlist/bin/datastruct/UnsortedList.class b/unsorted_list/unsortedlist/bin/datastruct/UnsortedList.class new file mode 100644 index 0000000..b3ea749 Binary files /dev/null and b/unsorted_list/unsortedlist/bin/datastruct/UnsortedList.class differ diff --git a/unsorted_list/unsortedlist/test/datastruct/MyUnsortedListTest.java b/unsorted_list/unsortedlist/test/datastruct/MyUnsortedListTest.java new file mode 100644 index 0000000..9734882 --- /dev/null +++ b/unsorted_list/unsortedlist/test/datastruct/MyUnsortedListTest.java @@ -0,0 +1,79 @@ +package datastruct; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class MyUnsortedListTest { + @Test + public void testPopOneElem() { + MyUnsortedList testList = MyUnsortedList.of(1); + Integer res = 1; + assertEquals(res, testList.pop()); + MyUnsortedList testListAfter = MyUnsortedList.of(); + assertEquals("Pop avec une liste d'un seul élément echou",testListAfter, testList); + } + + @Test + public void testPopLast() { + MyUnsortedList testList = MyUnsortedList.of(1,2,3); + Integer res = 3; + assertEquals("L'élément enlevé par popLast n'est pas bon",res, testList.popLast()); + } + + @Test + public void testPopLastVerifierList() { + MyUnsortedList testList = MyUnsortedList.of(1,2,3); + MyUnsortedList testListAfter = MyUnsortedList.of(1,2); + testList.popLast(); + assertEquals("Le contenu de la liste après popLast n'est pas bon",testList,testListAfter); + } + + @Test(expected = EmptyListException.class) + public void testPopLastListVide() { + MyUnsortedList testList = MyUnsortedList.of(); + testList.popLast(); + } + + @Test + public void testPopLastListOneElem() { + MyUnsortedList testList = MyUnsortedList.of(1); + Integer pop = 1; + assertEquals("PopLast avec liste d'un seul element echou",pop, testList.popLast()); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testRemoveInvalideIndex() { + MyUnsortedList testList = MyUnsortedList.of(1,2); + testList.remove(-1); + } + + @Test + public void testRemoveElem() { + MyUnsortedList testList = MyUnsortedList.of(1,2); + Integer res = 2; + assertEquals("L'élément enlevé par remove n'est pas bon",res, testList.remove(1)); + } + + @Test + public void testRemoveElemVerifierList() { + MyUnsortedList testList = MyUnsortedList.of(1,2); + MyUnsortedList resList = MyUnsortedList.of(1); + testList.remove(1); + assertEquals("Le contenue après remove n'est pas bon",resList, testList); + } + + @Test + public void testEquals() { + MyUnsortedList testList1 = MyUnsortedList.of(1,2); + MyUnsortedList testList2 = MyUnsortedList.of(1,2); + assertTrue("testEquals cas 2 listes equales echou",testList1.equals(testList2)); + } + + @Test + public void testEqualsCase2() { + MyUnsortedList testList1 = MyUnsortedList.of(1,2); + MyUnsortedList testList2 = MyUnsortedList.of(1); + assertFalse("testEquals cas 2 listes non equales echou",testList1.equals(testList2)); + } +} \ No newline at end of file