public void ReverseStringInPlace_SeussInput_CharReversalSucceeds() { string input = "the cat in the hat"; char[] inputArray = input.ToCharArray(); var so = new StringOps(); so.ReverseStringInPlace(inputArray, 0, inputArray.Length); string output = new string(inputArray); Assert.AreEqual(output, "tah eht ni tac eht"); }
public void ReverseWordsInSentenceInPlace_SeussInput_WordReversalSucceeds() { string input = "the cat in the hat"; char[] inputArray = input.ToCharArray(); int len = inputArray.Length; var so = new StringOps(); so.ReverseStringInPlace(inputArray, 0, len); so.ReverseWordsInSentenceInPlace(inputArray, len); string output = new string(inputArray); Assert.AreEqual(output, "hat the in cat the"); }