public void Test_StringManipulator_IndexOfStringStartIndexInLaterSectionNotFound() { StringManipulator m = new StringManipulator(); m.Append("hello cru"); m.Append("el world"); Assert.AreEqual("hello cruel world".IndexOf("k", 7), m.IndexOf("k", 7)); }
public void Test_StringManipulator_InsertString() { StringManipulator m = new StringManipulator(); m.Append("hello"); m.Append(" world"); m.Insert("cruel", 6); Assert.AreEqual("hello cruel world", m.ToString()); }
public void Test_StringManipulator_IndexOfStringStartIndex() { StringManipulator m = new StringManipulator(); m.Append("hello cru"); m.Append("el world"); Assert.AreEqual("hello cruel world".IndexOf("l", 3), m.IndexOf("l", 3)); }
public void Test_StringManipulator_AddTwoStrings() { StringManipulator m = new StringManipulator(); m.Append("hello"); m.Append(" world"); Assert.AreEqual("hello world", m.ToString()); }
public void Test_StringManipulator_IndexOfSingleLetter() { StringManipulator m = new StringManipulator(); m.Append("hello cru"); m.Append("el world"); Assert.AreEqual("hello".IndexOf('l'), m.IndexOf("l")); }
public void Test_StringManipulator_IndexOfStringInSecondSections() { StringManipulator m = new StringManipulator(); m.Append("hello cru"); m.Append("el world"); Assert.AreEqual("hello cruel world".IndexOf("rld"), m.IndexOf("rld")); }
public void Test_StringManipulator_SubstringMultipleSection() { StringManipulator m = new StringManipulator(); m.Append("hello cru"); m.Append("el world"); Assert.AreEqual("cruel", m.Substring(6, 5)); }
public void Test_StringManipulator_RemoveWholeFirstSection() { StringManipulator m = new StringManipulator(); m.Append("hello "); m.Append("world"); m.Remove("hello "); Assert.AreEqual("world", m.ToString()); }
public void Test_StringManipulator_RemoveSingleStringAcrossTwoSections() { StringManipulator m = new StringManipulator(); m.Append("hello cr"); m.Append("uel world"); m.Remove("cruel"); Assert.AreEqual("hello world", m.ToString()); }
public void Test_StringManipulator_RemoveWholeLastSectionAndReplace() { StringManipulator m = new StringManipulator(); m.Append("hello "); m.Append("cruel "); m.Append("world"); m.Replace("world", "suzy"); Assert.AreEqual("hello cruel suzy", m.ToString()); }
public void Test_StringManipulator_RemoveMidTextAndReplace() { StringManipulator m = new StringManipulator(); m.Append("hello"); m.Append(" cruel "); m.Append("world"); m.Replace(" cruel ", " big "); Assert.AreEqual("hello big world", m.ToString()); }
public void Test_StringManipulator_RemoveSingleStringAcrossThreeSections() { StringManipulator m = new StringManipulator(); m.Append("hello cr"); m.Append("u"); m.Append("el world"); m.Remove("cruel"); Assert.AreEqual("hello world", m.ToString()); Assert.AreEqual("hello world".Length, m.Length, "The Lengths should be the same too"); }
private static void TestStringManipulator() { Console.Write("String Manipulator: "); Stopwatch sw = new Stopwatch(); sw.Start(); var sb = new StringManipulator(); for (int x = 0; x < 1000; x++) { sb.Append("Hello "); } for (int x = 0; x < 1000; x++) { sb.Insert("World", 50); } for (int x = 0; x < 1000; x++) { sb.Replace("Hello ", "Hey "); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }
public void TestTimingSM() { Stopwatch sw = new Stopwatch(); sw.Start(); var sb = new StringManipulator(); for (int x = 0; x < 1000; x++) { sb.Append("Hello "); } for (int x = 0; x < 1000; x++) { sb.Insert("World", 50); } for (int x = 0; x < 1000; x++) { sb.Replace("Hello ", "Hey "); } sw.Stop(); Assert.IsFalse(true, $"{sw.ElapsedMilliseconds}"); }
public void Test_StringManipulator_ReplaceMany() { StringManipulator m = new StringManipulator(); m.Append("hello cruel world"); m.Replace("l", "L"); Assert.AreEqual("heLLo crueL worLd", m.ToString()); }
public void Test_StringManipulator_RemoveTwoStringsInsideSection() { StringManipulator m = new StringManipulator(); m.Append("hello cruel world"); m.Remove("l"); Assert.AreEqual("heo crue word", m.ToString()); }