Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Term Project Part 1 and 2 for Review #12

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e567b9b
Corrected MathSet type param.
braedonbillingsley Feb 12, 2024
da81a21
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 12, 2024
c8681d8
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 12, 2024
ac7c789
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 12, 2024
88db6fb
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 13, 2024
ed257dc
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 13, 2024
143e97d
Created ArrayList<E> class and implemented List<E> interface and meth…
braedonbillingsley Feb 13, 2024
4bd99da
Implemented methods for LinkedList.java
braedonbillingsley Feb 15, 2024
bf5eecd
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
fc549ff
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
088f5fc
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
dc75164
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
f122c82
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
15b3e40
Implemented methods for LinkedList.java. Completed JUnit tests for Ar…
braedonbillingsley Feb 15, 2024
ab7d510
Implemented 2A, 2B, and confirmed matching output.
braedonbillingsley Feb 16, 2024
13ac8ee
Implemented LinkedStack and matched output for 2C.
braedonbillingsley Feb 16, 2024
fc13f2f
Finished implementation and testing of 2C LinkedQueue and QueueTestCl…
braedonbillingsley Feb 16, 2024
c396fae
Implemented Stats client and matched output to page 125. 2D complete.
braedonbillingsley Feb 16, 2024
52b82c1
Finished run time analysis and class documentation. Fixed what warnin…
braedonbillingsley Feb 16, 2024
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
17 changes: 17 additions & 0 deletions SDEV333-Term-Project.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
251 changes: 251 additions & 0 deletions Tests/ArrayListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Iterator;

import static org.junit.jupiter.api.Assertions.*;

/**
* The ArrayListTest class is used for testing the functionalities of the ArrayList class.
*
* @author Braedon Billingsley
*/
class ArrayListTest {

private ArrayList<Integer> list;

@BeforeEach
void setUp() {
list = new ArrayList<>();
}

@Test
void addFront() {
// Check if list is initially empty
assertTrue(list.isEmpty());

// Adding to an empty list
list.addFront(1);
assertEquals(1, list.size());
assertEquals(1, list.get(0));

// nearly empty list
list.addFront(2);
assertEquals(2, list.size());
assertEquals(2, list.get(0));

// non-empty list
for (int i = 3; i <= 10; i++) {
list.addFront(i);
}
assertEquals(10, list.size());
assertEquals(10, list.get(0));
}

@Test
void addBack() {
// Check if list is initially empty
assertTrue(list.isEmpty());

// empty list
list.addBack(1);
assertEquals(1, list.size());
assertEquals(1, list.get(0));

// nearly empty list
list.addBack(2);
assertEquals(2, list.size());
assertEquals(2, list.get(1));

//non-empty list
for (int i = 3; i <= 10; i++) {
list.addBack(i);
}
assertEquals(10, list.size());
assertEquals(10, list.get(9));
}

@Test
void add() {
// empty list
assertTrue(list.isEmpty());
list.add(0, 30);
assertEquals((Integer)30, list.get(0));

// nearly empty list
list.add(1, 60);
assertEquals((Integer)60, list.get(1));

// non-empty list
for (int i = 2; i < 10; ++i) {
list.add(i, i * 30);
assertEquals((Integer)(i * 30), list.get(i));
}
}

@Test
void get() {
// empty list
assertTrue(list.isEmpty());

list.addBack(40);
assertEquals((Integer)40, list.get(0));

// nearly empty list
list.addBack(80);
assertEquals((Integer)80, list.get(1));

// non-empty list
for (int i = 2; i < 10; ++i) {
list.addBack(i * 40);
assertEquals((Integer)(i * 40), list.get(i));
}
}

@Test
void set() {
// empty list
assertTrue(list.isEmpty());

list.addBack(50);
list.set(0, 60);
assertEquals((Integer)60, list.get(0));

// nearly empty list
list.addBack(100);
list.set(1, 120);
assertEquals((Integer)120, list.get(1));

// non-empty list
for (int i = 2; i < 10; ++i) {
list.addBack(i * 50);
list.set(i, i * 60);
assertEquals((Integer)(i * 60), list.get(i));
}
}

@Test
void removeFront() {

// nearly empty list
list.addBack(15);
list.removeFront();
assertEquals(0, list.size());

// non-empty list
list.addBack(15);
list.addBack(30);
list.removeFront();
assertEquals(1, list.size());
assertEquals((Integer)30, list.get(0));
}

@Test
void removeBack() {

// nearly empty list
list.addBack(25);
list.removeBack();
assertEquals(0, list.size());

// non-empty list
list.addBack(25);
list.addBack(50);
list.removeBack();
assertEquals(1, list.size());
assertEquals((Integer)25, list.get(0));
}

@Test
void remove() {
// empty list

// nearly empty list
list.addBack(35);
list.remove((Integer)35);
assertEquals(0, list.size());

// non-empty list
list.addBack(35);
list.addBack(70);
list.remove((Integer)35);
assertEquals(1, list.size());
assertEquals((Integer)70, list.get(0));
}

@Test
void contains() {
// empty list
assertTrue(list.isEmpty());
assertFalse(list.contains(55));

// nearly empty list
list.addBack(55);
assertTrue(list.contains(55));
assertFalse(list.contains(65));

// non-empty list
list.addBack(65);
assertTrue(list.contains(55));
assertTrue(list.contains(65));
}

@Test
void isEmpty() {
// empty list
assertTrue(list.isEmpty());

// nearly empty list
list.addBack(75);
assertFalse(list.isEmpty());

// non-empty list
list.addBack(85);
assertFalse(list.isEmpty());
}

@Test
void size() {
// empty list
assertEquals(0, list.size());

// nearly empty list
list.addBack(85);
assertEquals(1, list.size());

// non-empty list
list.addBack(170);
assertEquals(2, list.size());
}

@Test
void iterator() {
// empty list
assertTrue(list.isEmpty());

Iterator<Integer> iterator = list.iterator();
assertFalse(iterator.hasNext());

// nearly empty list
list.addBack(10);
iterator = list.iterator();
assertTrue(iterator.hasNext());
assertEquals((Integer)10, iterator.next());

// non-empty list
list.addBack(20);
list.addBack(30);
iterator = list.iterator();

assertTrue(iterator.hasNext());
assertEquals((Integer)10, iterator.next());

assertTrue(iterator.hasNext());
assertEquals((Integer)20, iterator.next());

assertTrue(iterator.hasNext());
assertEquals((Integer)30, iterator.next());

assertFalse(iterator.hasNext());
}
}
Loading