Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions unsorted_list/unsortedlist/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1709718469011</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions unsorted_list/unsortedlist/test/datastruct/MyUnsortedListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package datastruct;

import static org.junit.Assert.*;

import org.junit.Test;

public class MyUnsortedListTest {
@Test
public void testPopOneElem() {
MyUnsortedList<Integer> testList = MyUnsortedList.of(1);
Integer res = 1;
assertEquals(res, testList.pop());
MyUnsortedList<Integer> testListAfter = MyUnsortedList.of();
assertEquals("Pop avec une liste d'un seul élément echou",testListAfter, testList);
}

@Test
public void testPopLast() {
MyUnsortedList<Integer> 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<Integer> testList = MyUnsortedList.of(1,2,3);
MyUnsortedList<Integer> 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<Integer> testList = MyUnsortedList.of();
testList.popLast();
}

@Test
public void testPopLastListOneElem() {
MyUnsortedList<Integer> 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<Integer> testList = MyUnsortedList.of(1,2);
testList.remove(-1);
}

@Test
public void testRemoveElem() {
MyUnsortedList<Integer> 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<Integer> testList = MyUnsortedList.of(1,2);
MyUnsortedList<Integer> resList = MyUnsortedList.of(1);
testList.remove(1);
assertEquals("Le contenue après remove n'est pas bon",resList, testList);
}

@Test
public void testEquals() {
MyUnsortedList<Integer> testList1 = MyUnsortedList.of(1,2);
MyUnsortedList<Integer> testList2 = MyUnsortedList.of(1,2);
assertTrue("testEquals cas 2 listes equales echou",testList1.equals(testList2));
}

@Test
public void testEqualsCase2() {
MyUnsortedList<Integer> testList1 = MyUnsortedList.of(1,2);
MyUnsortedList<Integer> testList2 = MyUnsortedList.of(1);
assertFalse("testEquals cas 2 listes non equales echou",testList1.equals(testList2));
}
}