Package tests
Class ArrayListTest
java.lang.Object
tests.ArrayListTest
A test class for testing the
MyArrayList
class.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Tests that when trying to add a null value that it will throw a null pointer exception and not increase its size.void
Tests that the add method is able to add elements and increases the size.void
Tests that theaddAll
method will copy one array into another.void
Tests that the AddALl method will throw a NullPointer exception if we pass null into the parameter.void
Tests that the set method throws NullPointerException when given a null value to thechangeTo
param.void
test_Get()
Test that the value returned by the get method is correct.void
Test that the get method throws an IndexOutOfBoundsException when an incorrect index is entered.void
Tests that the IsEmpty returns true ifsize == 0
and false if it is greater than 0.void
Tests that the remove method removes the value stored at the given index.void
Tests that the remove method throws IndexOutOfBoundsException if given an incorrect index.void
test_Set()
Tests that the set method changes the value of the given index with the new value.void
Tests that the set method throws NullPointerException when given a null value to thechangeTo
param.void
Tests that the MyArrayList size method is working correctly.void
Tests thetoArray
method fromMyArrayList
void
Tests that a NullPointerException is thrown if given a null array for the param.
-
Constructor Details
-
ArrayListTest
public ArrayListTest()
-
-
Method Details
-
test_add_Valid
Tests that the add method is able to add elements and increases the size.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_add_Invalid
Tests that when trying to add a null value that it will throw a null pointer exception and not increase its size.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_AddAll
Tests that theaddAll
method will copy one array into another.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_AddAll_Invalid
Tests that the AddALl method will throw a NullPointer exception if we pass null into the parameter.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Size
Tests that the MyArrayList size method is working correctly.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Get
Test that the value returned by the get method is correct.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.
-
test_Get_Invalid
Test that the get method throws an IndexOutOfBoundsException when an incorrect index is entered.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.
-
test_Remove
Tests that the remove method removes the value stored at the given index.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Remove_Invalid
Tests that the remove method throws IndexOutOfBoundsException if given an incorrect index.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Set
Tests that the set method changes the value of the given index with the new value.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Set_Invalid
Tests that the set method throws NullPointerException when given a null value to thechangeTo
param. And throws an IndexOutOfBoundsException when given an invalid index.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_Clear
Tests that the set method throws NullPointerException when given a null value to thechangeTo
param. And throws an IndexOutOfBoundsException when given an invalid index.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_IsEmpty
Tests that the IsEmpty returns true ifsize == 0
and false if it is greater than 0.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.IllegalAccessException
- SeeIllegalAccessException
for more information.
-
test_ToArray
Tests thetoArray
method fromMyArrayList
- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.
-
test_ToArray_Invalid
Tests that a NullPointerException is thrown if given a null array for the param.- Throws:
IllegalArgumentException
- Occurs when a method has been passed the wrong argument.
-