diff --git a/.gitignore b/.gitignore
index 3a3154e..659c6d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,28 +1,28 @@
-.DS_Store
-# Compiled class file
-*.class
-
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-.idea
-*.iml
+.DS_Store
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+.idea
+*.iml
target
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 0fbc4f2..2086649 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
-language: java
-jdk: openjdk17
-jobs:
- include:
- - script: mvn clean verify package
-after_success:
+language: java
+jdk: openjdk17
+jobs:
+ include:
+ - script: mvn clean verify package
+after_success:
- bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
diff --git a/README.md b/README.md
index 60bfad4..ab81ee4 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,32 @@
-[](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity)
-
-@BCComputerScience
-
-# Spr23-5540-CodeReviewActivity
-
-## Task 1: Open a Pull request
-1. **Clone/Fork** this repository that contains the unit test assignmentSkeleton from here. You should have access now, because you can see this ReadMe file.
-2. If Cloned, create a branch to the local repository named "First_lastName_CodeReview"
-3. Update the skeleton project with your final project implementation from Assignment two
-4. Don't change the pom.xml or the .travis.yml file
-5. Commit your changes to the **local repository**
-6. Push your local barnch to the remote
-7. Complete a pull request for the updates
-
-
-### Warning: You have to complete Task 1 to be appointed as a reviewer for a pull request and start Task 2
-
-## Task 2: Code review for the assigned pull request
-1. You will be assigned to a students' submission to complete the code review for their project implementation.
-2. You need to complete the code reviews for the pull request assigned to you.
-3. Check the build for the assigned code and note if there is any errors
-4. If there is a build issue indiacte it in your review comments
-5. Also, add at least four meaningful inline reviews of the class implementation, the test class, and one overall recap. Agreeing on the implementation is not counted as a meaningful review.
-Approve or request changes to the pull request
-6. Take screenshots for your reviews.
-
-### Check Canvas for more instructions on how to ccomplete each task
-
-Enjoy your code review experience.
-
-Sara
+[](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity)
+
+@BCComputerScience
+
+# Spr23-5540-CodeReviewActivity
+
+## Task 1: Open a Pull request
+1. **Clone/Fork** this repository that contains the unit test assignmentSkeleton from here. You should have access now, because you can see this ReadMe file.
+2. If Cloned, create a branch to the local repository named "First_lastName_CodeReview"
+3. Update the skeleton project with your final project implementation from Assignment two
+4. Don't change the pom.xml or the .travis.yml file
+5. Commit your changes to the **local repository**
+6. Push your local barnch to the remote
+7. Complete a pull request for the updates
+
+
+### Warning: You have to complete Task 1 to be appointed as a reviewer for a pull request and start Task 2
+
+## Task 2: Code review for the assigned pull request
+1. You will be assigned to a students' submission to complete the code review for their project implementation.
+2. You need to complete the code reviews for the pull request assigned to you.
+3. Check the build for the assigned code and note if there is any errors
+4. If there is a build issue indiacte it in your review comments
+5. Also, add at least four meaningful inline reviews of the class implementation, the test class, and one overall recap. Agreeing on the implementation is not counted as a meaningful review.
+Approve or request changes to the pull request
+6. Take screenshots for your reviews.
+
+### Check Canvas for more instructions on how to ccomplete each task
+
+Enjoy your code review experience.
+
+Sara
diff --git a/pom.xml b/pom.xml
index 6330c14..0653770 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,77 +1,77 @@
-
-
- 4.0.0
-
- org.example
- UnitTestAssignment
- 1.0-SNAPSHOT
-
-
- 15
- 15
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- 5.7.2
- test
-
-
- org.hamcrest
- hamcrest-library
- 2.2
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M5
-
-
- org.jacoco
- jacoco-maven-plugin
- 0.8.7
-
-
-
- prepare-agent
-
-
-
- report
- test
-
- report
-
-
-
- jacoco-check
-
- check
-
-
-
-
- PACKAGE
-
-
- LINE
- COVEREDRATIO
- 0.9
-
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ org.example
+ UnitTestAssignment
+ 1.0-SNAPSHOT
+
+
+ 15
+ 15
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.7.2
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ 2.2
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M5
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.7
+
+
+
+ prepare-agent
+
+
+
+ report
+ test
+
+ report
+
+
+
+ jacoco-check
+
+ check
+
+
+
+
+ PACKAGE
+
+
+ LINE
+ COVEREDRATIO
+ 0.9
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/StringManipulation.java b/src/main/java/StringManipulation.java
index 4deb6f1..128c8cf 100644
--- a/src/main/java/StringManipulation.java
+++ b/src/main/java/StringManipulation.java
@@ -1,33 +1,62 @@
-public class StringManipulation implements StringManipulationInterface {
-
- @Override
- public String getString() {
- return null;
- }
-
- @Override
- public void setString(String string) {
- }
-
- @Override
- public int count() {
- return 0;
- }
-
- @Override
- public String removeNthCharacter(int n, boolean maintainSpacing) {
- return null;
- }
-
- @Override
- public String[] getSubStrings(int startWord, int endWord) {
- return null;
- }
-
- @Override
- public String restoreString(int[] indices) {
- return null;
- }
-
-
-}
+import java.util.Arrays;
+
+public class StringManipulation implements StringManipulationInterface {
+ private String value;
+
+ @Override
+ public String getString() {
+ return value;
+ }
+
+ @Override
+ public void setString(String string) {
+ value = string;
+ }
+
+ @Override
+ public int count() {
+ if (value.trim() == "") return 0;
+ return value.trim().split("\\s+").length;
+ }
+
+ @Override
+ public String removeNthCharacter(int n, boolean maintainSpacing) {
+
+ char[] chars = value.toCharArray();
+ String res = "";
+
+ for (int i = 0; i < chars.length; i++) {
+
+ if ( (i+1)%n != 0 ) res += chars[i];
+ else if (maintainSpacing) res += " ";
+ }
+ return res;
+ }
+
+ @Override
+ public String[] getSubStrings(int startWord, int endWord){
+ String[] words = value.trim().split("\\s+");
+ if (value.trim() == "" || endWord < startWord || startWord > words.length) throw new IllegalArgumentException();
+ return Arrays.copyOfRange(value.trim().split("\\s+"), startWord-1, endWord+1);
+ }
+
+ @Override
+ public String restoreString(int[] indices) {
+ if (value == null || indices.length != value.length()) throw new IllegalArgumentException();
+
+ //output string
+ String res = "";
+
+ //string value to char array
+ char[] chars = value.toCharArray();
+
+ for (int index : indices) {
+ if (index >= 0 && index < chars.length) res += chars[index];
+ else throw new ArrayIndexOutOfBoundsException();
+ }
+
+ return res;
+ }
+
+
+}
diff --git a/src/main/java/StringManipulationInterface.java b/src/main/java/StringManipulationInterface.java
index 87127e7..c88847a 100644
--- a/src/main/java/StringManipulationInterface.java
+++ b/src/main/java/StringManipulationInterface.java
@@ -1,108 +1,108 @@
-/**
- * This is an interface for a simple class that represents a string, defined
- * as a sequence of characters.
- *
- */
-public interface StringManipulationInterface {
-
- /**
- * Returns the current string. If the string is null, it should return null.
- *
- * @return Current string
- */
- String getString();
-
- /**
- * Sets the value of the current string.
- *
- * @param string The value to be set
- */
- void setString(String string);
-
- /**
- * Returns the number of words in the current string
- *
- * @return Number of words in the current string
- */
- int count();
-
- /**
- * Returns a string that consists of all characters in the original string except for the characters
- * in positions n, 2n, 3n, and so on, either deleting those or replacing them
- * with a white space. The characters in the resulting string should be in the same order
- * and with the same case as in the current string.
- *
- *
- * Examples:
- * - For n=2 and maintainSpacing=false, the method would return the string without the 2nd, 4th,
- * 6th, and so on characters in the string.
- * - For n=3 and maintainSpacing=true, the method would return the string with a space replacing
- * the 3nd, 6th, 9th, and so on characters in the string.
- *
- * Values n and maintainSpacing are passed as parameters. The starting character is considered to be in Position 1.
- * Special cases expected behavior
- *
- * throws IndexOutOfBoundsException If n is greater than the string length.
- * throws IllegalArgumentException If "n" less than or equal to zero.
- *
- * @param n Determines the positions of the characters to be returned
- * @param maintainSpacing Determines whether replace the missing characters with a space, in order
- * to maintain the length of the original string.
- * @return String made of characters at positions other than n, 2n, and so on in the current string
- *
- *
- */
- String removeNthCharacter(int n, boolean maintainSpacing);
-
- /**
- * Returns the words from position "startWord" to position "endWord"
- * in the sentence, with 1 being the first Word in the String
- *
- * @param startWord
- * Position of the first word to return
- * @param endWord
- * Position of the last word to return
- * @return
- * String array of the words from position "startWord" to position "endWord"
- * Special cases
- * throws IllegalArgumentException
- * If either "startWord" or "endWord" are invalid (i.e.,
- * "startWord" <= 0, "endWord" <= 0, or "startWord"
- * > "endWord")
- * throws IndexOutOfBoundsException
- * If the string has less than "endWord" words in it
- */
- String[] getSubStrings(int startWord, int endWord);
-
- /**
- * Given a string s and an integer array indices of the same length.
- * The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
- * Return the shuffled string.
- * example:
- * Input: string = "UnitTest", indices = [4,5,6,7,0,1,2,3]
- * Output: "TestUnit"
- * Explanation:
- * indices: 4 5 6 7 0 1 2 3
- * String: U n i t T e s t
- * Actions to Shuffle: Shift U to 4th position, n to 5th position, i to 6th position ......
- * Output: T e s t U n i t
- * 0 1 2 3 4 5 6 7
- * As shown, "UnitTest" becomes "TestUnit" after shuffling.
- *
- * special cases and assumptions
- * s contains lower-case or upper-case English letters.
- * All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
- * indices length is the same as the string length.
- *
- * throws IllegalArgumentException if not s.length == indices.length == n
- * throws IndexOutOfBoundsException if indices[i]< 0 or indices[i]>= string length
- *
- * @param indices is an integer array for shuffled string new indices positions
- * the character at the ith position moves to indices[i] in the shuffled string.
- *
- * @return Return the shuffled string.
- *
- * */
- String restoreString(int[] indices);
-
-}
+/**
+ * This is an interface for a simple class that represents a string, defined
+ * as a sequence of characters.
+ *
+ */
+public interface StringManipulationInterface {
+
+ /**
+ * Returns the current string. If the string is null, it should return null.
+ *
+ * @return Current string
+ */
+ String getString();
+
+ /**
+ * Sets the value of the current string.
+ *
+ * @param string The value to be set
+ */
+ void setString(String string);
+
+ /**
+ * Returns the number of words in the current string
+ *
+ * @return Number of words in the current string
+ */
+ int count();
+
+ /**
+ * Returns a string that consists of all characters in the original string except for the characters
+ * in positions n, 2n, 3n, and so on, either deleting those or replacing them
+ * with a white space. The characters in the resulting string should be in the same order
+ * and with the same case as in the current string.
+ *
+ *
+ * Examples:
+ * - For n=2 and maintainSpacing=false, the method would return the string without the 2nd, 4th,
+ * 6th, and so on characters in the string.
+ * - For n=3 and maintainSpacing=true, the method would return the string with a space replacing
+ * the 3nd, 6th, 9th, and so on characters in the string.
+ *
+ * Values n and maintainSpacing are passed as parameters. The starting character is considered to be in Position 1.
+ * Special cases expected behavior
+ *
+ * throws IndexOutOfBoundsException If n is greater than the string length.
+ * throws IllegalArgumentException If "n" less than or equal to zero.
+ *
+ * @param n Determines the positions of the characters to be returned
+ * @param maintainSpacing Determines whether replace the missing characters with a space, in order
+ * to maintain the length of the original string.
+ * @return String made of characters at positions other than n, 2n, and so on in the current string
+ *
+ *
+ */
+ String removeNthCharacter(int n, boolean maintainSpacing);
+
+ /**
+ * Returns the words from position "startWord" to position "endWord"
+ * in the sentence, with 1 being the first Word in the String
+ *
+ * @param startWord
+ * Position of the first word to return
+ * @param endWord
+ * Position of the last word to return
+ * @return
+ * String array of the words from position "startWord" to position "endWord"
+ * Special cases
+ * throws IllegalArgumentException
+ * If either "startWord" or "endWord" are invalid (i.e.,
+ * "startWord" <= 0, "endWord" <= 0, or "startWord"
+ * > "endWord")
+ * throws IndexOutOfBoundsException
+ * If the string has less than "endWord" words in it
+ */
+ String[] getSubStrings(int startWord, int endWord);
+
+ /**
+ * Given a string s and an integer array indices of the same length.
+ * The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
+ * Return the shuffled string.
+ * example:
+ * Input: string = "UnitTest", indices = [4,5,6,7,0,1,2,3]
+ * Output: "TestUnit"
+ * Explanation:
+ * indices: 4 5 6 7 0 1 2 3
+ * String: U n i t T e s t
+ * Actions to Shuffle: Shift U to 4th position, n to 5th position, i to 6th position ......
+ * Output: T e s t U n i t
+ * 0 1 2 3 4 5 6 7
+ * As shown, "UnitTest" becomes "TestUnit" after shuffling.
+ *
+ * special cases and assumptions
+ * s contains lower-case or upper-case English letters.
+ * All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
+ * indices length is the same as the string length.
+ *
+ * throws IllegalArgumentException if not s.length == indices.length == n
+ * throws IndexOutOfBoundsException if indices[i]< 0 or indices[i]>= string length
+ *
+ * @param indices is an integer array for shuffled string new indices positions
+ * the character at the ith position moves to indices[i] in the shuffled string.
+ *
+ * @return Return the shuffled string.
+ *
+ * */
+ String restoreString(int[] indices);
+
+}
diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java
index 6692c2c..109994d 100644
--- a/src/test/java/StringManipulationTest.java
+++ b/src/test/java/StringManipulationTest.java
@@ -1,149 +1,209 @@
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-
-import static org.junit.jupiter.api.Assertions.*;
-
-public class StringManipulationTest {
-
- private StringManipulationInterface manipulatedstring;
-
- @BeforeEach
- public void setUp() {
- manipulatedstring = new StringManipulation();
- }
-
- @AfterEach
- public void tearDown() {
- manipulatedstring = null;
- }
-
- @Test
- public void testCount1() {
- manipulatedstring.setString("This is my string");
- int length = manipulatedstring.count();
- assertEquals(4, length);
- }
-
- @Test
- public void testCount2() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testCount3() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testCount4() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRemoveNthCharacter1() {
- manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?");
- assertEquals("I' bttr uts0e 16tsinths trn6 rgh?", manipulatedstring.removeNthCharacter(3, false));
- }
-
- @Test
- public void testRemoveNthCharacter2() {
- manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?");
- assertEquals("I' b tt r ut s0 e 16 ts in th s tr n6 r gh ?", manipulatedstring.removeNthCharacter(3, true));
- }
-
- @Test
- public void testRemoveNthCharacter3() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRemoveNthCharacter4() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRemoveNthCharacter5() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRemoveNthCharacter6() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRemoveNthCharacter7() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testGeSubStrings1() {
- manipulatedstring.setString("This is my string");
- String [] sStings = manipulatedstring.getSubStrings(3, 4);
-
- assertEquals(sStings[0], "my");
- assertEquals(sStings[1], "string");
- }
-
- @Test
- public void testGeSubStrings2() {
- fail("Not yet implemented");
- }
- @Test
- public void testGeSubStrings3() {
- fail("Not yet implemented");
- }
- @Test
- public void testGeSubStrings4() {
- fail("Not yet implemented");
- }
- @Test
- public void testGeSubStrings5() {
- fail("Not yet implemented");
- }
- @Test
- public void testGeSubStrings6() {
- fail("Not yet implemented");
- }
-
- @Test
- public void testRestoreString1()
- {
- manipulatedstring.setString("art");
- int [] array;
- array=new int[]{1,0,2};
- String restoreString = manipulatedstring.restoreString(array);
- assertEquals(restoreString, "rat");
- }
-
- @Test
- public void testRestoreString2()
- {
- fail("Not yet implemented");
-
- }
-
- @Test
- public void testRestoreString3()
- {
- fail("Not yet implemented");
-
- }
-
- @Test
- public void testRestoreString4()
- {
- fail("Not yet implemented");
-
- }
-
- @Test
- public void testRestoreString5()
- {
- fail("Not yet implemented");
-
- }
-
-}
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class StringManipulationTest {
+
+ private StringManipulationInterface manipulatedstring;
+
+ @BeforeEach
+ public void setUp() {
+ manipulatedstring = new StringManipulation();
+ }
+
+ @AfterEach
+ public void tearDown() {
+ manipulatedstring = null;
+ }
+
+ @Test
+ //checks regular working test count
+ public void testCount1() {
+ manipulatedstring.setString("This is my string");
+ int length = manipulatedstring.count();
+ assertEquals(4, length);
+ }
+
+ @Test
+ //tests trailing spaces
+ public void testCount2() {
+ manipulatedstring.setString("Hey there bud, I love ice cream! ");
+ int length = manipulatedstring.count();
+ assertEquals(7, length);
+ }
+
+ @Test
+ //tests empty value
+ public void testCount3() {
+ manipulatedstring.setString("");
+ int length = manipulatedstring.count();
+ assertEquals(0, length);
+ }
+
+ @Test
+ //tests large trailing space within words
+ public void testCount4() {
+ manipulatedstring.setString("wow!... wow!");
+ int length = manipulatedstring.count();
+ assertEquals(2, length);
+ }
+
+ @Test
+ //tests with removing every 3rd character without maintaining spacing
+ public void testRemoveNthCharacter1() {
+ manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?");
+ assertEquals("I' bttr uts0e 16tsinths trn6 rgh?", manipulatedstring.removeNthCharacter(3, false));
+ }
+
+ @Test
+ //tests with removing every 3rd character WITH maintaining spacing
+ public void testRemoveNthCharacter2() {
+ manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?");
+ assertEquals("I' b tt r ut s0 e 16 ts in th s tr n6 r gh ?", manipulatedstring.removeNthCharacter(3, true));
+ }
+
+ @Test
+ //tests a different value for Nth character removed argument
+ public void testRemoveNthCharacter3() {
+ manipulatedstring.setString("I love chihuahuas!!!");
+ assertEquals("Ilv hhaus!", manipulatedstring.removeNthCharacter(2, false));
+ }
+
+ @Test
+ //tests empty value
+ public void testRemoveNthCharacter4() {
+ manipulatedstring.setString("");
+ assertEquals("", manipulatedstring.removeNthCharacter(2, false));
+ }
+
+ @Test
+ //tests removing 1 value
+ public void testRemoveNthCharacter5() {
+ manipulatedstring.setString("a");
+ assertEquals("", manipulatedstring.removeNthCharacter(1, false));
+ }
+
+ @Test
+ //tests removing an Nth character that is never reached (stays the same)
+ public void testRemoveNthCharacter6() {
+ manipulatedstring.setString("The new Spiderverse was soooo good!");
+ assertEquals("The new Spiderverse was soooo good!", manipulatedstring.removeNthCharacter(50, false));
+ }
+
+ @Test
+ //tests with removing EVERY character while maintaining spacing, effectively replacing every char with " "
+ public void testRemoveNthCharacter7() {
+ manipulatedstring.setString("aaa");
+ assertEquals(" ", manipulatedstring.removeNthCharacter(1, true));
+ }
+
+ @Test
+ //tests regular substring get
+ public void testGeSubStrings1() {
+ manipulatedstring.setString("This is my string");
+ String [] sStings = manipulatedstring.getSubStrings(3, 4);
+
+ assertEquals(sStings[0], "my");
+ assertEquals(sStings[1], "string");
+ }
+
+ @Test
+ //another substring get with different parameters and string value
+ public void testGeSubStrings2() {
+ manipulatedstring.setString("With great responsibility comes great power.");
+ String [] sStings = manipulatedstring.getSubStrings(1, 3);
+
+ assertEquals(sStings[1], "great");
+ assertEquals(sStings[2], "responsibility");
+ }
+ @Test
+ //tests substring get with a large string value
+ public void testGeSubStrings3() {
+ manipulatedstring.setString("Rap snitches, telling all their business, sit in the court, and be their own star witness");
+ String [] sStings = manipulatedstring.getSubStrings(7, 16);
+
+ assertEquals(sStings[0], "sit");
+ assertEquals(sStings[6], "their");
+ assertEquals(sStings[9], "witness");
+ }
+ @Test
+ //tests substring get with an empty string value
+ public void testGeSubStrings4() {
+ manipulatedstring.setString("");
+ assertThrows(IllegalArgumentException.class, () -> { manipulatedstring.getSubStrings(5, 2); });
+ }
+ @Test
+ //tests substring get with trailing spaces
+ public void testGeSubStrings5() {
+ manipulatedstring.setString(" a ");
+ String [] sStings = manipulatedstring.getSubStrings(1, 1);
+
+ assertEquals(sStings[0], "a");
+ }
+ @Test
+ //tests substring get with multiple trailing spaces between words
+ public void testGeSubStrings6() {
+ manipulatedstring.setString(" a b c d .e");
+ String [] sStings = manipulatedstring.getSubStrings(3, 5);
+
+ assertEquals(sStings[0], "c");
+ assertEquals(sStings[2], ".e");
+ }
+
+ @Test
+ //tests restore string expecting success
+ public void testRestoreString1()
+ {
+ manipulatedstring.setString("art");
+ int [] array;
+ array=new int[]{1,0,2};
+ String restoreString = manipulatedstring.restoreString(array);
+ assertEquals(restoreString, "rat");
+ }
+
+ @Test
+ //tests restore string again with a different string input
+ public void testRestoreString2()
+ {
+ manipulatedstring.setString("dormitory");
+ int [] array;
+ array=new int[]{0,4,2,5,8,7,6,1,3};
+ String restoreString = manipulatedstring.restoreString(array);
+ assertEquals(restoreString, "dirtyroom");
+ }
+
+ @Test
+ //tests swapping only one pair
+ public void testRestoreString3()
+ {
+ manipulatedstring.setString("angel");
+ int [] array;
+ array=new int[]{0,1,2,4,3};
+ String restoreString = manipulatedstring.restoreString(array);
+ assertEquals(restoreString, "angle");
+ }
+
+ @Test
+ //tests out of right max bound
+ public void testRestoreString4()
+ {
+ manipulatedstring.setString("bob");
+ int [] array;
+ array=new int[]{0,2,10};
+ assertThrows(ArrayIndexOutOfBoundsException.class, () -> { manipulatedstring.restoreString(array); });
+ }
+
+ @Test
+ //tests out of min left bound
+ public void testRestoreString5()
+ {
+ manipulatedstring.setString("cat");
+ int [] array;
+ array=new int[]{2,1,-3};
+ assertThrows(ArrayIndexOutOfBoundsException.class, () -> { manipulatedstring.restoreString(array); });
+ }
+
+}