-
Test Cases for the constructorTest() method:
a. Test if the constructorTest() method returns a Sequence object with an empty sequence.
- Call constructorTest() method and store the result in a variable.
- Use the length() method to check the length of the sequence.
- Verify that the length is 0.
b. Test if the constructorTest() method returns a new instance of Sequence each time it is called.
- Call constructorTest() method twice and store the results in two different variables.
- Use the equals() method to check if the two sequence objects are equal.
- Verify that the two objects are not equal.
-
Test Cases for the constructorRef() method:
a. Test if the constructorRef() method returns a Sequence object with an empty sequence.
- Call constructorRef() method and store the result in a variable.
- Use the length() method to check the length of the sequence.
- Verify that the length is 0.
b. Test if the constructorRef() method returns a new instance of Sequence each time it is called.
- Call constructorRef() method twice and store the results in two different variables.
- Use the equals() method to check if the two sequence objects are equal.
- Verify that the two objects are not equal.
-
Test Cases for the createFromArgsTest() method:
a. Test if the createFromArgsTest() method creates a Sequence object with the given entries.
- Call createFromArgsTest() method with a few strings as arguments.
- Use the length() method to check the length of the sequence.
- Verify that the length is equal to the number of arguments passed.
b. Test if the createFromArgsTest() method adds the entries to the sequence in the correct order.
- Call createFromArgsTest() method with a few strings as arguments.
- Use the remove() method to remove the last entry from the sequence.
- Call the get() method to get the last entry of the sequence.
- Verify that the last entry is not equal to the last argument passed to createFromArgsTest() method.
-
Test Cases for the createFromArgsRef() method:
a. Test if the createFromArgsRef() method creates a Sequence object with the given entries.
- Call createFromArgsRef() method with a few strings as arguments.
- Use the length() method to check the length of the sequence.
- Verify that the length is equal to the number of arguments passed.
b. Test if the createFromArgsRef() method adds the entries to the sequence in the correct order.
- Call createFromArgsRef() method with a few strings as arguments.
- Use the remove() method to remove the last entry from the sequence.
- Call the get() method to get the last entry of the sequence.
- Verify that the last entry is not equal to the last argument passed to createFromArgsRef() method.
-
Test Cases for the add() method:
a. Test if the add() method adds an entry to the sequence at the specified index.
- Create a Sequence object using the constructorTest() method.
- Call the add() method to add a string at a specified index.
- Use the get() method to get the entry at the specified index.
- Verify that the entry is equal to the string added.
b. Test if the add() method increases the length of the sequence by 1.
- Create a Sequence object using the constructorTest() method.
- Use the length() method to get the initial length of the sequence.
- Call the add() method to add a string at a specified index.
- Use the length() method again to get the updated length of the sequence.
- Verify that the updated length is equal to the initial length + 1.
-
Test Cases for the remove() method:
a. Test if the remove() method removes the entry at the specified index from the sequence.
- Create a Sequence object using the constructorTest() method.
- Add a few strings to the sequence using the add() method.
- Use the length() method to get the initial length of the sequence.
- Call the remove() method to remove an entry at a specified index.
- Use the get() method to get the entry at the specified index.
- Verify that the entry is not equal to the string removed.
b. Test if the remove() method decreases the length of the sequence by 1.
- Create a Sequence object using the constructorTest() method.
- Add a few strings to the sequence using the add() method.
- Use the length() method to get the initial length of the sequence.
- Call the remove() method to remove an entry at a specified index.
- Use the length() method again to get the updated length of the sequence.
- Verify that the updated length is equal to the initial length - 1.
-
Test Cases for the length() method:
a. Test if the length() method returns 0 for an empty sequence.
- Create a Sequence object using the constructorTest() method.
- Use the length() method to get the length of the sequence.
- Verify that the length is 0.
b. Test if the length() method returns the correct length of the sequence with multiple entries.
- Create a Sequence object using the constructorTest() method.
- Add a few strings to the sequence using the add() method.
- Use the length() method to get the length of the sequence.
- Verify that the length is equal to the number of strings added.